Repository navigation
fix(config): validate smoother parameters at construction (#4953) - #4970
Merged
Merged
Conversation
None of the Smooth* descriptors validated their numeric fields. SmoothMAD(k=0)
clamped every row to its median and SmoothPercentile(percentile=0.99) read a
fraction as the 0.99th percentile, destroying the model with no error or
warning (measured NLL 15 -> 61/87).
Add semantic validation to every smoother constructor, which is the public
config surface reached by direct construction, SmootherConfig, Fallback and
the dict/JSON parser:
- MAD/SoftNorm k > 0 (finite)
- percentile on the 0-100 scale with 1 < value <= 100 (rejects the
0.99 fraction case; 100 is the documented max)
- asymmetric 0 <= low < high <= 100
- MSE steps >= 1 (int) and 0 < maxshrink <= 1
- outlier 0 <= pct < 100
- log mu > 0 and the same percentile rule
- rowcol axis in {row, col}
- group_size_threshold an int >= 0
Fallback now parses its smoother payload in __post_init__, so a directly
constructed Fallback(smooth={...}) is validated too. Error messages name the
field, offending value and valid range.
This was referenced Nov 17, 2026
Merged
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
…ntized loads (ModelCloud#4945) (ModelCloud#4972) `ModelLoader.from_quantized` popped the options it knew and let every other keyword reach `QuantizeConfig.from_pretrained`, which ignored it. A typo of a real option (`dtpye=`, `attn_implmentation=`, `devcie_map=`) or an option that does not apply (`bits=`) therefore "succeeded" and changed nothing, while the unquantized path raises from the HF constructor. A passed `quantize_config` was dropped the same way: the checkpoint's config won without a word. Wrap the keyword dict in `_TrackedKwargs`, which records every key consumed by `pop`, and raise `TypeError` for whatever is left after the internal keys are normalised. The accepted set is derived from `inspect.signature(cls.from_quantized)`, the recorded pops, and `inspect.signature(snapshot_download)` (the Hub staging options), so a newly added parameter or pop is accepted without editing a literal list. The message reuses the difflib close-match style of ModelCloud#4686: `dtpye` now points at `dtype`. VLLM/SGLang keep their explicit passthrough runtime options. `GPTQModel.load(quantized, quantize_config=...)` now raises `ValueError` instead of ignoring the argument: a quantized checkpoint's bits/group_size/method/format come from the checkpoint, and forwarding a different config was not provably safe. Two loader tests passed `quantize_config=` to `from_quantized`, relying on the silent drop; they now call it without that argument. Closes ModelCloud#4945. Also switch the `extract_adapter_rank_patterns` citation in docs/adapter-rank-pattern-matching.md to the symbol form (`config.py::extract_adapter_rank_patterns`). ModelCloud#4970 added ~137 lines above that definition, so the old `config.py:5595` citation fails `tests/test_docs_contract_refs.py` on pristine main and blocks the required AWQ CPU (unit) check.
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.
Fixes #4953.
What was unvalidated
All seven smoother descriptors accepted any numeric value; the same for
SmootherConfig,Fallback(smooth=...)and the dict/JSON parser:SmoothPercentilepercentile<=0clamps to the row min,>=100is a no-op,0.99clamps almost everything to the minSmoothPercentileAsymmetriclow,highlow > highproduced a meaningless clampSmoothMADkk=0clamps every row to its median;k<0giveslo > hiSmoothMSEsteps,maxshrinksteps<=0/maxshrinkoutside(0,1]silently clampedSmoothOutlierpctpct>=100clamps to the smallest|w|(destructive)SmoothSoftNormkk<=0collapses every z-scoreSmoothLogpercentile,mumu<=0silently becameepsSmoothRowColaxis"row"group_size_thresholdBounds chosen
SmoothMAD.k > 0,SmoothSoftNorm.k > 0,SmoothLog.mu > 0(finite positive; zero/negative collapse the block). The issue's "k must be an int" cannot be literal — the default is2.75.SmoothPercentile.percentile/SmoothLog.percentile:1 < value <= 100. Confirmed from_quantile: it divides by 100, so the field is a percent, not a fraction;<=0clamps to the min and>=100is the max.0.99gets a dedicated fraction-vs-percent message.SmoothPercentileAsymmetric:0 <= low < high <= 100.SmoothMSE.stepsint>= 1;maxshrinkin(0, 1].SmoothOutlier.pctin[0, 100);SmoothRowCol.axisin{"row", "col"}(normalized to lowercase);group_size_thresholdint>= 0.Fallback.__post_init__now parses/validates a directly suppliedsmoothpayload, soFallback(smooth={"type":"mad","k":0})fails at construction.SmoothMAD:kmust be > 0, got 0.0.Evidence
Destructive behaviour on parent (direct
smooth_block,torch.randn(4,128)):MAD k=0->row_std=[0,0,0,0](rel_change 1.000);pct 0.99-> rel_change 0.975;k=2.75/pct 99-> 0.076/0.085.tests/test_smoother_parameter_validation_4953.pyonorigin/main: 25 failed, 13 passed (DID NOT RAISEforSmoothMAD(k=0),SmoothPercentile(0.99), and the rest); fixed: 38 passed.tests/qcfg+test_quant_formats.py+test_fallback.py+test_weight_only*.py+test_config_serialization_roundtrip_4201.py+test_module_preprocessor.py+test_mlx_rtn_quantization.py+kernels/test_fallback.py: 443 passed, 13 skipped, 1 environment error (test_quantize_0_gptqcannot findc4-train.00000-of-01024.json.gzat fixture setup).ruff check gptqmodel tests: clean.Residual risk
SmoothPercentile(percentile<=1),SmoothOutlier(pct>=100)or a non-intgroup_size_thresholdnow fail loudly at construction. Those values were destructive or silently clamped.SmoothPercentileAsymmetricdoes not apply the fraction heuristic (its defaultlow=0.5is itself sub-1), solow=0.5, high=0.99remains legal.float()/int()-coerced before the constructor, so a non-numeric string there raises a generic conversion error rather than the field-named one.SmoothMSE.steps=1is accepted although the internal search clamps to>=3.