Repository navigation
fix(config): reject fraction asymmetric percentiles and validate dynamic smoothers (#5005) - #5017
Merged
Merged
Conversation
…mic smoothers (#5005) `SmoothPercentileAsymmetric` reads the same 0-100 scale as `SmoothPercentile` through `fallback_smooth._quantile`, but only the symmetric smoothers were guarded. `low=0.005, high=0.995` (meant 0.5% / 99.5%) constructed cleanly, and with `high <= 1` the upper bound lands next to the row minimum, so `_clamp_block` pins almost every weight to the bottom tail: the model is destroyed with no error or warning (#4953 was the same defect on `SmoothPercentile`). New `_validate_asymmetric_percentile_bounds` rejects `high <= 1` (destructive) and a non-zero `low` below 0.1 (clips nothing, so it is a fraction typo or dead configuration; `0` stays the explicit "no lower clip"). `low` legitimately sits below 1 -- the documented default is 0.5 -- so it cannot reuse the symmetric rule. The dict/JSON and `SmootherConfig`/`Fallback` paths go through the same constructor and now fail too. Second half: a smoother inside a per-module `dynamic` override is merged only when the module is first matched, so `{"fallback": {"smooth": {"type": "mad", "k": 0}}}` raised from the middle of `quantize()` -- after the model had been mutated -- with no module name in the message. New `_validate_dynamic_smoothers` runs the runtime normalizers (`_normalize_fallback`, `_normalize_preprocessors`, `_normalize_smoother_config`) for every smoother bearing key of a rule at construction, without mutating the rule, and names the offending pattern. It is wired into all four `dynamic` loops (base, FP8, bitsandbytes, EXL3). Tests: `tests/test_smooth_percentile_bounds_5005.py` (16 nodes), added to the AWQ CPU `unit` suite. On unmodified `origin/main` 7 of them fail (the three fraction bounds, the dict/wrapper path, and all three `dynamic` forms); with the fix 16 pass. The numeric node documents the mechanism: a 0.99 "percentile" clamps >90% of a 128-wide block while 99.5 clamps <2%.
This was referenced Nov 17, 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 #5005. Two related gaps left by #4970 (fix of #4953):
SmoothPercentileAsymmetricwas never given the fraction rule.It reads the same 0-100 scale as
SmoothPercentilethroughfallback_smooth._quantile, but only0 <= low < high <= 100was checked, solow=0.005, high=0.995(meant 0.5% / 99.5%) constructed cleanly. Withhigh <= 1the upper bound lands next to the row minimum and_clamp_blockpins almost every weight to the bottom tail — the model isdestroyed with no error and no warning.
Smoothers inside per-module
dynamicoverrides were not validated atconstruction. A rule is merged into a per-module config only when the
module is first matched, so
dynamic={"+:.*q_proj.*": {"fallback": {"smooth": {"type": "mad", "k": 0}}}}constructed cleanly and then raised from
normalize_fallbackin the middle ofquantize(), after the model had already been mutated, with no module namein the message. Same for the
{"preprocessors": [{"code": "smoother", "smooth": {...}}]}form.What Changed
gptqmodel/quantization/config.py_validate_asymmetric_percentile_bounds(owner, low, high), called fromSmoothPercentileAsymmetric.__init__:high <= 1->ValueErrornaming the 0-100 scale (destructive: clampsalmost every weight to the row minimum);
0 < low < 0.1->ValueErrornaming the 0-100 scale (clips nothing atany realistic group size, so it is a fraction typo or dead config;
0stays the explicit "no lower clip").
lowcannot reuse the symmetric rule because the documented default is0.5(the 0.5th percentile). The dict/JSON andSmootherConfig/Fallback(smooth=...)paths all go through this constructor, so they failtoo.
_validate_dynamic_smoothers(owner, layer_name, layer_dict): for everysmoother-bearing key of one
dynamicrule (fallback,preprocessors,smoother,smooth) it runs the same normalizer the runtime uses(
_normalize_fallback,_normalize_preprocessors,_normalize_smoother_config) and re-raises with the offending modulepattern named. It does not mutate the rule, so serialization and runtime
normalization are unchanged.
dynamicloops:BaseQuantizeConfig,FP8Config,BitsAndBytesConfig,EXL3Config.tests/test_smooth_percentile_bounds_5005.py(new, 16 nodes), added to theAWQ CPU
unitsuite.No change to
SmoothPercentile/SmoothLog(their #4970 rule is re-assertedby the new tests), no change to
smooth_block/_quantilenumerics, and nochange to any legal configuration.
Tests
tests/test_smooth_percentile_bounds_5005.pyon unmodifiedorigin/main(
24a46e337, test copied into a separate worktree): 7 failed, 9 passed.maintest_asymmetric_fraction_bounds_are_rejected[both-fractions]DID NOT RAISEforlow=0.005, high=0.995test_asymmetric_fraction_bounds_are_rejected[fraction-high]DID NOT RAISEforhigh=0.99test_asymmetric_fraction_bounds_are_rejected[fraction-low]DID NOT RAISEforlow=0.005test_dict_and_wrapper_paths_reject_the_same_asymmetric_boundsSmootherConfig/Fallbackaccepted the fractiontest_dynamic_fallback_smoother_is_validated_at_constructiondynamicrule withmad k=0constructedtest_dynamic_preprocessor_smoother_is_validated_at_constructiondynamicrule with a badpreprocessorssmoother constructedtest_dynamic_smoother_field_is_validated_at_constructiondynamicrule with a fractionsmootherconstructedThe 9 nodes that already pass are the legal-boundary cases, the unchanged
#4970 rules, and the numeric mechanism node (a 0.99 "percentile" clamps >90% of
a 128-wide block, 99.5 clamps <2%).
On this branch: 16 passed.
Neighbouring suites (config/fallback/smoother + AWQ scale-search safety + docs
contract), identical command on both trees:
origin/maintests/test_smoother_parameter_validation_4953.py(the #4970 guard) is part ofthat run and stays green:
low=0.0, high=100.0andpercentile=1.5are stilllegal.
ruff checkclean on both changed Python files.Model Support / Module Plan
Not applicable: no model, alias, definition, or module-plan change.
AWQ onboarding safety
Not applicable: no model onboarding, grouping, search, replay, or fold change.
The new test file is only wired into the AWQ CPU
unitlane because that is theCPU suite PRs actually run.
Logic Flow Documentation
Not applicable: the only control-flow change is a fail-closed rejection at
config construction (before a model is loaded), documented in the two new
function docstrings and pinned by the tests. No runtime decision order, data
lifecycle, or tensor flow changes.
Review Requirements
Kernel Accuracy Requirements
Not applicable: no kernel or fusion change.
Notes
SmoothPercentileAsymmetric(high<=1)or a non-zerolow<0.1, or an invalidsmoother inside a
dynamicrule, now fails at construction/load with afield-named error instead of silently destroying the model or failing
mid-
quantize().low=0andlow>=0.1are unaffected, so the documenteddefault
0.5 / 99.5and0 / 100still work.lowuses a different threshold thanhighon purpose:lowbelow 1 islegitimate (0.5 is the default), so the rule targets the values that clip
nothing rather than the values that clip everything.