Skip to content

Transformers 4.54 and 4.55 and gpt-oss - #52

Merged
IlyasMoutawwakil merged 40 commits into
mainfrom
transformers-4.55
Sep 12, 2025
Merged

IlyasMoutawwakil merged 40 commits into
mainfrom
transformers-4.55

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Sep 8, 2025 •

Copy link
Copy Markdown
Member

fixes #55 and #46

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@IlyasMoutawwakil IlyasMoutawwakil changed the title Transformers 4.54 and 4.55 Transformers 4.54, 4.55 and 4.56 Sep 8, 2025
@IlyasMoutawwakil IlyasMoutawwakil changed the title Transformers 4.54, 4.55 and 4.56 Transformers 4.54 and 4.55 Sep 9, 2025
@IlyasMoutawwakil
IlyasMoutawwakil marked this pull request as ready for review September 9, 2025 11:08
@IlyasMoutawwakil IlyasMoutawwakil changed the title Transformers 4.54 and 4.55 Transformers 4.54 and 4.55 and gpt-oss Sep 10, 2025

@IlyasMoutawwakil IlyasMoutawwakil Sep 11, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just to accelerate and separate testing as I was seeing lots of failures in seq2seq (BaseModelOutput constraint)

Comment thread tests/onnxruntime/test_decoder.py Outdated
Comment on lines +399 to +400
elif is_transformers_version(">=", "4.43.0") and isinstance(outputs.past_key_values, EncoderDecoderCache):
outputs.past_key_values = outputs.past_key_values.self_attention_cache.to_legacy_cache()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

transformers PR in huggingface/transformers#40811

"hiera": "hf-internal-testing/tiny-random-HieraForImageClassification",
"ibert": "hf-internal-testing/tiny-random-IBertModel",
"imagegpt": "hf-internal-testing/tiny-random-ImageGPTModel",
# "imagegpt": "hf-internal-testing/tiny-random-ImageGPTModel", # The mode is broken on transformers :/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

transformers PR in huggingface/transformers#40811

Comment thread optimum/exporters/onnx/model_patcher.py Outdated
Comment on lines +472 to +475
if hasattr(self.orig_forward, "__wrapped__"):
self.orig_forward = types.MethodType(
check_model_inputs_patched(self.orig_forward.__wrapped__), self._model
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we unwrap the faulty decorator and wrap with the fixed one

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

transformers PR in huggingface/transformers#40811

Copilot AI left a comment

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.

Pull Request Overview

This pull request updates optimum-onnxruntime to support Transformers 4.54 and 4.55, along with adding support for gpt-oss models. The changes focus on maintaining compatibility with both newer and older Transformers versions while adding support for the new gpt-oss architecture.

  • Updates to support Transformers versions 4.54 and 4.55
  • Adds support for the new gpt-oss model architecture
  • Updates model testing utilities and configurations to accommodate new Transformers changes

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Updates Transformers version constraint from <4.54.0 to <4.56.0
tests/onnxruntime/testing_utils.py Adds gpt_oss model entry and updates repository references
tests/onnxruntime/test_seq2seq.py Moves seq2seq tests to dedicated file
tests/onnxruntime/test_modeling.py Removes seq2seq tests moved to separate file
tests/onnxruntime/test_decoder.py Adds gpt_oss support and updates cache handling
tests/exporters/onnx/utils_tests.py Adds gpt_oss and updates model references
optimum/onnxruntime/modeling_seq2seq.py Updates Whisper generation mixin and cache handling
optimum/onnxruntime/modeling_ort.py Adds dtype parameter to _from_pretrained
optimum/onnxruntime/modeling_decoder.py Updates cache handling for different model types
optimum/exporters/onnx/utils.py Adds gpt_oss to supported models list
optimum/exporters/onnx/model_patcher.py Updates patching for Transformers 4.54+
optimum/exporters/onnx/model_configs.py Adds GPTOssOnnxConfig and updates GPTBigCode
optimum/exporters/onnx/input_generators.py Adds GPTBigCodeDummyPastKeyValuesGenerator
optimum/exporters/onnx/_traceable_decorator.py New decorator for model inputs patching
.github/workflows/*.yml CI workflow improvements and dependency updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread optimum/onnxruntime/modeling_seq2seq.py Resolved
Comment thread tests/onnxruntime/test_decoder.py Resolved
Comment thread optimum/exporters/onnx/model_patcher.py Resolved
Comment thread optimum/onnxruntime/modeling_decoder.py Resolved

@Abdennacer-Badaoui Abdennacer-Badaoui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@echarlaix echarlaix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome work, thanks a lot @IlyasMoutawwakil !

Comment thread optimum/exporters/onnx/model_patcher.py Resolved
Comment thread optimum/exporters/onnx/model_patcher.py Resolved
Comment thread optimum/exporters/onnx/model_patcher.py Resolved
Comment thread optimum/onnxruntime/modeling_decoder.py Resolved

return wrapped_forward

if any(recordable_keys.values()):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not sure to understand why we need all of this, if you could add some comment to explain that would be awesome 🙏

@IlyasMoutawwakil IlyasMoutawwakil Sep 12, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just patched/fixed the function to accept use_cache as a positional argument and not fail with some models 😭
it's a new transformers decorator that was added around all forward passes to handle a lot of the use_cache, rtutn_tuple, output_attentions, .. arguments in one central place.
it's very hacky and breaks a couple things unfortunately but we can't remove it unfortunately as it now handles a big chunk of the "what should the model output and in what format" logic.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relax transformers>=4.55.0 to be compatible with vllm==0.10.1.1 (GHSA-79j6-g2m3-jgfw, GHSA-rxc4-3w6r-4v47)

5 participants