Repository navigation
Fix reward/classification models broken by load_weights v2 dispatch (#28671) - #31988
Merged
alexnails merged 2 commits intoJul 22, 2026
Merged
Conversation
…gl-project#28671) sgl-project#28671 refactored LlamaForCausalLM/Qwen2ForCausalLM.load_weights to dispatch to self._legacy_load_weights / self._load_weights_v2. The reward and classification wrappers (llama_reward, llama_classification, qwen2_rm, qwen2_classification) borrow the base loader via an unbound call `Base.load_weights(self, ...)` but inherit only nn.Module, so `self` has no `_legacy_load_weights` and weight load fails with AttributeError (default path, since v2 is opt-in). Call `_legacy_load_weights` directly, restoring the pre-sgl-project#28671 behavior. These wrapped models are not AutoWeightLoader v2 citizens, so legacy is the correct path.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Jialin
force-pushed
the
jialino/fix-native-reward-load-weights
branch
from
July 22, 2026 01:14
f24938e to
656c93b
Compare
Collaborator
|
/rerun-test test/registered/prefill_only/test_reward_models.py |
Contributor
|
Results for 🚀 |
b8zhong
approved these changes
Jul 22, 2026
alexnails
approved these changes
Jul 22, 2026
Closed
Merged
3 of 5 tasks
2 tasks done
This was referenced Jul 22, 2026
This was referenced Jul 26, 2026
Zhylkaaa
pushed a commit
to Zhylkaaa/sglang
that referenced
this pull request
Jul 29, 2026
…sgl-project#28671) (sgl-project#31988) Co-authored-by: Alex Nails <alex.nails@radixark.ai>
Atituiset
pushed a commit
to Atituiset/sglang
that referenced
this pull request
Sep 10, 2026
…sgl-project#28671) (sgl-project#31988) Co-authored-by: Alex Nails <alex.nails@radixark.ai>
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.
Motivation
#28671 refactored
LlamaForCausalLM/Qwen2ForCausalLM.load_weightsto dispatch toself._legacy_load_weights/self._load_weights_v2. The reward and classification wrappers (llama_reward,llama_classification,qwen2_rm,qwen2_classification) borrow the base loader via an unbound callBase.load_weights(self, ...)but inherit onlynn.Module, soselfhas no_legacy_load_weightsand weight load fails withAttributeError(default path, since v2 is opt-in). This breaks loading of every reward/classification model built on Llama or Qwen2 — e.g.LxzGordon/URM-LLaMa-3.1-8Bcrashes at startup with'LlamaForSequenceClassificationWithNormal_Weights' object has no attribute '_legacy_load_weights'.Call
_legacy_load_weightsdirectly, restoring the pre-#28671 behavior. These wrapped models are not AutoWeightLoader v2 citizens, so legacy is the correct path.Modifications
Base.load_weights(self, ...)toBase._legacy_load_weights(self, ...)in the four affected wrappers:llama_reward.py,llama_classification.py,qwen2_rm.py,qwen2_classification.py.load_weights).load_weightsis still self-contained and works.Accuracy Tests
No output change — this restores the exact weight-loading path that ran before #28671 (the refactor renamed that body to
_legacy_load_weightsverbatim). The path is exercised by the existing reward/classification loading tests (test/registered/prefill_only/test_reward_models.py,test_score_engine.py,test_pooled_hidden_states.py), which fail on current trunk and pass with this change.blackandpy_compileverified locally.Speed Tests and Profiling
N/A — weight-loading path only; no inference-speed impact.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⏳ Run #29884063179
Latest PR Test (Extra): ⏳ Run #29884063091