Repository navigation
fix(config): validate per-module dynamic numeric overrides (#5503) - #5531
Merged
Merged
Conversation
The dynamic merge copied its values verbatim, so the numeric checks that __post_init__ runs on the top-level fields never saw a per-module rule: damp_percent=nan quantized with every damp-recovery attempt failing and was then rescued by the Hessian floor, damp_percent=5.0 used 5x the Hessian mean with no warning, damp_auto_increment=-0.5 was accepted, and group_size=nan only failed later inside quantize(). A NaN was also serialized into quantize_config.json, where a bare NaN is not valid JSON. Run the same bounds on one dynamic rule: group_size through _validate_group_size, the damp/Paro/MACaQ float options through their top-level ranges, and a finiteness check for every remaining numeric field. The FP8/NF12/BnB/EXL3/GGUF overrides, which own their dynamic normalizer, now call the shared validator too. Fixes #5503
Qubitium
marked this pull request as ready for review
November 19, 2026 10:25
This was referenced Nov 20, 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
Fixes #5503. Follow-up to #5444 (#5437).
__post_init__validates the top-levelgroup_size/damp_percent/damp_auto_incrementand the Paro/MACaQ float options, but thedynamicmerge copied per-module values verbatim. Every one of those checks was skipped for adynamicrule:At quantize time
damp_percent=nanran every damp-recovery attempt withnan, was rescued by the Hessian diagonal floor, and was then written as a bareNaNintoquantize_config.json(not valid JSON).group_size=nanonly failed later insidequantize().What Changed
_validate_dynamic_numeric_overrides(owner, layer_name, layer_dict)ingptqmodel/quantization/config.py, called from every_normalize_dynamic_layer_config(base, FP8, NF12, BnB, EXL3, GGUF; VPTQ already rejects all dynamic overrides):group_sizegoes through_validate_group_sizeplus the existing supported-set error, sonan/non-integral values fail at construction and-7keeps its message.damp_percent(0, 1),damp_auto_increment>= 0, Paro's learning rates > 0 /opt_pair_ratio(0, 0.5] /opt_weight_decay/opt_eps/opt_sgd_momentum/opt_sgd_dampening/clamp bounds >= 0,opt_betasas two finite non-negative floats, MACaQridge>= 0 andpre_alpha[0, 1] — the same bounds as the top-level fields.int/float-annotated field (bits,mse, …) rejectsNaN/inf.group_sizebranch in the base normalizer is gone; the shared validator owns it.Tests
New coverage in
tests/test_config_numeric_validation_5437.py:test_every_numeric_option_rejects_non_finite_values_through_dynamicsweeps every numeric field of everyQuantizeConfigsubclass throughdynamic={"+:.*": {field: nan|inf|-inf}}.test_reported_dynamic_overrides_are_rejectedpins the issue's concrete values; 9 of its 10 cases are red onorigin/main(the tenth,group_size=-7, was already rejected).test_dynamic_numeric_overrides_keep_valid_valuespins that in-range rules still construct and are not rewritten.Unit tests have been executed and passed.
I added a new simple/fast unit test for this change.
Model Support / Module Plan
Not applicable: no new
MODEL_MAPentry, model-type alias, or definition change.AWQ onboarding safety
Not applicable: the change only validates numeric
dynamicvalues at config construction; no grouping, search, replay, or fold change.Logic Flow Documentation
Not applicable: no control flow changes. The per-module rule is validated with the same bounds the top-level fields already use.
Review Requirements
_normalize_dynamic_layer_confighook.group_size=100is still accepted at construction, matching the top-level field.Kernel Accuracy Requirements
Not applicable: no kernel math change.
Notes
group_size=100remains accepted at config construction exactly like the top-levelgroup_size, and still fails inselect_quant_linearat quantize time. Rejecting it per-module only would have made the two paths disagree.