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] Calibration input normalisation gaps: [B,T,T] masks collapse to one token; min-length checks only row 0 and counts padding; validation gaps #4194
1. A [B, T, T] causal attention_mask keeps only token 0
_pack_ids (utils/calibration.py:246-268) routes masks through _normalize_attention_mask and then normalize_seq_mask.
In utils/attn_mask.py:53-56, the fallback reshape(B, -1)[..., :seq_len] takes the first row of the T×T matrix.
The rank>2 handler meant for this case (calibration.py:233-239, "Some tokenizers emit causal masks shaped like [B, 1, T, T] or [B, T, T]") is dead code: _to_2d_long_tensor is never called with name="attention_mask".
Possibly related (likely, not reproduced on a stock model): normalize_seq_mask(torch.zeros(1,1,5,5)) returns all-False, the same additive-mask flaw as #4187. That helper also builds the GPTQ Hessian keep-mask (forward_executor.py:~372, looper_helpers.py:~710).
2. calibration_data_min_length checks only row 0, by padded width
utils/calibration.py:498: if len(input_ids[0]) <= calibration_data_min_length.
Multi-row items, e.g. tokenizer(texts, padding=True) rows, are judged by the padded width of the first row. Rows with 3 real tokens, or fully padded rows, pass the filter.
out=prepare_calibration_dataset(qm, [{"input_ids": torch.tensor([[7,7,7]+[0]*30]), "attention_mask": torch.tensor([[1,1,1]+[0]*30])}], calibration_data_min_length=10)
print(len(out), int(out[0]["attention_mask"].sum())) # 1 3 -> kept with 3 real tokens
Expected: filter per row on attention_mask.sum().
3. Validation gaps
An unknown calibration_sort (e.g. "descending") silently falls back to native order (:619-638). Valid values are asc, desc and shuffle.
These raise "must contain only integers" (:384-390), while the equivalent numpy array or tensor is accepted:
a list of np.int64 (list(np_array));
a list of torch scalars;
a nested [[ids]] sample.
A torch.empty(0, N) sample raises a bare IndexError: list index out of range (:498).
calibration_sort="shuffle" uses the unseeded global random.shuffle (:635) and there is no seed argument.
Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(calibration): normalize causal masks and validate rows per token (M…