Skip to content

[Draft] Add Eurobert configuration for ONNX export #2321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DWarez
Copy link

@DWarez DWarez commented Jul 15, 2025

What does this PR do?

Adding configuration for Eurobert ONNX export support

Fixes # (2300)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

@fxmarty, @echarlaix, @JingyaHuang, @michaelbenayoun

@DWarez
Copy link
Author

DWarez commented Jul 15, 2025

I created a configuration to support Eurobert, but I'm still unsure about its correctness. When exporting the model, I'm getting some trace warnings:

/python3.11/site-packages/transformers/modeling_attn_mask_utils.py:122: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if (input_shape[-1] > 1 or self.sliding_window is not None) and self.is_causal:
python3.11/site-packages/transformers/modeling_attn_mask_utils.py:196: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  inverted_mask = torch.tensor(1.0, dtype=dtype) - expanded_mask

As you can see they come from some modelling methods in the transformers library (which are invoked by the modelling eurobert scripts).

I investigated a bit and to me it's quite clear why the warnings are getting triggered, but I'm unsure about their impacts on the usability and correctness of the exported model.

Any suggestion about how to test this would be appreciated, thanks.

@IlyasMoutawwakil
Copy link
Member

Hi ! thanks for the contribution, please move it to optimum-onnx as we are moving the entire onnx/ort integrations there.

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.

2 participants