Skip to content

handle missing TF2_WEIGHTS_NAME for newer transformers versions#2384

Merged
IlyasMoutawwakil merged 2 commits into
huggingface:mainfrom
niyarrbarman:fix-tf2-weights-name-import
Nov 14, 2025
Merged

handle missing TF2_WEIGHTS_NAME for newer transformers versions#2384
IlyasMoutawwakil merged 2 commits into
huggingface:mainfrom
niyarrbarman:fix-tf2-weights-name-import

Conversation

@niyarrbarman
Copy link
Copy Markdown
Contributor

What does this PR do?

handles the absence of TF2_WEIGHTS_NAME constant in recent transformers versions while still remaining backward-compatible with older versions.

Fixes #2372

Who can review?

@echarlaix, @JingyaHuang, @michaelbenayoun, @IlyasMoutawwakil

Comment thread optimum/exporters/tasks.py Outdated
Comment on lines +33 to +37
# TF2_WEIGHTS_NAME is not available in recent transformers versions
try:
from transformers.utils import TF2_WEIGHTS_NAME
except Exception:
TF2_WEIGHTS_NAME = None
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.

let's simply remove it. optimum-onnx (which is based on optimum v2) does not support exporting tf models.

Copy link
Copy Markdown
Member

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Choose a reason for hiding this comment

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

Thanks ! let's simply remove the tf weights support

@niyarrbarman
Copy link
Copy Markdown
Contributor Author

@IlyasMoutawwakil I made the changes, could you please review once if everything's alright

@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.

@niyarrbarman
Copy link
Copy Markdown
Contributor Author

Hi @IlyasMoutawwakil , if there's some issue with the removal please let me know. Thanks

@IlyasMoutawwakil IlyasMoutawwakil merged commit b7f00d5 into huggingface:main Nov 14, 2025
15 checks passed
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.

Optimum incompatible with recent Transformers versions

3 participants