A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 2, 20:45 UTC
[Bugfix][Model] Fix GPT2ForSequenceClassification sub-module prefix (#43579)
Signed-off-by: QingZhou-YangHY <3868850350@qq.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Huanyu Yang committed
May 26, 2026 at 13:43 UTC
6f955986e12168fa0e00e0d864c14330b4c72691
1 file changed
+7
-2
vllm/model_executor/models/gpt2.py
+7
-2
@@ -339,7 +339,7 @@ class GPT2ForSequenceClassification(nn.Module, SupportsCrossEncoding):
339
super().__init__()
340
config = vllm_config.model_config.hf_config
341
self.transformer = GPT2Model(
342
- vllm_config=vllm_config, prefix=maybe_prefix(prefix, "gpt2")
342
+ vllm_config=vllm_config, prefix=maybe_prefix(prefix, "transformer")
343
)
344
self.score = nn.Linear(
345
config.n_embd,
@@ -358,6 +358,7 @@ class GPT2ForSequenceClassification(nn.Module, SupportsCrossEncoding):
358
359
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
360
loader = AutoWeightsLoader(self)
361
+ weights = _add_transformer_prefix(weights)
362
return loader.load_weights(weights)
363
364
def forward(
@@ -380,6 +381,10 @@ def _add_transformer_prefix(
381
weights: Iterable[tuple[str, torch.Tensor]],
382
) -> Iterable[tuple[str, torch.Tensor]]:
383
for name, tensor in weights:
383
- if not name.startswith("transformer.") and not name.startswith("lm_head"):
384
+ if (
385
+ not name.startswith("transformer.")
386
+ and not name.startswith("lm_head.")
387
+ and not name.startswith("score.")
388
+ ):
389
name = "transformer." + name
390
yield name, tensor