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] auto_nf12: a fully excluded non-final layer is saved as NF12 buffers under nn.Linear names -> reload yields NaN logits #4007
Audit of main @ 105602e. Silent checkpoint corruption with the default auto_dtype_cast="auto_nf12".
A fully excluded non-final layer is saved as NF12 buffers under nn.Linear names, and the reload gives NaN logits (high)
If a dynamic -: rule excludes every module of a layer that is not the last one, the layer still runs one forward so the next layer gets its inputs. This is the replay_skipped_layer branch in gptqmodel/looper/stage_layer.py:1060-1100 → looper._prepare_named_module_for_forward → models/base.py:4726 → _maybe_auto_dtype_cast_forward_module (base.py:3529).
During that forward, the layer's nn.Linear modules are swapped for AutoNF12HookedLinear and never swapped back: the dense restore only happens on the role == "quant_source" path (base.py ~4626-4680), which an excluded layer never takes.
As a result:
save() writes *.nf12_packed / *.nf12_escapes / *.nf12_exp_baseinstead of*.weight, while quantize_config.json describes the layer as plain unquantized.
On load, HF reports the NF12 keys as "not used" (a warning only) and the nn.Linear weights stay uninitialised.
Repro (tiny bf16 Llama, 4 layers, CUDA sm ≥ 80, dynamic={"-:.*layers\.1\..*": {}}):
saved layer1 keys: ['model.layers.1.mlp.up_proj.nf12_escapes', 'model.layers.1.mlp.up_proj.nf12_exp_base', 'model.layers.1.mlp.up_proj.nf12_packed']
reloaded logits rel-err vs fp: auto_dtype_cast="off": 0.18 default: nan
Scope:
Reproduced with GPTQ and AWQ (gemm). offload_to_disk=False doesn't help.
It happens for layers 0, 1, 2 and 1+2.
Not triggered by: excluding the last layer, a single module (-:.*mlp\.down_proj), one sub-block (-:.*layers\.1\.self_attn\..*), or auto_dtype_cast="off".
Triggers with any bf16 source (or fp16 that converts to bf16 exactly).
Fix:
Don't NF12-pack sources in the replay_skipped_layer forward: set state["auto_dtype_cast_forward_disabled"], or call restore_source_module after the replay.
Make save() refuse NF12 buffers under a module that is not quantized.
The dynamic skip-layer tests (tests/test_dynamic.py, test_checkpoint_quantization.py::test_dynamic_*) run on CPU, where NF12 is not eligible. A GPU bf16 whole-layer -: test that saves, reloads and checks logits is missing.
Activity
fix(nf12): keep excluded-layer replay dense and fail closed on leaked…
docs(nf12): report the measured before-fix rel-err and link PR #4012 (#…
test(nf12): widen the unaffected-exclusion logit bound for ROCm (#4007)…