Skip to content

Add clean cache option to forecaster#358

Merged
AzulGarza merged 1 commit into
TimeCopilot:mainfrom
elmartinj:add-clean-cache-forecaster
Jun 18, 2026
Merged

Add clean cache option to forecaster#358
AzulGarza merged 1 commit into
TimeCopilot:mainfrom
elmartinj:add-clean-cache-forecaster

Conversation

@elmartinj

Copy link
Copy Markdown
Contributor

Summary

Adds an optional clean_cache parameter to TimeCopilotForecaster.

When enabled, the forecaster runs cache cleanup after each model call inside the shared _call_models() loop. This helps memory-heavy workflows, especially when running multiple foundation models sequentially.

Changes

  • Added clean_cache: bool = False to TimeCopilotForecaster.
  • Added _clean_model_cache() helper.
  • Cleanup currently runs:
    • gc.collect()
    • torch.cuda.empty_cache() when Torch is installed and CUDA is available
  • Integrated cleanup after each model forecast/cross-validation call.
  • Added a unit test confirming cleanup runs once per model when clean_cache=True.

Validation

uv run pytest -n 2 tests/test_forecaster.py -q
# 12 passed

uv run pre-commit run --all-files
# passed

@AzulGarza AzulGarza self-requested a review June 18, 2026 16:54

@AzulGarza AzulGarza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @elmartinj! lgtm.:)

@AzulGarza AzulGarza merged commit d9efbff into TimeCopilot:main Jun 18, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants