fix(qwen3): support rope_parameters config - #1898
Merged
Merged
Conversation
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.
Summary
Qwen3 checkpoints produced by
transformers 5.xreleases (e.g.dinghar/qwen3-0.6b-pangram-sft) fail to load inmlx_lm.models.qwen3becauseModelArgscannot loadrope_thetacorrectly.The checkpoint's
config.jsonprovides:with no top-level
rope_thetafield. ButModelArgs.rope_thetais a required field with no default, so loading fails with:In addition,
rope_parametersmay contain RoPE configuration such asrope_type,factor, andoriginal_max_position_embeddings.ModelArgscurrently ignoresrope_parameters, so this configuration can be lost without raising an error becauserope_scalingis optional.Fix
ModelArgs:rope_thetafrom a required field to an optional one soModelArgscan get it fromrope_parametersrope_parameters: Optional[dict].rope_thetafromrope_parameterswhen the top-level value is absent, and userope_parametersas the fallback RoPE scaling configuration whenrope_scalingis absent.Changes are backward compatible: the existing
test_qwen3(flatrope_theta, norope_parameters) still passes unchanged.Testing
test_qwen3_rope_parameters:ValueErrorwhenrope_thetais absent from bothTypeErrorabove against unpatchedmain, and passes after the fix.dinghar/qwen3-0.6b-pangram-sftnow loads correctly.tests/test_models.pysuite passes locally.uvx pre-commit run --allFixes #1563