Skip to content

feat(chronos): add a finetune extra with peft for LoRA finetuning #57

Open

Description

@AzulGarza

Problem

Chronos supports ChronosFinetuningConfig(finetune_mode="lora"), and LoRA checkpoints are reloaded through PEFT (Chronos2Pipeline.from_pretrained). But peft is not a dependency of foundationforecast: it is absent from pyproject.toml and uv.lock.

As a result:

  • pip install foundationforecast succeeds, but LoRA finetuning fails at runtime with an import error from the Chronos backend.
  • tests/models/test_chronos.py uses pytest.importorskip("peft"), so the LoRA path is silently skipped in CI and never exercised.
  • docs/examples/finetuning.ipynb runs LoRA examples, so its install cell has to add peft by hand (raised by Copilot on docs: add a uv install cell to every example notebook #55).

Proposal

  1. Add an optional extra:

    [project.optional-dependencies]
    finetune = ["peft>=0.13.0,<1"]

    (Same bound TimeCopilot uses.)

  2. Add peft to the dev group (or install [finetune] in CI) so the LoRA test actually runs instead of being skipped.

  3. When finetune_mode="lora" and peft is missing, raise a clear error: install foundationforecast[finetune].

  4. Update docs/examples/finetuning.ipynb and the finetuning docs to install foundationforecast[plot,finetune].

Related: #56 (optional per-model extras), which this extra would fit into.

Activity

  1. sharmis-tp commented on Oct 30, 2026

    @sharmis-tp

    Can I take this? Part 2 is done since #65 (peft>=0.20.0,<1 is now in the dev group, pyproject.toml line 8), so what's left:

    • Add finetune = ["peft>=0.20.0,<1"] under [project.optional-dependencies] next to plot (~80-84). I'd use 0.20, not the 0.13 in the issue, because Chronos._load_model imports peft.auto.get_default_import_allowlist for LoRA adapters (foundationforecast/models/chronos.py ~341-353), and refactor(chronos): require peft>=0.20 and drop the allowlist fallback #65 pinned 0.20 for that.
    • Fail early with a clear message: when finetuning_config.finetune_mode == "lora" (passed to fit at ~328-331), or an adapter_config.json is found at load time, check for peft and raise "LoRA finetuning needs peft: pip install 'foundationforecast[finetune]'". Today that's an ImportError from deep in the backend.
    • Test: monkeypatch the import to fail and assert the message for both paths. test_chronos_lora_finetuning_save_and_reuse (tests/models/test_chronos.py:67) keeps covering the real path.
    • Docs: install cell in docs/examples/finetuning.ipynb -> foundationforecast[plot,finetune], and the finetuning section of the docs.

    Separate commits per type, as AGENTS.md asks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions