Skip to content

Add ONNX export optimization support for ModernBERT#2208

Merged
echarlaix merged 2 commits into
huggingface:mainfrom
amas0:main
Jun 11, 2025
Merged

Add ONNX export optimization support for ModernBERT#2208
echarlaix merged 2 commits into
huggingface:mainfrom
amas0:main

Conversation

@amas0
Copy link
Copy Markdown
Contributor

@amas0 amas0 commented Mar 6, 2025

What does this PR do?

Fixes #2177 where ModernBERT support for exporting to ONNX format was added but optimizations not fully enabled.

Minor change that adds modernbert to necessary configuration management objects. In local tests, optimizations provided noticeable speedups with identical results to non-optimized model.

Who can review?

@fxmarty, @echarlaix, @JingyaHuang, @michaelbenayoun

@Benjoyo
Copy link
Copy Markdown

Benjoyo commented Apr 2, 2025

Any news? Would be really helpful!

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

@Kastakin
Copy link
Copy Markdown

Kastakin commented Apr 9, 2025

Are there updates on the matter?

@IlyasMoutawwakil
Copy link
Copy Markdown
Member

can you please add it to testing as well

@IlyasMoutawwakil
Copy link
Copy Markdown
Member

@amas0

@amas0
Copy link
Copy Markdown
Contributor Author

amas0 commented Apr 23, 2025 via email

@amas0
Copy link
Copy Markdown
Contributor Author

amas0 commented Apr 24, 2025

@IlyasMoutawwakil I believe this change should do it?

Please advise if not.

@hotchpotch
Copy link
Copy Markdown

It works well on ModernBERT, thanks @amas0 !

@echarlaix echarlaix added the onnxruntime Related to ONNX Runtime label Jun 4, 2025
@amas0
Copy link
Copy Markdown
Contributor Author

amas0 commented Jun 8, 2025

Still waiting on integration of this bit, @IlyasMoutawwakil - should be good to go?

@IlyasMoutawwakil
Copy link
Copy Markdown
Member

IlyasMoutawwakil commented Jun 9, 2025

Thanks or iterating, can you please fix the code quality, with make style

@amas0
Copy link
Copy Markdown
Contributor Author

amas0 commented Jun 10, 2025

Hmmm. I'm at a bit of a loss here. I see the failing code quality check, but I can't recreate on my local machine.

Trying to recreate locally, I've done:

# In the cloned repo
uv venv -p 3.9.22  # matches the Python version in the check
source .venv/bin/activate
uv pip install -e '.[quality]'
make style

which gives:

$ make style
black .
All done! ✨ 🍰 ✨
213 files left unchanged.
ruff check . --fix

Any ideas? Confirmed the version numbers match up on python and package versions for the formatters.

@echarlaix echarlaix merged commit e7c807b into huggingface:main Jun 11, 2025
35 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

onnxruntime Related to ONNX Runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ONNX export optimization support for ModernBERT

7 participants