Skip to content

fix(config): reject NaN/inf in every numeric quantize option (#5437) - #5444

Merged
Qubitium merged 2 commits into
mainfrom
fix/5437-config-finite-numbers
Nov 19, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/5437-config-finite-numbers

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

#5316 (the fix for #5307) added _validate_finite_float to MSEConfig, FOEMConfig, GPTAQConfig and 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:

input today why
MacaqConfig(ridge=nan) flip refinement silently off ridge is applied only if ridge > 0
ParoConfig(opt_rotation_lr=nan) +13.8% wikitext-2 PPL, no warning LR comparisons are false for NaN
VPTQConfig(npercent=nan) outlier codebook silently disabled npercent > 0 is false for NaN
RTNConfig/AWQConfig/QQQConfig/ParoConfig/VPTQConfig(group_size=nan) per-channel fallback or a NaN divisor group_size <= 0 is false for NaN
`MacaqConfig(bits=nan inf -1)`

Changes

  • _validate_group_size — rejects non-finite and non-integral group_size, normalizes integral floats (128.0 → 128), and keeps the existing supported-set message for out-of-range integers. Called from BaseQuantizeConfig.__post_init__ (covers every config that does not force the value) and from EXL3Config/MacaqConfig, which overwrite group_size before 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 — validates ridge, and rejects a non-MXFP4 bits/group_size instead of overwriting it. -1 stays accepted as the shared "unset" sentinel so older configs keep loading.
  • VPTQConfig — validates npercent and type-checks group_num, kmeans_iters, kmeans_seed, block_size (NaN used to satisfy every one of their bounds).
  • GPTQConfig/QQQConfig/VPTQConfig — the inherited damp_auto_increment is validated too.

Test: a sweep, not a list

tests/test_config_numeric_validation_5437.py walks every numeric field of every QuantizeConfig subclass and asserts nan/inf/-inf are rejected, so a new field cannot reintroduce the hole:

@pytest.mark.parametrize("config_cls", _config_classes())
def test_every_numeric_option_rejects_non_finite_values(config_cls):
    for name in _numeric_fields(config_cls):
        for bad in NON_FINITE:
            with pytest.raises(REJECTED):
                config_cls(offload_to_disk=False, **{name: bad})

Before this PR that sweep reports 13 configs accepting NaN, including group_size on all of them. After it, 0.

Red -> green

pytest tests/test_config_numeric_validation_5437.py
main @ 8618744ac: 27 failed, 2 passed
this branch:      29 passed

No regressions on the affected suites (CPU, GPU for the Paro/MACaQ paths):

suite result
tests/test_paro.py + tests/test_macaq.py 344 passed, 1 skipped
tests/test_vptq.py + tests/test_vptq_outlier_bounds.py 329 passed
test_config_serialization_roundtrip_4201 + test_config_per_module_validation_4200 + test_calibration_config + test_calibration_option_validation_5307 143 passed
test_macaq_rotation_serialization_4225 + test_checkpoint_resume_nf12_macaq_4792 + serialization + 5307 60 passed

uvx [email protected] check gptqmodel docs/eora tests setup.py: clean.

Compatibility notes

  • None/string group_size already raised on main (None <= 0 / str <= 0 is a TypeError), so nothing that loaded before stops loading.
  • Integer fields still surface OverflowError from int(inf); the sweep accepts that as a loud rejection. Only the silent-accept path is closed.

Fixes #5437

…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant