Commit graph

150 commits

Author SHA1 Message Date
Oleksandr Shchur
47be457206 Use typing_extensions for NotRequired 2026-02-20 17:06:04 +00:00
Oleksandr Shchur
7695bf1442 Bump version 2026-02-20 16:34:30 +00:00
Oleksandr Shchur
560f34aeac Only require future_covariates if mode == TEST 2026-02-19 12:50:39 +00:00
Oleksandr Shchur
f951d9aefa
Rename task -> input in dataset.py (#467)
*Issue #, if available:*

*Description of changes:*

Rename all variables and methods that refer to "task" in `dataset.py` to
use `input` instead:
- `PreparedTask` → `PreparedInput`
- `self.tasks` → `self.inputs`
- `prepare_tasks` → `prepare_inputs`
- `validate_and_prepare_single_dict_task` →
`validate_and_prepare_single_dict_input`
- All `task_` prefixed local variables renamed (e.g., `task_target` →
`target`, `task_context` → `context`, `task_past_tensor` →
`past_tensor`, etc.)


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2026-02-19 13:30:08 +01:00
Oleksandr Shchur
0e9db70afc
Move input preparation outside of Chronos2Dataset (#466)
*Issue #, if available:*

This PR enables fine-tuning on datasets that don't fit into memory. The
main idea is to decouple the preprocessing logic from the
`Chronos2Dataset` class.

The workflow is as follows:
1. Preprocess raw data once using `prepare_tasks()` → save to any
`Sequence[PreparedTask]` container like `datasets.Dataset`
  2. During training, load tasks lazily via memory-mapped Arrow files
3. Pass data to `pipeline.fit(..., convert_inputs=False)` to skip
redundant preprocessing

*Description of changes:*
- Added `PreparedTask` `TypedDict` defining the preprocessed task schema
(context, future_covariates, n_targets, n_covariates,
n_future_covariates as torch.Tensor/int)
- Extracted `prepare_tasks()` as a standalone function so it can be used
in preprocessing scripts
- Added `convert_inputs` parameter to `Chronos2Dataset` and
`Chronos2Pipeline.fit()` to toggle between raw input preprocessing
(default) and pre-processed input passthrough.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2026-02-19 10:10:07 +01:00
Oleksandr Shchur
1f099eb265
Allow explicitly passing the frequency to predict_df (#449)
*Issue #, if available:* #425 

*Description of changes:*
- Add `freq: str | None` parameter to `predict_df` methods. This can
only be set in combination with `validate_inputs=False`. If specified,
the user-provided `freq` will be used instead of the tryin to infer the
`freq` from the data.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2026-01-19 13:59:08 +01:00
Abdul Fatir
f889ae6647
Add new model IDs to README 2026-01-06 14:52:41 +01:00
Oleksandr Shchur
5edd2ad23d
Update notebook on Chronos-2 deployment to SageMaker (#444)
*Issue #, if available:*

*Description of changes:*
- Refactor the notebook to cover real-time inference (CPU & GPU),
serverless inference and batch prediction options for Chronos-2 on
SageMaker
- Update README

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-30 16:18:38 +01:00
Abdul Fatir
822c773424
Add Pandas version field to bug report template 2025-12-18 18:26:13 +01:00
Abdul Fatir
fd533389c3
Bump version from 2.2.1 to 2.2.2 (#439)
*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-12-17 19:12:57 +01:00
Oleksandr Shchur
c50fed93df
Speed up predict_df (#437)
*Issue #, if available:*

*Description of changes:*
- Remove for-loop with numpy operations + single pd.DataFrame
construction


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-17 12:44:43 +00:00
Abdul Fatir
efb86e02c2
Chronos-2: Add after_batch callback (#436)
*Issue #, if available:*

*Description of changes:* Adds support for custom callbacks after each
batch is processed during prediction. This allows for keeping track of
the time limit in AutoGluon.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-17 11:45:16 +01:00
Abdul Fatir
2896499580
Update version to 2.2.1 (#435)
*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-12-16 13:07:19 +01:00
Abdul Fatir
71ff0d64ba
Chronos-2: Add option to disable DataParallel (#434)
*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-12-15 19:27:05 +01:00
Abdul Fatir
eb5b61234a
Chronos-2: Only pin_memory when device type is cuda (#431) 2025-12-10 14:59:13 +01:00
Abdul Fatir
086e660023
Add unittests for df_utils (#414)
*Issue #, if available:*

*Description of changes:* This PR improves test coverage by adding unit
tests for `df_utils`. Previously these methods were only being tested as
part of Chronos-2 integration tests.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-08 15:02:44 +00:00
Abdul Fatir
d608e0dd68
Chronos-2: Update quick start notebook with LoRA example (#415)
*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-12-08 14:52:25 +00:00
Abdul Fatir
75a2dfe228 Update docstring 2025-12-08 14:14:21 +00:00
Abdul Fatir
c74311fbeb
Add validate_inputs to predict_df in BaseChronosPipeline (#427)
*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-12-08 14:11:47 +00:00
Abdul Fatir
fdda16fc02
Bump version from 2.2.0rc4 to 2.2.0 (#426)
*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-12-08 13:49:34 +01:00
Abdul Fatir
5f5da1ac89
Bump version from 2.2.0rc3 to 2.2.0rc4 (#422)
*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-12-04 13:24:48 +01:00
Abdul Fatir
89031842fa
Chronos-2: Handle missing 'peft' and lora_config specified (#421)
*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-12-04 09:43:56 +00:00
Abdul Fatir
564218776a
Chronos-2: Ensure updated chronos_config is saved after fine-tuning (#420)
*Issue #, if available:*

*Description of changes:* Previously, only the returned pipeline had
correct configuration but it was not being saved to disk.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-03 17:32:14 +01:00
Abdul Fatir
f0e1ef5b8f
Chronos-2: Update context_length if fine-tuned with longer than default (#419)
*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-12-03 17:05:02 +01:00
Abdul Fatir
3cb8f8831a
Chronos-2: Rename predict_batches_jointly to cross_learning (#418)
*Issue #, if available:*

*Description of changes:*
- Rename `predict_batches_jointly` to `cross_learning`
- Add deprecation warning
- Add cross_learning to predict_df docstring

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-03 15:15:37 +00:00
Abdul Fatir
7513dee92d
Chronos-2: Do not catch exceptions in predict_fev when fine-tuning (#417)
*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-12-03 15:33:08 +01:00
Abdul Fatir
9afe64332f
Bump version to 2.2.0rc3 (#411)
*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-12-01 19:21:44 +01:00
Abdul Fatir
c1237a5259
Chronos-2: Add option to remove PrinterCallback (#410)
*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-12-01 17:56:37 +01:00
Abdul Fatir
1da6965318
Chronos-2: set default dataloader_num_workers=0 in Trainer (#409)
*Issue #, if available:*

*Description of changes:* 0 is a better default than 1. 


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-01 14:13:50 +00:00
Oleksandr Shchur
4eea8d0122
Handle prediction_length below 3 (#407)
*Issue #, if available:* Fixes #403

*Description of changes:*
- Update the `future_df` validation logic to only check that
`prediction_length` values are provided for each item.
- Update unit tests for DF-based methods in `test_chronos2.py`
- Ignore fine-tuned checkpoint folders with `.gitignore`


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-12-01 13:10:16 +01:00
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