Skip to content

[BUG] #4970 (fix of #4953) incomplete: SmoothPercentileAsymmetric still accepts fraction bounds (low=0.005, high=0.995 -> RTN PPL NaN); dynamic smoothers unvalidated until mid-quantize #5005

Closed

Description

@Qubitium

Found on main @ c2b0bf6, RTX 4090.

What is wrong

#4970 (fix of #4953) rejects SmoothPercentile(percentile <= 1) and SmoothLog(percentile <= 1) because "a value <= 1 looks like a fraction and clamps almost every weight" (_validate_smooth_percentile, gptqmodel/quantization/config.py). SmoothPercentileAsymmetric uses the same 0-100 scale through the same _quantile() (fallback_smooth.py). Its fields are only checked for 0 <= low < high <= 100, so the same fraction mistake still passes:

C.SmoothPercentileAsymmetric(low=0.005, high=0.995)  # meant 0.5% / 99.5%: accepted
C.SmoothPercentileAsymmetric(low=0.5,   high=0.99)   # accepted
C.SmoothPercentile(percentile=0.99)                  # rejected by #4970

With high <= 1, hi = _quantile(block, high) is close to the row minimum. _clamp_block then pins almost every weight in the group to the bottom tail. The model is destroyed, and there is no error or warning. This is the failure #4953 reported, on the sibling class.

A smaller gap with the same root cause: smoothers inside per-module dynamic overrides are still not validated at construction. QuantizeConfig(bits=4, dynamic={"+:.*q_proj.*": {"fallback": {"smooth": {"type": "mad", "k": 0}}}}) constructs without error. The ValueError only fires once quantization reaches a matching module, when normalize_fallback() builds the smoother. The same applies to {"preprocessors": [{"code": "smoother", "smooth": {...}}]} in dynamic.

Repro

Qwen2.5-0.5B-Instruct, fp16, RTNConfig(bits=4, group_size=128, smoother=SmootherConfig(smooth=...)), 32 C4 rows, in-memory model, wikitext-2 PPL (20 x 511-token windows):

for tag, sm in [("none", None),
                ("asym default 0.5/99.5", C.SmoothPercentileAsymmetric()),
                ("asym fraction 0.005/0.995", C.SmoothPercentileAsymmetric(low=0.005, high=0.995)),
                ("asym 0.5/0.99", C.SmoothPercentileAsymmetric(low=0.5, high=0.99))]:
    kw = {} if sm is None else {"smoother": C.SmootherConfig(smooth=sm)}
    m = GPTQModel.load("Qwen2.5-0.5B-Instruct", C.RTNConfig(bits=4, group_size=128, **kw), dtype=torch.float16)
    m.quantize(CalibrationConfig(dataset=texts, batch_size=4))
    print(tag, ppl(m.model))
none                       27.583
asym default 0.5/99.5      110.083
asym fraction 0.005/0.995  nan
asym 0.5/0.99              nan

None of these runs printed an error or a warning.

Suggested fix

Apply the _validate_smooth_percentile rule to SmoothPercentileAsymmetric.high, which must be > 1. For low, either warn when both bounds are <= 1, or reject high <= 1 alone; that alone already catches the fraction pair. Optionally, normalize smoothers found in dynamic overrides (fallback.smooth, preprocessors[].smooth) at QuantizeConfig construction, so a bad override fails before quantization starts.

Test that should have caught it

tests/test_smoother_parameter_validation_4953.py covers only low >= high for the asymmetric class. Add SmoothPercentileAsymmetric(low=0.005, high=0.995) to the rejected cases.

Severity

Low-medium. This is user error, but the model is silently destroyed (NaN PPL). It is the case the #4953 fix was meant to close.

Side note, not filed separately: the default SmoothPercentileAsymmetric() (0.5/99.5) also takes RTN PPL from 27.6 to 110 here. That may be worth checking against the docs' recommended use.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-root-5005 is working on this issue now.

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent release: agent-root-5005 finished this issue. Fix: #5017, squash-merged as bfbb7a2b4.

    Validation rule implemented. New _validate_asymmetric_percentile_bounds (called from SmoothPercentileAsymmetric.__init__):

    • high <= 1 -> ValueError naming the 0-100 scale (the destructive form: _quantile(block, 0.99) is nearly the row minimum, so _clamp_block pins almost every weight to the bottom tail);
    • 0 < low < 0.1 -> ValueError (clips nothing at any realistic group size, so it is a fraction typo or dead config; 0 stays the explicit "no lower clip").

    low cannot reuse the symmetric rule because the documented default is 0.5, so 0.5/99.5, 0/100, 1.0/99.9, 0.1/99.9 all still construct. The dict/JSON and SmootherConfig/Fallback(smooth=...) paths go through the same constructor and now fail too. SmoothPercentile/SmoothLog keep #4970's behaviour (re-asserted in the new tests).

    Dynamic smoothers. New _validate_dynamic_smoothers runs the runtime normalizers (_normalize_fallback, _normalize_preprocessors, _normalize_smoother_config) for every smoother-bearing key of a dynamic rule (fallback, preprocessors, smoother, smooth) at construction, without mutating the rule, and names the offending pattern. Wired into all four dynamic loops (base, FP8, bitsandbytes, EXL3). dynamic={"+:.*q_proj.*": {"fallback": {"smooth": {"type": "mad", "k": 0}}}} now raises GPTQConfig: dynamic['+:.*q_proj.*'].fallback is not a valid smoother: SmoothMAD: k must be > 0, got 0.0. instead of failing mid-quantize().

    Red -> green. New tests/test_smooth_percentile_bounds_5005.py (16 nodes) on unmodified origin/main @ 24a46e337: 7 failed, 9 passed (the three fraction bounds, the dict/wrapper path, and all three dynamic forms DID NOT RAISE); with the fix 16 passed. A numeric node documents the mechanism: a 0.99 "percentile" clamps >90% of a 128-wide block, 99.5 clamps <2%.

    No regressions. Config/fallback/smoother + AWQ scale-search safety + docs-contract suites: main 266 passed / 2 skipped -> branch 282 passed / 2 skipped (+16 = the new file). tests/qcfg 183 passed on both trees. ruff clean. All 9 CI checks green; one review thread ("unnecessary lambda") fixed in 5c2f04893 and resolved before the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions