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
[QUALITY] #4311/#4194 incomplete: Hessian keep-mask reads an all-zero additive [B,1,1,S] layer mask as fully masked - PanGu-alpha GPTQ sees 0 calibration tokens, every module silently RTN (always since #4946 strips padding) #5134
Found on main @ 7b8f127, RTX 4090, with the real pangu_alpha_2_6B checkpoint (all 32 layers, default GPTQConfig(bits=4, group_size=128)).
What is wrong
GPTQ on PanGu-α never sees a calibration token. Every quantized module of every layer falls back to RTN, and nothing fails:
WARN Quantization: Module `attn.q_proj` -> no calibration samples reached this module; forcing `rtn` fallback quantization instead of quantizing a zero Hessian.
... (186 of 186 modules in layers 0-30; layer 31 then crashes, filed separately)
Root cause. The keep-mask for the Hessian is built from the attention mask that the layer itself received (looper/forward_executor.py:435, utils/looper_helpers.py:785), through normalize_seq_mask (utils/attn_mask.py:27-34). PanGu's remote code passes its blocks the old HF extended additive mask (1.0 - mask[:, None, None, :]) * -10000.0 (modeling_gptpangu.py:332-340). For a row with no padding this mask is all zeros. normalize_seq_mask decides between "additive" and "0/1" by looking for a negative value. With none present it uses m > 0, so a fully attended row becomes fully masked:
>>>m=torch.ones(1, 5); ext= (1.0-m[:, None, None, :]) *-10000.0>>>normalize_seq_mask(m).tolist()
[[True, True, True, True, True]]
>>>normalize_seq_mask(ext).tolist() # same row, extended additive form
[[False, False, False, False, False]] # expected all True>>>normalize_seq_mask((1.0-torch.tensor([[1,1,1,0,0.]])[:, None, None, :]) *-10000.0).tolist()
[[True, True, True, False, False]] # correct as soon as one pad exists
utils/calibration.py:876-888 (#4311) already special-cases exactly this "all-zero additive mask means no padding", but only for the user's calibration masks. The layer-input masks used for the Hessian never got the same treatment. #4194 flagged normalize_seq_mask on all-zero additive masks as "possibly related, not reproduced on a stock model". PanGu-α is that stock model.
Why it is now every PanGu run: #4946 (f3433d159, #4889)
Before #4946, a calibration row that carried tokenizer padding produced at least one -10000 entry, so the mask read correctly, and only fully unpadded datasets were hit. #4946 now strips edge padding from every row before batching. The layer mask is therefore always all zeros, and every PanGu calibration is empty.
Measured on the real checkpoint (2-layer truncation, CUDA, 16 rows x 128 tokens), counting no calibration samples warnings:
tests/test_pangu_alpha_replay.py::test_pangu_last_layer_gptq_beats_rtn fails on CPU, CUDA and ROCm:
AssertionError: GPTQ last-layer q_proj error 0.0990 must beat RTN 0.0990; the top-query layer is calibrated on the wrong input
(GPTQ equals RTN to 4 digits because every module is RTN.) Bisected with the HEAD test over 3867c82af..7b8f12785, the first bad commit is f3433d159 (#4946). The test only passed before because its rows carry trailing padding. With an all-ones mask it fails on the parent too.
Suggested fix
In normalize_seq_mask, treat floating-point masks of rank >= 3 (the extended/causal forms) as additive whatever their values, so keep = m >= 0, and keep m > 0 only for 2-D 0/1 masks. Alternatively, apply the calibration.py:876-888 all-zero rule inside normalize_seq_mask itself, so forward_executor, looper_helpers and the AWQ call sites share it. Add a unit node for normalize_seq_mask(torch.zeros(1,1,1,S)) and an unpadded PanGu GPTQ node that asserts a non-zero Hessian sample count.
Severity: high for PanGu-α (silent full-RTN quantization with a "GPTQ" label). It also applies to any remote-code model that hands its blocks a [B,1,1,S] additive mask.
Activity
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-4e3a0639ecaffinished this issue.Pull request: #5155
Fixed: all-zero/rank>=3 additive attention masks are classified as unpadded (keep = m >= 0); PanGu Hessian now sees 128 samples/module.
docs: cite the introducing PR for #5134
fix(calibration): keep all-zero extended attention masks (ModelCloud#…