You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] RTN/weight-only quantize with lm_head=True on a tied-embedding model runs every layer then crashes 'Cannot copy out of meta tensor': WeightOnlyLooper tie guard uses find_tied_parameters, blind on the lazy shell (#4034 fixed only ModuleLooper) #5027
Found on main @ c2b0bf6, RTX 5090, torch 2.15, transformers 5.22.
What is wrong
Quantizing lm_head on a model with tied word embeddings is refused up front with NotImplementedError: quantization of lm_head layer with tied weights is not supported. The weight-only looper (RTN, and every method that goes through WeightOnlyLooper) applies this guard with find_tied_parameters(self.gptq_model.model) (gptqmodel/looper/weight_only_looper.py:1064-1073). With the default offload_to_disk=True, the model is a lazy shell: lm_head.weight and embed_tokens.weight are separate META parameters that are not tied yet, so find_tied_parameters returns nothing and the guard never fires.
The module looper hit the same problem and fixed it in #4034 (ModuleLooper._lm_head_is_tied, module_looper.py:1391+). That fix uses the checkpoint and the declared tie (and, since #4852/#4993, the resolved tie snapshot). The weight-only looper was never switched to it.
The result: RTN with lm_head=True on a tied model (Qwen2.5, Llama-3.2, gemma, ...) runs the whole quantization and then crashes on the head with an unrelated error:
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty() ...
weight_only_looper.py:503 _quantize_named_module -> :439 _prepare_named_module_for_quantization -> looper_helpers.move_module_to_device
rtn offload_to_disk=True : NotImplementedError Cannot copy out of meta tensor; no data! ... (after all layers were quantized)
rtn offload_to_disk=False: NotImplementedError quantization of `lm_head` layer with tied weights is not supported. (0.2 s, up front)
gptq offload_to_disk=True : NotImplementedError quantization of `lm_head` layer with tied weights is not supported. (up front)
Suggested fix
Share one tied-head check between both loopers. Move ModuleLooper._lm_head_is_tied into a helper (for example, next to lm_head_is_tied in utils/tied_weights.py, using the resolved snapshot) and call it from WeightOnlyLooper in place of find_tied_parameters.
Tests that should have caught it
The tied-head refusal test covers the GPTQ looper. Add the same case for RTNConfig(lm_head=True) with the default offload_to_disk=True.
Severity
Low to medium. It is a loud failure, but it comes after the full layer loop (hours on a large model) and its error message points away from the real cause.
Agent claim:agent-root-5027-tied-head is working on this issue now.
Started 2026-11-18T00:11:07Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.
claiming: share the ModuleLooper tied-head check with WeightOnlyLooper so RTN lm_head=True refuses up front instead of crashing after the whole loop
The weight-only looper now shares the tied-head check with ModuleLooper (lm_head_quantization_is_tied in gptqmodel/utils/tied_weights.py, called from weight_only_looper.py), and the issue is closed.
Verified on main @ 0ff0c0ebc with Qwen2.5-0.5B-Instruct (tie_word_embeddings=True), RTNConfig(bits=4, group_size=128, lm_head=True):
offload_to_disk=True : NotImplementedError: quantization of `lm_head` layer with tied weights is not supported. Untie the model weights before quantization.
offload_to_disk=False: NotImplementedError: quantization of `lm_head` layer with tied weights is not supported. Untie the model weights before quantization.
Both refuse up front instead of quantizing every layer and then failing with Cannot copy out of meta tensor. Nothing to add here.
Agent release:agent-root-5011 stood down on this issue.
#5041 (c959f29ca, "share the tied-head check with the module looper") landed on main while I was implementing it and does exactly what this issue asked (one resolved check in utils/tied_weights.py, used by both loopers, with tests/test_weight_only_tied_lm_head_5027.py). Verified at origin/main @ 236f31b07: RTNConfig(lm_head=True) on a tied checkpoint is now refused up front with the tied-head message instead of Cannot copy out of meta tensor. My duplicate change was dropped; no separate PR.
Activity
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-5027is working on this issue now.Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-5011is working on this issue now.Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #5041
weight-only lm_head=True on a tied-embedding model must not run every layer then fail on a meta tensor
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-root-5027-tied-headis working on this issue now.Started 2026-11-18T00:11:07Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.
claiming: share the ModuleLooper tied-head check with WeightOnlyLooper so RTN lm_head=True refuses up front instead of crashing after the whole loop
Qubitium commentedon Nov 18, 2026
Agent claim released — already fixed.
The weight-only looper now shares the tied-head check with
ModuleLooper(lm_head_quantization_is_tiedingptqmodel/utils/tied_weights.py, called fromweight_only_looper.py), and the issue is closed.Verified on
main@0ff0c0ebcwith Qwen2.5-0.5B-Instruct (tie_word_embeddings=True),RTNConfig(bits=4, group_size=128, lm_head=True):Both refuse up front instead of quantizing every layer and then failing with
Cannot copy out of meta tensor. Nothing to add here.Qubitium commentedon Nov 18, 2026
Agent release:
agent-root-5011stood down on this issue.#5041 (
c959f29ca, "share the tied-head check with the module looper") landed onmainwhile I was implementing it and does exactly what this issue asked (one resolved check inutils/tied_weights.py, used by both loopers, withtests/test_weight_only_tied_lm_head_5027.py). Verified atorigin/main@236f31b07:RTNConfig(lm_head=True)on a tied checkpoint is now refused up front with the tied-head message instead ofCannot copy out of meta tensor. My duplicate change was dropped; no separate PR.fix(weight-only): share the tied-head check with the module looper (M…