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] MSEConfig/FOEMConfig/GPTAQConfig/HessianConfig accept NaN and negative values (#4953 class): MSEConfig(norm=nan|-1) silently disables MSE, FOEMConfig(alpha=nan) crashes KeyError 'native_inp', GPTAQ alpha<0 fails late with NaN loss #5307
Found on main @ c03416c, CPU (Qwen2.5-0.5B-Instruct, 2 decoder layers).
What is wrong
The calibration-option dataclasses check only the type of their numeric fields, never range or finiteness. NaN and negative values pass construction, GPTQConfig.__post_init__, from_quant_config and save_pretrained. They then either silently turn the feature off or fail deep inside the first layer with an unrelated error. #4953/#4970 and #5005/#5017 fixed this for smoother parameters ("validate at construction instead of silently destroying the model"). These siblings were not covered:
field (file:line)
check today
NaN / negative accepted
effect at quantize()
MSEConfig.norm (config.py:2155)
is a number
yes / yes
norm=nan and norm=-1.0 silently disable the MSE grid. Output is bit-identical to no MSE (nll 16.1933 == base), while norm=2.4 gives 16.2463. Docs: "0 disables".
FOEMConfig.alpha
is a number
yes / yes
alpha=nan: KeyError: 'native_inp' at quantization/foem.py:143 in the first module. nan > 0 is False when the processor plan decides whether to capture native inputs, but FOEM itself treats it as enabled.
FOEMConfig.beta
is a number
yes / yes
beta=nan: ValueError: Quantization: Failed due to NaN loss for self_attn.q_proj after calibration capture.
GPTAQConfig.alpha (config.py:2479)
is a number
yes / yes
alpha=nan or alpha=-5.0: Failed due to NaN loss for q_proj/o_proj after calibration.
HessianConfig.sink_row_cap_median_multiple
none
yes / –
nan is accepted. With desc_act=True the run completes with a different result (nll 16.2355 vs 16.1933).
HessianConfig.chunk_size / chunk_bytes
int
True accepted as 1
ExpertsRoutingBypass.batch_size
–
"4" (str) is coerced
Repro
importtorchfromgptqmodelimportGPTQModelfromgptqmodel.quantizationimportconfigasCfromgptqmodel.quantization.configimportCalibrationConfignan=float("nan")
# all of these construct without error, round-trip through save_pretrained/from_quant_config:C.GPTQConfig(bits=4, mse=C.MSEConfig(norm=nan))
C.GPTQConfig(bits=4, mse=C.MSEConfig(norm=-1.0))
C.GPTQConfig(bits=4, foem=C.FOEMConfig(alpha=nan))
C.GPTQConfig(bits=4, gptaq=C.GPTAQConfig(alpha=-5.0))
C.QuantizeConfig.from_quant_config({"quant_method": "gptq", "bits": 4, "group_size": 128, "foem": {"alpha": nan}})
forcfgin [...]:
m=GPTQModel.load("Qwen2.5-0.5B-Instruct (2 layers)", cfg, dtype=torch.bfloat16)
m.quantize(CalibrationConfig(dataset=c4_16_rows, batch_size=4)) # then wikitext nll on 256 tokens
Output (group_size=128):
base nll 16.1933
mse=MSEConfig(norm=2.4) nll 16.2463 <- MSE active
mse=MSEConfig(norm=nan) nll 16.1933 <- silently off
mse=MSEConfig(norm=-1.0) nll 16.1933 <- silently off
gptaq alpha=nan ValueError: Quantization: Failed due to `NaN` loss for `self_attn.q_proj`
gptaq alpha=-5.0 ValueError: Quantization: Failed due to `NaN` loss for `self_attn.o_proj`
foem alpha=0.25, beta=nan ValueError: Quantization: Failed due to `NaN` loss for `self_attn.q_proj`
foem alpha=nan, beta=0.2 KeyError: 'native_inp' (gptq_processor.py:386 -> foem.py:143)
hessian sink cap = nan nll 16.2355 (desc_act=True; accepted)
Suggested fix
In each __post_init__, require math.isfinite(), and enforce the documented ranges: MSEConfig.norm >= 0; GPTAQ/FOEM alpha >= 0 and beta >= 0 (or whatever range the papers allow); sink_row_cap_median_multiple > 0. Reject bool for int fields. The dynamic and from_quant_config paths already reuse these constructors, so they would be covered too. Use the same _validated_float helper that #4970 added for smoothers.
Test that should have caught it
tests/test_smoother_parameter_validation_4953.py covers smoothers only. Add a parametrized test over MSEConfig, FOEMConfig, GPTAQConfig and HessianConfig that feeds nan, inf and a negative value and expects ValueError at construction.
Severity
Low. Each case needs an invalid value. The MSEConfig case quietly produces a checkpoint without the requested MSE search (and records norm: nan in it). The FOEM case crashes with a KeyError that does not point at the config.
claiming: reject non-finite and out-of-range MSE/FOEM/GPTAQ/Hessian numeric options at construction instead of silently disabling the feature or failing late
Implemented in draft PR #5316. Added _validate_finite_float and applied it to MSEConfig.norm, GPTAQConfig.alpha, FOEMConfig.alpha/beta, and HessianConfig.sink_row_cap_median_multiple; chunk_size/chunk_bytes now reject bool. The 15 invalid construction cases fail on the parent commit.
Activity
Qubitium commentedon Nov 19, 2026
Agent claim released:
agent-root-5307-config-rangesfinished this issue.Pull request: #5316
claiming: reject non-finite and out-of-range MSE/FOEM/GPTAQ/Hessian numeric options at construction instead of silently disabling the feature or failing late
Qubitium commentedon Nov 19, 2026
Implemented in draft PR #5316. Added
_validate_finite_floatand applied it toMSEConfig.norm,GPTAQConfig.alpha,FOEMConfig.alpha/beta, andHessianConfig.sink_row_cap_median_multiple;chunk_size/chunk_bytesnow rejectbool. The 15 invalid construction cases fail on the parent commit.fix(config): reject non-finite calibration options at construction (#…