Repository navigation
fix(config): reject non-finite calibration options at construction (#5307) - #5316
Merged
Merged
Conversation
…5307) MSEConfig.norm accepted NaN/negative and silently disabled the MSE search; FOEMConfig.alpha=NaN crashed later with KeyError: native_inp; GPTAQ alpha and Hessian sink caps accepted NaN or negative values. Validate these fields with a shared finite/range helper, and reject bool for Hessian chunk_size/chunk_bytes.
Qubitium
marked this pull request as ready for review
November 19, 2026 01:09
Qubitium
added a commit
that referenced
this pull request
Nov 19, 2026
…5444) * test(paro): make the prewarm gating test independent of session state (#5430) `test_paro_prewarm_rotation_extension_skips_unsupported_configs` patched `_PARO_ROTATION_EXTENSION.load` and expected one call. The product never reaches that attribute once the extension is loaded: `prewarm_*` calls `_load_rotation_extension()`, which returns True immediately from the module global `_ROTATION_EXTENSION_READY` and otherwise asks `_extension_api().is_available("paro")`. So the test only passed when it was the first thing in the process to touch the extension. Any earlier test that runs a real fused rotation set the flag and the assertion became `assert [] == ['load']`. Patch the seam the product actually calls, `_load_rotation_extension`, which is already how the neighbouring tests in this file spy on the same helper, and add a test that pins the "already loaded" state the old test tripped on: a prewarm there must return True without probing or rebuilding. Verified on main 8618744: pytest tests/test_paro_rotation_inference_cache_5317.py \ tests/test_paro.py::test_paro_prewarm_rotation_extension_skips_unsupported_configs before: 1 failed, 3 passed (assert [] == ['load']) after: 4 passed pytest tests/kernels/test_paro_triton_cudagraph_5225.py <same test> before: 1 failed, 5 passed after: 6 passed pytest tests/test_paro.py: 245 passed * fix(config): reject NaN/inf in every numeric quantize option (#5437) #5316 added `_validate_finite_float` for MSEConfig/FOEMConfig/GPTAQConfig/ HessianConfig only. Every other config still accepted NaN/inf, and NaN compares false against every bound, so the option was silently ignored or silently replaced: MacaqConfig(ridge=nan) -> flip refinement off (applies only if ridge > 0) ParoConfig(opt_rotation_lr=nan) -> +13.8% wikitext-2 PPL, no warning VPTQConfig(npercent=nan) -> outlier codebook silently disabled <any>Config(group_size=nan|inf) -> per-channel fallback / NaN divisor MacaqConfig(bits=nan) -> silently rewritten to 4 Changes: - `_validate_group_size` rejects non-finite and non-integral group_size and normalizes integral floats; called from `BaseQuantizeConfig.__post_init__` and from `EXL3Config`/`MacaqConfig`, which force the value before the base check can see it. - ParoConfig routes its nine float options (LRs, weight decay, eps, betas, SGD momentum/dampening, channel clamp bounds) through `_validate_finite_float`. - MacaqConfig validates `ridge`, and rejects a non-MXFP4 `bits`/`group_size` instead of overwriting it (`-1` stays accepted as the "unset" sentinel). - VPTQConfig validates `npercent` and type-checks `group_num`, `kmeans_iters`, `kmeans_seed`, `block_size`. - GPTQConfig/QQQConfig/VPTQConfig validate the inherited `damp_auto_increment`. A new parametrized sweep walks every numeric field of every QuantizeConfig subclass, so a new field cannot reintroduce the hole. Red -> green (tests/test_config_numeric_validation_5437.py): main @ 8618744: 27 failed, 2 passed this branch: 29 passed No regressions: tests/test_paro.py + tests/test_macaq.py 344 passed, tests/test_vptq.py + tests/test_vptq_outlier_bounds.py 329 passed, config serialization/validation suites 203 passed. ruff clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5307.
The calibration-option dataclasses validated only the type of their numeric
fields.
NaN/inf/negative values constructed, round-tripped throughquantize_config.json, and then either silently disabled the feature or faileddeep inside the first layer:
MSEConfig(norm=nan|-1.0)silently disabled the MSE grid (bit-identical tono MSE).
FOEMConfig(alpha=nan)raisedKeyError: 'native_inp'during quantization.GPTAQConfig(alpha=nan|-5.0)andFOEMConfig(beta=nan)failed later with aNaN-loss error.
HessianConfig(sink_row_cap_median_multiple=nan)was accepted.HessianConfig(chunk_size=True)/chunk_bytes=Truewere accepted as1.NaNcomparisons are always false, so each range check now validates thenormalized float and rejects non-finite values explicitly.
What Changed
gptqmodel/quantization/config.py: new_validate_finite_float(owner, field, value, minimum=...)helper.MSEConfig.norm: finite and>= 0.GPTAQConfig.alpha: finite and>= 0.FOEMConfig.alpha/beta: finite and>= 0.HessianConfig.sink_row_cap_median_multiple: finite and>= 0.HessianConfig.chunk_size/chunk_bytes: rejectboolas well asnon-int values.
tests/test_calibration_option_validation_5307.py: 15 invalid cases(
nan,inf, negative, bool) and 10 legal boundary cases, plus theQuantizeConfig.from_quant_config(...)dict path.Tests
The 15 invalid cases fail on the parent commit; the legal boundary cases pass
both before and after.
Model Support / Module Plan
Not applicable: no model, alias, or module-plan change.
Logic Flow Documentation
Not applicable: construction-time validation only; no runtime flow changes.
Kernel Accuracy Requirements
Not applicable: no kernel or quantization math change.
Notes
MSEConfig(norm=0)remains the documented "disable the search" value.ExpertsRoutingBypass.batch_sizeis unchanged: it intentionally coercesnumeric strings and already rejects zero/negative values.