Skip to content

[BUG] ChronosBoltPipeline fails with transformers>=4.41 due to DynamicCache changes #310

@PouyaGhahramanian

Description

@PouyaGhahramanian

Bug report

Bug report checklist

  • I provided code that demonstrates a minimal reproducible example.
  • I confirmed bug exists on the latest mainline of Chronos via source install.

Describe the bug
When using ChronosBoltPipeline with the latest transformers library (>=4.41), the following error occurs due to changes in Hugging Face's caching mechanism:

AttributeError: 'DynamicCache' object has no attribute 'is_updated'

Expected behavior
ChronosBoltPipeline.predict() should work correctly with the latest versions of Hugging Face transformers without requiring manual patches or downgrades.

To reproduce

from chronos import ChronosBoltPipeline

pipeline = ChronosBoltPipeline.from_pretrained("amazon/chronos-bolt-base")
context = [...]  # your input data
prediction_length = 10
forecast = pipeline.predict(context, prediction_length=prediction_length)

This results in:

AttributeError: 'DynamicCache' object has no attribute 'is_updated'

Environment description
Operating system: Ubuntu 20.04 LTS
Python version: 3.11
CUDA version: 12.1
PyTorch version: 2.5.1
HuggingFace transformers version: 4.43.2
HuggingFace accelerate version: 1.9.0


Cause
Starting from transformers>=4.41, Hugging Face introduced a new caching mechanism (DynamicCache) for models like T5, which no longer has the is_updated attribute. ChronosBolt still assumes the old cache implementation.

Temporary Workarounds

  1. Downgrade transformers to 4.40.2:
    pip install transformers==4.40.2
  2. Patch modeling_t5.py:
    Replace:
    past_key_value.is_updated[self.layer_idx] = True
    with:
    if hasattr(past_key_value, "is_updated"):
        past_key_value.is_updated[self.layer_idx] = True

Suggested Fix

  • Pin transformers<=4.40.2 in chronos-forecasting dependencies until a proper fix is implemented, or
  • Update ChronosBolt's T5 wrapper to support DynamicCache by adding compatibility checks as shown above.

Additional Note
I am willing to work on a fix for this issue and can submit a PR to make ChronosBoltPipeline compatible with the new DynamicCache system in transformers>=4.41.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions