From ad28d605e6db88b7236977517799b5088076f209 Mon Sep 17 00:00:00 2001 From: Mike G Date: Thu, 25 Jun 2026 17:46:28 -0700 Subject: [PATCH] [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 --- .../layers/quantization/base_config.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vllm/model_executor/layers/quantization/base_config.py b/vllm/model_executor/layers/quantization/base_config.py index 7bc5d16be7..9b18bdc132 100644 --- a/vllm/model_executor/layers/quantization/base_config.py +++ b/vllm/model_executor/layers/quantization/base_config.py @@ -48,11 +48,18 @@ class QuantizeMethodBase(ABC): raise NotImplementedError # Not required functions - def tie_weights(self, layer: torch.nn.Module, *args, **kwargs): - """Tie layer's weights for the layer from another layer/tensors. + def tie_weights(self, layer: torch.nn.Module, embed_tokens: torch.nn.Module): + """Tie ``layer``'s weight to ``embed_tokens``' weight. + + The default shares the weight tensor, which is the standard behavior for + tied word embeddings and matches what ``ParallelLMHead.tie_weights`` did + directly before quantization methods became responsible for it. + Quantization methods that need special weight handling (e.g. repacked + weights) override this. Expects create_weights to have been called before on the layer.""" - raise NotImplementedError + layer.weight = embed_tokens.weight + return layer def process_weights_after_loading(self, layer: nn.Module) -> None: """Process the weight after loading.