Commit graph

120 commits

Author SHA1 Message Date
Abdul Fatir
8c686cfa71
Bump version from 2.2.0rc1 to 2.2.0rc2 2025-11-30 16:53:59 +01:00
Abdul Fatir
5cde42eb1f
Chronos-2: Add option to specify callbacks in fit (#405)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-28 16:55:35 +01:00
Abdul Fatir
514019fb1c
Fix potential crash due to unbound local in df_utils (#404)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-28 13:54:52 +01:00
Abdul Fatir
a942c0609c
Update peft version constraint in pyproject.toml 2025-11-28 00:08:38 +01:00
Abdul Fatir
32023ec99f
Bump version to 2.2.0rc1 2025-11-28 00:07:25 +01:00
Abdul Fatir
b438bed63f
Chronos-2: Add option to skip dataframe validation in predict_df (#400)
*Issue #, if available:*

*Description of changes:* This PR adds a `validate_inputs ` argument to
`predict_df` (defaults to `True`), which allows the user to disable
dataframe validation when they know that their dataframe is in the right
format. This reduces runtime by removing the input validation component,
e.g., when calling this method from
[AutoGluon](https://github.com/autogluon/autogluon/pull/5427), and also
handles series with shorter than 3 timesteps.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-27 16:52:37 +01:00
Abdul Fatir
c5907ef52e
Chronos-2: Add LoRA fine-tuning support (#393)
*Issue #, if available:*

*Description of changes:* Adds support for LoRA fine-tuning.

- [x] Move peft/pandas dependency to an extra
- [x] Add tests for LoRA
- [x] Update notebook with LoRA info
- [x] Enable automatic recognition and loading of LoRA adapters


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-25 16:06:58 +01:00
Oleksandr Shchur
bcd563eb66
Optimize convert_df_input_to_list_of_dicts_input and validate_df_inputs (#395)
*Issue #, if available:* Addresses #391

*Description of changes:*

- Speed up `convert_df_input_to_list_of_dicts_input` and
`validate_df_inputs` via a few tricks:
- Replace `df.iloc[start_idx:end_idx][col]` with
`df[col].iloc[start_idx:end_idx]` to avoid copying data on each slice
  - Vectorize computation of future timestamps using numpy
- Work with `dict[str, np.ndarray]` instead of `pd.DataFrame` when
working with covariates to avoid repeated `.to_numpy()` calls.


**Before**
```
Benchmarking 20000 series, 200 steps, 0 covariates...
Average runtime: 27.33s
Benchmarking 20000 series, 200 steps, 5 covariates...
Average runtime: 44.69s
```

**After**
```
Benchmarking 20000 series, 200 steps, 0 covariates...
Average runtime: 4.60s
Benchmarking 20000 series, 200 steps, 5 covariates...
Average runtime: 8.92s
```

<details> 

```python
import time

import numpy as np
import pandas as pd

from chronos.df_utils import convert_df_input_to_list_of_dicts_input


def benchmark_convert_df_input(
    num_items: int, num_steps: int, num_covariates: int = 0, num_trials: int = 10, freq: str = "D"
) -> None:
    """
    Benchmark convert_df_input_to_list_of_dicts_input function.

    Args:
        num_items: Number of time series
        num_steps: Number of observations per series
        num_covariates: Number of covariates to include
        num_trials: Number of benchmark trials
        freq: Frequency string for timestamps
    """
    prediction_length = 24

    # Generate context DataFrame
    item_ids = np.repeat(np.arange(num_items), num_steps)
    timestamps = np.tile(pd.date_range("2020-01-01", periods=num_steps, freq=freq), num_items)

    df_data = {"item_id": item_ids, "timestamp": timestamps, "target": np.random.randn(num_items * num_steps)}
    df_data.update({f"cov_{i}": np.random.randn(num_items * num_steps) for i in range(num_covariates)})
    df = pd.DataFrame(df_data)

    # Generate future_df with covariates
    future_df = None
    if num_covariates > 0:
        future_item_ids = np.repeat(np.arange(num_items), prediction_length)
        offset = pd.tseries.frequencies.to_offset(freq)
        future_start = pd.Timestamp("2020-01-01") + num_steps * offset
        future_timestamps = np.tile(pd.date_range(start=future_start, periods=prediction_length, freq=freq), num_items)

        future_data = {"item_id": future_item_ids, "timestamp": future_timestamps}
        future_data.update({f"cov_{i}": np.random.randn(num_items * prediction_length) for i in range(num_covariates)})
        future_df = pd.DataFrame(future_data)

    times = []
    print(f"Benchmarking {num_items} series, {num_steps} steps, {num_covariates} covariates...")
    for _ in range(num_trials):
        start = time.perf_counter()
        convert_df_input_to_list_of_dicts_input(
            df=df,
            future_df=future_df,
            id_column="item_id",
            timestamp_column="timestamp",
            target_columns=["target"],
            prediction_length=prediction_length,
        )
        end = time.perf_counter()
        times.append(end - start)

    print(f"Average runtime: {sum(times) / len(times):.2f}s")


if __name__ == "__main__":
    # Test without covariates
    benchmark_convert_df_input(20_000, 200, num_covariates=0, num_trials=1)

    # Test with covariates
    benchmark_convert_df_input(20_000, 200, num_covariates=5, num_trials=1)
```

</details>

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-25 15:30:32 +01:00
Oleksandr Shchur
d6f8ea4301
Fix link in Chronos-Bolt tutorial notebook entry (#396)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-25 13:18:43 +01:00
Abdul Fatir
972a09b626
Chronos-2: Convert assert about batch size to warning (#392) 2025-11-24 09:22:43 +01:00
Abdul Fatir
7daaa7194c
Bump version to 2.1.0 (#389)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-21 11:50:52 +01:00
Abdul Fatir
182aafe184
Update torch dependency version to >=2.2,<3 (#388)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-21 11:37:14 +01:00
Abdul Fatir
67a6f91aec
Update version to 2.1.0rc1 for pre-release (#383)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-18 10:52:56 +01:00
Abdul Fatir
359d7ff1b9
Chronos-2: Change default fine-tuning learning rate and remove experimental label (#381)
*Issue #, if available:*

*Description of changes:* Lower learning rates generally appear to be
working better. This is probably because we are doing full fine-tuning
of a model with 120M params.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-18 10:33:38 +01:00
Abdul Fatir
0f3c5652e5
Mask past-only covariates during loss computation (#379)
*Issue #, if available:*

*Description of changes:* This PR masks rows corresponding to all
covariates in the future target. Specifically, this is to avoid the
contribution of past-only covariates in loss computation. The previous
setup was correct from the perspective of pretraining but I think this
makes more sense for fine-tuning.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-17 18:02:55 +01:00
Abdul Fatir
111972a6cc
Add Chronos2Pipeline.embed (#361)
*Issue #, if available:* #354 

*Description of changes:* This PR adds `Chronos2Pipeline.embed` to
enable users to extract embeddings from the last encoder layer in an
easy way. The API and behavior is similar to what Chronos and
Chronos-Bolt provides.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-17 17:16:50 +01:00
Abdul Fatir
e48f48071f
Add predict_df support for Chronos and Chronos-Bolt (#371)
*Issue #, if available:*

*Description of changes:* This PR adds `predict_df` to the base pipeline
which enables pandas support for the univariate Chronos and Chronos-Bolt
models.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-11 18:37:19 +01:00
Abdul Fatir
22c036bf07
Fix SageMaker deployment link in README 2025-11-07 16:04:35 +01:00
Abdul Fatir
46b20c2d54
Update long horizon heuristic for Chronos-Bolt (#366)
*Issue #, if available:*

*Description of changes:* In light of the planned AG dependency on this
package, this PR updates the long horizon heuristic of Chronos-Bolt to
what it was in AG (introduced in
https://github.com/autogluon/autogluon/pull/5177). Code has been
copy-pasted [from
AG](5fcebaa493/timeseries/src/autogluon/timeseries/models/chronos/pipeline/chronos_bolt.py (L441)).


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-11-06 11:25:48 +01:00
Ilias Aarab
78bd1c90ca
Set num_workers=0 in Chronos-2 test data loader (#365)
By default, the `transformers` library sets the `num_workers` argument
of the PyTorch DataLoader to `0`, ensuring out-of-the-box compatibility
across different platforms.

*Issue #, if available:*

*Description of changes:*

Set the DataLoader `num_workers` argument to `0` to improve
cross-platform compatibility, particularly on Windows systems where
multiprocessing requires guarded execution.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Abdul Fatir <Abdulfatirs@gmail.com>
2025-11-05 23:33:07 +01:00
Abdul Fatir
93419cfe9f
Relax transformers lower bound to >=4.41 (#364) 2025-11-05 14:27:46 +01:00
Abdul Fatir
c23d34cd88
Add FutureWarning for CloudFront (#357)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-31 11:05:09 +01:00
Abdul Fatir
c5aa5f4292
Update Notebooks and README (#356)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Oleksandr Shchur <oleks.shchur@gmail.com>
2025-10-31 10:09:04 +01:00
Oleksandr Shchur
dc5c438ab2
Remove logo from README (#355)
Removed logo image from the README.

*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-31 08:13:20 +01:00
Oleksandr Shchur
9f8fef2116
Update model link to Hugging Face (#353)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-30 18:08:57 +01:00
Oleksandr Shchur
c60bd2ce4e
Add Chronos-2 SageMaker notebook (#350)
*Issue #, if available:*

*Description of changes:*
- Add notebook showcasing how Chronos-2 can be deployed using Amazon
SageMaker

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-30 10:11:07 +01:00
Xiaoxuan(Alex) Zhang
6c6915501c
fix validate_and_prepare_single_dict_task by separating "past only" and "future known" cov keys (#344)
Closes #345 

Hi @abdulfatir 
Here is the bugfix about the function
"validate_and_prepare_single_dict_task", which had 2 issue points:

1. Originally, one of this func return, the "task_n_future_covariates",
will return the ["past only" + "future known"]covariates number, by
`task_n_future_covariates = len(task_future_covariates_list)` as
`task_future_covariates_list ` is filled by for` key in
task_covariates_keys`
2. The code seems not to guarantee the last "future known" rows are
atcually what we expected, even there is a sorted option.

So, this PR fixed them by separating "past only" and "future known" covs
from the "past_covariates" input, and explicitly put the "past only"
covs rows above "future known" cov rows, supported by a temp list
"ordered_covariate_keys".
2025-10-29 14:00:56 +01:00
Oleksandr Shchur
6d46e628ae
Revert "Move SageMaker notebook to a new path" (#349)
Reverts amazon-science/chronos-forecasting#348
2025-10-29 13:58:23 +01:00
Oleksandr Shchur
c09c33fcbe
Move SageMaker notebook to a new path (#348)
*Issue #, if available:*

*Description of changes:*
- Move the SageMaker deployment notebook to a new path to check that the
GitHub redirect feature works.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-29 13:50:40 +01:00
Abdul Fatir
fbe2ae491d
Count notebooks as python in language stats (#347)
*Issue #, if available:*

*Description of changes:* The repo is classified as a Jupyter Notebook
repo. This PR attempts to fix this by counting notebooks as python files
instead of a separate thing.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-29 09:12:28 +01:00
Abdul Fatir
93b90b7abe
Treat notebooks as documentation in linguist (#338)
*Issue #, if available:*

*Description of changes:* This PR updates `.gitattributes` to treat
notebooks as documentation rather than code when computing language
statistics. See: https://github.com/github-linguist/linguist/issues/3282


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-22 15:06:23 +02:00
Kashif Rasul
ca9c3275a2
[chronos-2] add support for SDPA (#331)
This pull request introduces configurable attention backends to the
Chronos-2 model, allowing users to select between eager, SDPA, and
FlashAttention-2 implementations.

---------

Co-authored-by: Oleksandr Shchur <oleks.shchur@gmail.com>
Co-authored-by: Abdul Fatir <Abdulfatirs@gmail.com>
2025-10-22 14:02:09 +02:00
Abdul Fatir
0c51188db7
Add logging steps in fine-tuning example (#334)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-21 19:58:26 +02:00
Abdul Fatir
6c4f999922
Update Chronos-2 notebook install instructions (#333)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-21 17:24:10 +02:00
Adnan Khan
a52d460f04
Scope down GitHub token permissions (#328)
*Issue #, if available:*

*Description of changes:*

Scope down GitHub token permissions for GHA security best practices.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-21 07:48:03 +02:00
Abdul Fatir
330c5438a6
Fix pandas install instruction (#326)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-20 16:11:37 +02:00
Abdul Fatir
7a8427d18e
Bump version to 2.0.0 (#323)
*Issue #, if available:*

*Description of changes:* Bump to 2.0


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-20 15:23:23 +02:00
Abdul Fatir
5e3a6a1f13
Update README for Chronos-2 (#324)
*Issue #, if available:*

*Description of changes:* Update README for Chronos-2

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Oleksandr Shchur <oleks.shchur@gmail.com>
2025-10-20 14:56:55 +02:00
Oleksandr Shchur
c475a9123f
Add example notebook for Chronos-2 (#325)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-20 14:02:18 +02:00
Abdul Fatir
48cdf1f7f6
Use dynamic versioning and bump version (#320)
⚠️ Must be merged after #319 and other related PRs.

*Issue #, if available:*

*Description of changes:* Exports `chronos.__version__` and uses it
dynamically in `pyproject.toml`. Bumps version to 2.0.0.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-20 12:04:04 +02:00
Abdul Fatir
3d08338f37
Remove ALWAYS_DOWNLOAD from CF and S3 (#322)
*Issue #, if available:*

*Description of changes:* Remove `ALWAYS_DOWNLOAD` so that Chronos-2
works in a fully offline env if model files are cached.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-10-20 11:41:58 +02:00
Abdul Fatir
15ffe8835d
Add Chronos-2 (#319)
*Issue #, if available:*

*Description of changes:* This PR adds the Chronos-2 model.

* Chronos-2 modeling and pipeline code, including tests.
* Updated `pyproject.toml`. Merge `training` and `evaluation` extras
into a single `dev` extra. This stuff is only relevant for the Chronos
models.
* Added `predict_fev` to `BaseChronosPipeline`.
* Changes to `InstanceNorm` for Chronos-Bolt to make it general and
compatible with Chronos-2.
* Minor renaming and polishing in the inference code for Chronos and
Chronos-Bolt.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Oleksandr Shchur <oleks.shchur@gmail.com>
2025-10-20 10:34:20 +02:00
Abdul Fatir
fcd09fe8b6
Fix issue with new caching mechanism in transformers and bump versions (#313)
*Issue #, if available:* Fixes #310 and closes #302

*Description of changes:* This PR fixes an issue related to the new
caching mechanism for T5 introduced in `transformers==4.54`. [Prior
versions
set](https://github.com/huggingface/transformers/blob/v4.53.3/src/transformers/models/t5/modeling_t5.py#L1328)
`encoder_config.is_encoder_decoder = False` when initializing encoder
and decoder. Following transformers, we also initialized Chronos-Bolt in
the same way. However, in v4.54 this line [has been
removed](3fd456b200/src/transformers/models/t5/modeling_t5.py (L1301))
and [new logic has been
added](3fd456b200/src/transformers/models/t5/modeling_t5.py (L494))
which relies on `is_encoder_decoder` [being
True](3fd456b200/src/transformers/models/t5/modeling_t5.py (L1007)).
This causes Chronos-Bolt to break as described in #310. This PR removes
`is_encoder_decoder = False` for both encoder and decoder which fixes
the issue. I re-ran our mini eval in the CI and got the same results for
v4.54 and v4.48 (our current lower bound).

This PR also bumps package versions. 


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-08-05 10:46:12 +02:00
Abdul Fatir
6a9c8dadac
Bump version to 1.5.2 (#299)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-05-06 10:20:46 +02:00
Tyler
c5880604df
Bump accelerate>=0.32,<2 (#298)
*Issue #, if available:*

*Description of changes:*

Just increased the max version allowed. Tests pass.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Abdul Fatir <Abdulfatirs@gmail.com>
2025-05-06 10:15:22 +02:00
Lorenzo Stella
f40a266a55
Fix type-checking issues (#295)
*Issue #, if available:* See example build
https://github.com/amazon-science/chronos-forecasting/actions/runs/14302765904/job/40313421985

*Description of changes:*
- Address type-checker complaints, where possible
- Bump bugfix version of the package


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-04-10 17:23:59 +02:00
Abdul Fatir
eec771e339
Fix scaling that affects constant series (#294) 2025-04-07 08:54:03 +02:00
Lorenzo Stella
94e20ea7e5
Fix date in readme (#284)
*Issue #, if available:*

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-02-19 08:47:59 +01:00
Oleksandr Shchur
a996ca79ad
Add example notebook for SageMaker JumpStart (#281)
*Issue #, if available:*

*Description of changes:*
- Add pointers to fev and JumpStart notebook in the README
- Add notebook describing how to deploy Chronos with SageMaker JumpStart


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-02-17 10:35:42 +01:00
Lorenzo Stella
8178798f4e
Bump transformers to >=4.48 (#280)
*Issue #, if available:* addresses
https://github.com/amazon-science/chronos-forecasting/security/dependabot/1

*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-02-13 13:46:47 +01:00