[Fix] Add setter for config property to fix optimum ONNX export#3831
Open
lcheng321 wants to merge 1 commit into
Open
[Fix] Add setter for config property to fix optimum ONNX export#3831lcheng321 wants to merge 1 commit into
lcheng321 wants to merge 1 commit into
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
SentenceTransformer.configwas added in v5.5.0 as a read-only property.optimum'sstandardize_model_attributesassignsmodel.config = model[0].auto_model.configduring ONNX export, which raisesAttributeError. Works fine withsentence-transformers==5.4.1.Error:
Root Cause
sentence_transformers/base/model.pydefinesconfigwith only a@propertygetter and no setter. Whenoptimumattempts to assignmodel.configduring export, Python raisesAttributeError.Fix
Add a
@config.setterat line 1588 ofsentence_transformers/base/model.pythat delegates to the underlying transformer model, consistent with the existingtokenizerandmax_seq_lengthsetters.Verification
Verified without internet or GPU (pure Python, no hardware required).
Test 1 — Static AST check (before vs after):
Output:
Test 2 — Behavioral simulation (optimum assignment):
Output:
Screenshots attached in comments.
Fixes #3830