Skip to content

Add support for transformers>=5.0#416

Open
kashif wants to merge 24 commits intoamazon-science:mainfrom
kashif:transformers-v5
Open

Add support for transformers>=5.0#416
kashif wants to merge 24 commits intoamazon-science:mainfrom
kashif:transformers-v5

Conversation

@kashif
Copy link
Copy Markdown
Contributor

@kashif kashif commented Dec 2, 2025

Issue #, if available:

Description of changes:

Added some fixes to chronos-bolt for Transformers V5rc

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

@abdulfatir abdulfatir changed the title Transformers v5 Add support for transformers==5.0 Dec 3, 2025
@abdulfatir
Copy link
Copy Markdown
Contributor

Thanks a lot @kashif! Do you think something also needs changing in Chronos and Chronos-2?

Could you also update the bound after the stable version of v5 is available? We can test and get this merged after chronos-forecasting==2.2 release which we are currently working on for autogluon==1.5 release.

@kashif kashif changed the title Add support for transformers==5.0 Add support for transformers>=5.0 Dec 5, 2025
Comment thread src/chronos/chronos2/model.py Outdated
Comment thread src/chronos/chronos_bolt.py Outdated
Copy link
Copy Markdown

@Cyrilvallez Cyrilvallez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, LGTM from the transformers side!

Comment thread src/chronos/chronos_bolt.py Outdated
@abdulfatir abdulfatir added the run-eval Run evaluation CI workflow label Jan 9, 2026
Copy link
Copy Markdown
Contributor

@abdulfatir abdulfatir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, Kashif! It looks like the most critical change is the T5Stack does not expected embed_tokens anymore. The initialization stuff can still be kept the same as before (pure pytorch). What do you think?

factor = self.config.initializer_factor
if isinstance(module, Chronos2LayerNorm):
module.weight.data.fill_(factor * 1.0)
init.constant_(module.weight, factor * 1.0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we need to move the init logic from pure pytorch to transformers? I would prefer keeping this part as is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep pytorch, but it should use the init module! I.e. not do it in-place, as we check a flag on the weight itself before re-initializing or not.
So keeping it as module.weight.data.fill_ will skip the check, and always re-init randomly, even if it was just loaded

@SchulteDev
Copy link
Copy Markdown

I am looking forward to transformers>=5.0 as this would unlock using https://github.com/huggingface/huggingface_hub v1.x

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

Labels

run-eval Run evaluation CI workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants