[Bugfix] Default tie_weights to sharing the weight (fix tied quantized embeddings, e.g. ModelOpt Gemma4) (#45544)

Signed-off-by: Mike G <180722391+mikekg@users.noreply.github.com> Co-authored-by: Michael Goin <mgoin64@gmail.com>

Mike G committed Jun 25, 2026 at 17:46 UTC ad28d605e6db88b7236977517799b5088076f209
1 file changed +10 -3
vllm/model_executor/layers/quantization/base_config.py
+10 -3
@@ -48,11 +48,18 @@ class QuantizeMethodBase(ABC):
48 raise NotImplementedError
49
50 # Not required functions
51 - def tie_weights(self, layer: torch.nn.Module, *args, **kwargs):
52 - """Tie layer's weights for the layer from another layer/tensors.
51 + def tie_weights(self, layer: torch.nn.Module, embed_tokens: torch.nn.Module):
52 + """Tie ``layer``'s weight to ``embed_tokens``' weight.
53 +
54 + The default shares the weight tensor, which is the standard behavior for
55 + tied word embeddings and matches what ``ParallelLMHead.tie_weights`` did
56 + directly before quantization methods became responsible for it.
57 + Quantization methods that need special weight handling (e.g. repacked
58 + weights) override this.
59
60 Expects create_weights to have been called before on the layer."""
55 - raise NotImplementedError
61 + layer.weight = embed_tokens.weight
62 + return layer
63
64 def process_weights_after_loading(self, layer: nn.Module) -> None:
65 """Process the weight after loading.