From 4597dd4d88537622a93a0b3646a8c2b82d869d6b Mon Sep 17 00:00:00 2001 From: Jialin Ouyang Date: Tue, 21 Jul 2026 18:47:49 -0700 Subject: [PATCH] Fix reward/classification models broken by `load_weights` v2 dispatch (#28671) (#31988) Co-authored-by: Alex Nails --- python/sglang/srt/models/llama_classification.py | 2 +- python/sglang/srt/models/llama_reward.py | 2 +- python/sglang/srt/models/qwen2_classification.py | 2 +- python/sglang/srt/models/qwen2_rm.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/models/llama_classification.py b/python/sglang/srt/models/llama_classification.py index 6d991789e..438b8b32c 100644 --- a/python/sglang/srt/models/llama_classification.py +++ b/python/sglang/srt/models/llama_classification.py @@ -83,7 +83,7 @@ class LlamaForClassification(nn.Module): elif "lm_head" in name: continue else: - LlamaForCausalLM.load_weights(self, [(name, loaded_weight)]) + LlamaForCausalLM._legacy_load_weights(self, [(name, loaded_weight)]) EntryClass = LlamaForClassification diff --git a/python/sglang/srt/models/llama_reward.py b/python/sglang/srt/models/llama_reward.py index a8e0f04e6..0eb5995f3 100644 --- a/python/sglang/srt/models/llama_reward.py +++ b/python/sglang/srt/models/llama_reward.py @@ -74,7 +74,7 @@ class LlamaForSequenceClassification(nn.Module): ) def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]]): - return LlamaForCausalLM.load_weights(self, weights) + return LlamaForCausalLM._legacy_load_weights(self, weights) class LlamaForSequenceClassificationWithNormal_Weights(LlamaForSequenceClassification): diff --git a/python/sglang/srt/models/qwen2_classification.py b/python/sglang/srt/models/qwen2_classification.py index a16ad64fa..a7f2b4fda 100644 --- a/python/sglang/srt/models/qwen2_classification.py +++ b/python/sglang/srt/models/qwen2_classification.py @@ -71,7 +71,7 @@ class Qwen2ForSequenceClassification(nn.Module): filtered_weights = [ (name, w) for name, w in weights if not name.startswith("lm_head") ] - return Qwen2ForCausalLM.load_weights(self, filtered_weights) + return Qwen2ForCausalLM._legacy_load_weights(self, filtered_weights) EntryClass = [ diff --git a/python/sglang/srt/models/qwen2_rm.py b/python/sglang/srt/models/qwen2_rm.py index aedebd178..fc71d477d 100644 --- a/python/sglang/srt/models/qwen2_rm.py +++ b/python/sglang/srt/models/qwen2_rm.py @@ -84,7 +84,7 @@ class Qwen2ForRewardModel(nn.Module): filtered_weights = [ (name, w) for name, w in weights if not name.startswith("lm_head") ] - return Qwen2ForCausalLM.load_weights(self, filtered_weights) + return Qwen2ForCausalLM._legacy_load_weights(self, filtered_weights) EntryClass = [