Repository navigation
fix(config): reject NaN/inf in every numeric quantize option (#5437) - #5444
Merged
Merged
Conversation
…#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
#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.
Qubitium
marked this pull request as ready for review
November 19, 2026 05:49
This was referenced Nov 19, 2026
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
#5316(the fix for#5307) added_validate_finite_floattoMSEConfig,FOEMConfig,GPTAQConfigandHessianConfigonly. Every other config still acceptedNaN/inf, andNaNcompares false against every bound, so the option was silently ignored or silently replaced:MacaqConfig(ridge=nan)if ridge > 0ParoConfig(opt_rotation_lr=nan)VPTQConfig(npercent=nan)npercent > 0is false for NaNRTNConfig/AWQConfig/QQQConfig/ParoConfig/VPTQConfig(group_size=nan)group_size <= 0is false for NaNChanges
_validate_group_size— rejects non-finite and non-integralgroup_size, normalizes integral floats (128.0→128), and keeps the existing supported-set message for out-of-range integers. Called fromBaseQuantizeConfig.__post_init__(covers every config that does not force the value) and fromEXL3Config/MacaqConfig, which overwritegroup_sizebefore the base check can see the caller's value.ParoConfig— the nine float options (opt_rotation_lr,opt_weight_lr,opt_quantizer_lr,opt_pair_ratio,opt_weight_decay,opt_eps,opt_betas,opt_sgd_momentum,opt_sgd_dampening,opt_channel_scale_clamp_min/max) go through_validate_finite_float.MacaqConfig— validatesridge, and rejects a non-MXFP4bits/group_sizeinstead of overwriting it.-1stays accepted as the shared "unset" sentinel so older configs keep loading.VPTQConfig— validatesnpercentand type-checksgroup_num,kmeans_iters,kmeans_seed,block_size(NaNused to satisfy every one of their bounds).GPTQConfig/QQQConfig/VPTQConfig— the inheriteddamp_auto_incrementis validated too.Test: a sweep, not a list
tests/test_config_numeric_validation_5437.pywalks every numeric field of everyQuantizeConfigsubclass and assertsnan/inf/-infare rejected, so a new field cannot reintroduce the hole:Before this PR that sweep reports 13 configs accepting NaN, including
group_sizeon all of them. After it, 0.Red -> green
No regressions on the affected suites (CPU, GPU for the Paro/MACaQ paths):
tests/test_paro.py+tests/test_macaq.pytests/test_vptq.py+tests/test_vptq_outlier_bounds.pytest_config_serialization_roundtrip_4201+test_config_per_module_validation_4200+test_calibration_config+test_calibration_option_validation_5307test_macaq_rotation_serialization_4225+test_checkpoint_resume_nf12_macaq_4792+ serialization + 5307uvx [email protected] check gptqmodel docs/eora tests setup.py: clean.Compatibility notes
None/stringgroup_sizealready raised onmain(None <= 0/str <= 0is aTypeError), so nothing that loaded before stops loading.OverflowErrorfromint(inf); the sweep accepts that as a loud rejection. Only the silent-accept path is closed.Fixes #5437