feat: add T0Model foundation model#3142
Conversation
Add T0Model, a Darts wrapper around The Forecasting Company's open-weights T0 foundation model (theforecastingcompany/t0-alpha on HuggingFace), following the existing foundation-model pattern (TiRex/Chronos-2). - Wraps the optional `tfc-t0` package; subclasses `FoundationModel` for zero-shot inference (univariate, multivariate, multiple series). - Supports future covariates (mapped to T0's [B, F, context+horizon] format) and QuantileRegression probabilistic forecasts (any quantiles in (0,1); T0 interpolates levels it was not trained on). - Registers in models lazy-import table, conftest availability flag, README/INSTALL/docs tables, pyproject `optional` group, and CHANGELOG. - Tests in test_t0.py mock `T0Forecaster.from_pretrained` (no weight download).
|
Nice PR! @GeoffNN Leaving my two cents here as the original contributor of Would you consider relaxing t0 python bounds to 3.10+ so all users can access your model? Also, is there a reason why past covariates cannot be supported? I have not looked into the model architecture, but would implanting past covariates as part of the context help improve the forecast quality? If so, I would suggest appending past covariates to the context and dropping them from the output. PS. It would be nice if a technical report / blog post can be provided to help us and users understand the model better. |
|
Hi @daidahao ! The tech report & blog post are both incoming, we'll release this a bit later. |
tfc-t0 requires python>=3.11,<3.14 but darts supports python>=3.10, so an unconditional entry made uv unable to resolve dev-all across darts' full range, breaking all CI jobs at the sync step. Mirror the onnxruntime pattern and add a python_version marker.
T0 is variate-agnostic, so past covariates are appended to the context and forecast jointly with the target, then dropped from the output (per review feedback from @daidahao). Future covariates continue to use T0's covariate branch. Flip supports_past_covariates to True; update docstrings, model tables, changelog, and tests (parametrized over future/past/both).
|
Thanks a lot for this PR @GeoffNN 🚀 Before giving a full review, there are two points:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3142 +/- ##
==========================================
- Coverage 96.94% 96.89% -0.06%
==========================================
Files 164 165 +1
Lines 17709 17757 +48
==========================================
+ Hits 17168 17205 +37
- Misses 541 552 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi both!
Since the model is Apache 2.0, there's no restriction on our side for this! |
|
Thanks a lot for the updates @GeoffNN, that sounds great 🚀 Regarding fine-tuning:
Let me know if it's clear or whether we can support in any way. |
|
@GeoffNN another question regarding adding tfc-t0 as a dependency to Darts: I quickly checked out your dependency requirements and noticed that all have an upper version cap here. Is there a specific reason you limit the upper versions? That would mean that at some point, tfc-t0 would block Darts users from installing newer dependency versions. Would it be possible to relax (remove) these caps? |
…dation-model # Conflicts: # CHANGELOG.md
- raise_log() no longer takes a logger arg (auto-resolved from caller module). - PLModuleInput is now a 4-tuple; unpack x_past, x_future, _, _.
…to feature/add-t0-foundation-model
…r py3.10 support) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Hello! Sorry for the delay here, we've been traveling - and want to think about the API surface we expose, especially for the with-gradients side. Re: versions - I believe we gate against untested (future) versions, to avoid breaking the package silently if the dependencies change their API on a major version. Let me double check. |
|
Thanks for the updates @GeoffNN 🚀 In the open-source world the continuous dependency integration (e.g. checking against newest versions and then fixing the package continuously if there are some breaking changes in dependencies) is a pro-active way to keep the package up-to-date. So, I would always recommend to go that way (except maybe where you're developing apps or similar where you want to ensure everyone user gets the exact same fixed environment (via dependency lockfiles for example). Let me know what you think |
Hi folks! Great work on darts! 🙏
We just released our first open-source model: t0-alpha. Adding it to your library so people can easily use it, benchmark it etc.
Checklist before merging this PR:
Summary
Adds
T0Model, a Darts wrapper around The Forecasting Company's open-weights T0 foundation model (~100M-parameter patch transformer for zero-shot forecasting). It follows the existing foundation-model pattern, closest toTiRexModel(delegates to an optional pip package) while also supporting future covariates likeChronos2Model.FoundationModel; zero-shot inference for univariate, multivariate, and multiple series.tfc-t0package (from t0 import T0Forecaster), declared in theoptionaldependency group (not pulled bydarts[torch]).supports_future_covariates=True):forward()reassembles Darts'(x_past, x_future)into T0's[B, F, context + horizon]covariate layout, NaN-filling theoutput_chunk_shiftgap (T0 treats NaN as missing). Past covariates are not supported.QuantileRegression. Any quantiles in(0, 1)are accepted — T0 interpolates levels it was not trained on (it was trained on[0.1, 0.25, 0.5, 0.75, 0.9]).predict()runs undertorch.inference_mode()).Registered in the models lazy-import table,
conftestavailability flag (T0_AVAILABLE), README / INSTALL / docs model tables,pyproject.tomloptionalgroup, andCHANGELOG.md.Other Information
Tests in
darts/tests/models/forecasting/test_t0.pymockT0Forecaster.from_pretrainedso CI never downloads weights (gated behindT0_AVAILABLE, matching the TiRex test pattern). Covers creation/validation, deterministic + probabilistic, multivariate, future covariates, and multiple series.Verified locally against the real
theforecastingcompany/t0-alphaweights — univariate deterministic, probabilistic with interpolated quantiles (0.05/0.95), future-covariate, and multivariate forecasts all produce finite outputs of the expected shape.🤖 Generated with Claude Code