Skip to content

feat: add chronos finetunning#323

Merged
AzulGarza merged 20 commits intomainfrom
feat/funetunning-chronos
Mar 17, 2026
Merged

feat: add chronos finetunning#323
AzulGarza merged 20 commits intomainfrom
feat/funetunning-chronos

Conversation

@AzulGarza
Copy link
Member

this pr adds the option to finetune chronos models

Copilot AI review requested due to automatic review settings March 17, 2026 03:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class support for finetuning Chronos (incl. optional checkpoint saving/reuse) within timecopilot’s Chronos forecaster, plus accompanying dependency and documentation updates.

Changes:

  • Introduce ChronosFinetuningConfig and finetune-on-forecast flow (forecast() finetunes on the provided context before predicting).
  • Add finetuning-related tests and expand the shared model test matrix to include finetuning variants.
  • Update dependencies (Chronos wrapper, peft, transformers constraint) and expose the new config in docs + mkdocs nav.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
timecopilot/models/foundation/chronos.py Adds finetuning config + finetune hook in forecast(), and special-cases loading LoRA adapter checkpoints.
tests/models/foundation/test_chronos.py Adds an integration-style test covering finetune → save → reuse workflow.
tests/models/conftest.py Adds finetuning-enabled Chronos instances to the global model matrix and new imports.
pyproject.toml Adds peft, bumps Chronos wrapper, relaxes transformers pinning for <3.13.
mkdocs.yml Adds a finetuning example notebook to docs navigation.
docs/api/models/foundation/models.md Exposes ChronosFinetuningConfig in API reference generation.
Comments suppressed due to low confidence (2)

tests/models/conftest.py:131

  • Inside the sys.version_info < (3, 13) block, Sundial is imported but no longer appended to the models list after this change. As written, that import becomes unused (lint failure) and it also drops Sundial from the main model test matrix on supported Python versions. Either re-add Sundial(...) to models here or remove the import if the exclusion is intentional.
    from tabpfn_time_series import TabPFNMode

    from timecopilot.models.foundation.tabpfn import TabPFN

    models.append(TabPFN(mode=TabPFNMode.MOCK))

timecopilot/models/foundation/chronos.py:218

  • BaseChronosPipeline.from_pretrained(...) is called with dtype=self.dtype, but elsewhere (and in existing tests) the expected kwarg is torch_dtype. This likely means the requested weight dtype will be ignored and test_chronos_model_uses_configured_dtype will fail (and it may also break compatibility with the underlying Hugging Face/Chronos API). Use torch_dtype=self.dtype consistently here (matching the Chronos2Pipeline branch).
        try:
            yield model
        finally:
            del model
            torch.cuda.empty_cache()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds optional finetuning support for Chronos foundation models, enabling on-the-fly finetuning on the forecast context (including LoRA/PEFT support) and reuse of saved finetuned checkpoints.

Changes:

  • Introduce ChronosFinetuningConfig and integrate optional finetuning into Chronos.forecast().
  • Add support for loading saved LoRA checkpoints by selecting Chronos2Pipeline.from_pretrained when adapter_config.json is present.
  • Update dependencies to support finetuning (add peft, bump timecopilot-chronos-forecasting, adjust transformers constraints) and surface docs/example notebook entries.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
timecopilot/models/foundation/chronos.py Adds finetuning configuration + finetune hook; updates model loading to handle LoRA checkpoints.
tests/models/foundation/test_chronos.py Adds tests for finetuning save/reuse and LoRA save/reuse.
tests/models/conftest.py Removes Sundial from the shared model test matrix.
pyproject.toml Adds peft dependency; bumps chronos forecasting; adjusts transformers constraint for <3.13.
uv.lock Updates lockfile for new/updated dependencies (incl. peft, transformers/tokenizers resolution changes).
mkdocs.yml Adds finetuning notebook to documentation navigation.
docs/api/models/foundation/models.md Exposes ChronosFinetuningConfig in the API docs.
Comments suppressed due to low confidence (1)

tests/models/conftest.py:114

  • This change removes Sundial from the shared models test matrix for Python <3.13. Since this PR is about Chronos finetuning, this looks like an unrelated coverage reduction; if Sundial is still a supported foundation model, consider keeping it in the matrix (or add a comment/PR description note explaining why it’s excluded).
if sys.version_info < (3, 13):
    from tabpfn_time_series import TabPFNMode

    from timecopilot.models.foundation.tabpfn import TabPFN

    models.append(TabPFN(mode=TabPFNMode.MOCK))


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@AzulGarza AzulGarza merged commit 4eba8da into main Mar 17, 2026
9 checks passed
@AzulGarza AzulGarza deleted the feat/funetunning-chronos branch March 17, 2026 05:57
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