Read rope_theta from rope_parameters in the Llama injection policy - #8341
Open
alanhuangyoo wants to merge 1 commit into
Open
Read rope_theta from rope_parameters in the Llama injection policy#8341alanhuangyoo wants to merge 1 commit into
alanhuangyoo wants to merge 1 commit into
Conversation
Kernel injection resolves rope_theta as
if hasattr(self.policy.client_module.self_attn, 'config'):
_config.rope_theta = ...self_attn.config.rope_theta
else:
_config.rope_theta = ...self_attn.rope_theta
transformers 5.0 folded the rotary settings into config.rope_parameters
and dropped the attribute, so against a stock LlamaConfig both branches
raise. The first is taken -- LlamaAttention still has .config -- and
injection dies with
AttributeError: 'LlamaConfig' object has no attribute 'rope_theta'
On transformers 5.8.0 that reproduces with a default LlamaConfig, so it
is not specific to the DeepSeek checkpoint in deepspeedai#8340.
Fall back to rope_parameters['rope_theta'] when the attribute is gone,
keeping the old spellings first so pre-5.0 installs are unaffected. This
is the same drift deepspeedai#7443 adapted to; the num_heads accessor it fixed
alongside still resolves, so only this one moved.
Fixes deepspeedai#8340
Signed-off-by: alanhuangyoo <alanhuangyoo@gmail.com>
alanhuangyoo
requested review from
hwchen2017,
loadams,
tjruwase and
tohtana
as code owners
August 28, 2026 09:55
This was referenced Aug 28, 2026
Contributor
Author
|
Opened #8345 for the It turned out to be eight models, and one of them fails quietly rather than loudly: |
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.
Fixes #8340.
What breaks
DS_LLAMAContainer.create_moduleresolvesrope_thetaas:transformers 5.0 folded the rotary settings into
config.rope_parametersand dropped the attribute.LlamaAttentionstill has.config, so the first branch is taken and it raises.This is not specific to the DeepSeek checkpoint in the issue — on transformers >= 5.0 it reproduces with a default
LlamaConfig. Checked on 5.8.0:and against a real module, both branches are dead:
The fix
Try the old spellings first, then
rope_parameters['rope_theta'], so pre-5.0 installs take exactly the path they take today and nothing changes for them.This is the same drift #7443 adapted to. The
num_headsaccessor it fixed alongside still resolves on 5.8 (config.num_attention_headsis intact), sorope_thetais the only one that moved again.requirements-dev.txtasks fortransformers>=4.51.3with no upper bound, so 5.x is in range.Verified that
rope_thetais the only accessor that moved: against a realLlamaDecoderLayeron 5.8.0,get_hidden_heads(),attention(),mlp()andlayernorm()all resolve once this one is fixed.I exercised the policy and container layer, not a full
init_inference()run against a downloaded checkpoint on GPU.Test
tests/unit/module_inject/test_llama_rope_theta.pycovers the three layouts plus the precedence between them and the not-found case — CPU only, no model download:End to end against a real
LlamaAttentionon 5.8.0:I did not touch
inference/v2. Six of its model implementations readself._config.rope_thetadirectly andexaone4is the only one using agetattrdefault, so they likely have the same exposure — but that is a different engine and a different change, and I have not reproduced it.