Skip to content

[BUG] Smoother parameters are never validated: SmoothMAD(k=0) / SmoothPercentile(percentile=0.99) silently destroy the model (RTN nll 15 -> 61 / 86) #4953

Closed

Description

@Qubitium

Found on main @ 3867c82, CPU (Qwen2.5-0.5B-Instruct truncated to 2 layers, bf16, RTN 4-bit g128).

What is wrong

None of the smoother descriptors in gptqmodel/quantization/config.py validate their parameters (SmoothPercentile :1422, SmoothPercentileAsymmetric :1443, SmoothMAD :1466, SmoothMSE, SmoothOutlier, SmoothSoftNorm, SmoothLog). The same holds for SmootherConfig(smooth=...), Fallback(smooth=...) and the dict/JSON forms parsed by _parse_smooth_method. smooth_block (gptqmodel/quantization/fallback_smooth.py:88) then applies whatever it gets:

  • SmoothMAD(k=0) clamps every weight row to its median. k<0 gives lo > hi, which _clamp_block resolves to a meaningless clamp.
  • SmoothPercentile(percentile=0.99) is read as the 0.99th percentile, not the 99th: every |w| is clamped to roughly the row minimum. percentile is on a 0-100 scale, but nothing rejects or warns about a value that looks like a fraction. percentile <= 0 clamps to the min, and >= 100 silently becomes a no-op.
  • SmoothPercentileAsymmetric(low > high), SmoothOutlier(pct > 100), SmoothMSE(steps <= 0 / maxshrink outside (0, 1]) and SmoothSoftNorm(k <= 0) are accepted the same way.

Quantization completes, the checkpoint saves and reloads, and nothing is logged. The model is simply destroyed. Every other numeric config field I probed rejects bad values at construction: HessianConfig, MoEConfig, CalibrationConfig, Fallback.strategy, damp_percent, and bools since #4668.

Repro

import torch
from gptqmodel import GPTQModel
from gptqmodel.quantization import config as C
from gptqmodel.quantization.config import CalibrationConfig

for tag, cfg in [
    ("no smoother",        C.RTNConfig(bits=4, group_size=128)),
    ("MAD k=2.75",         C.RTNConfig(bits=4, group_size=128, smoother=C.SmootherConfig(smooth=C.SmoothMAD(k=2.75)))),
    ("MAD k=0",            C.RTNConfig(bits=4, group_size=128, smoother=C.SmootherConfig(smooth=C.SmoothMAD(k=0.0)))),
    ("MAD k=-1",           C.RTNConfig(bits=4, group_size=128, smoother=C.SmootherConfig(smooth=C.SmoothMAD(k=-1.0)))),
    ("percentile=99",      C.RTNConfig(bits=4, group_size=128, smoother=C.SmootherConfig(smooth=C.SmoothPercentile(percentile=99.0)))),
    ("percentile=0.99",    C.RTNConfig(bits=4, group_size=128, smoother=C.SmootherConfig(smooth=C.SmoothPercentile(percentile=0.99)))),
]:
    m = GPTQModel.load("Qwen2.5-0.5B-Instruct (2 layers)", cfg, dtype=torch.bfloat16)
    m.quantize(CalibrationConfig(dataset=texts, batch_size=4)); m.save(out)
    print(tag, nll(GPTQModel.load(out, device="cpu", dtype=torch.bfloat16)))

Reloaded nll on a fixed prompt (no error or warning in any run):

no smoother        14.98
MAD k=2.75         15.37
MAD k=0            61.11   <- every weight = row median
MAD k=-1           17.05
percentile=99      14.95
percentile=0.99    86.52   <- fraction-vs-percent confusion

Suggested fix

Add __post_init__ validation to each smoother: SmoothMAD.k > 0, SmoothSoftNorm.k > 0, 0 < SmoothPercentile.percentile <= 100, 0 <= low < high <= 100, 0 <= SmoothOutlier.pct < 100, SmoothMSE.steps >= 1 and 0 < maxshrink <= 1, and group_size_threshold an int. Raise ValueError naming the field. For SmoothPercentile, also warn or reject when 0 < percentile <= 1, because that is almost always a fraction meant as a percent. Validate in _parse_smooth_method as well, so JSON/dict configs are covered.

Test that should have caught it

There is no negative test for smoother parameters. Add constructor tests for each out-of-range value.

Severity

Low-medium. This is user error, but it fails silently, and the fraction-vs-percent mistake is easy to make. The result is a model with nll 60-87 and no diagnostic.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released: agent-53ba17eb4d83 finished this issue.

    Pull request: #4970

    Validate smoother parameters (SmoothMAD k, SmoothPercentile percentile, etc.) at config construction instead of silently destroying the model (RTN nll 15 -> 1e4); add validation tests per smoother.

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

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

  3. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent release: agent-root-4953 is standing down — PR #4970 (fix/issue-4953, all checks green) already delivers this fix. No duplicate PR was opened and the local branch was discarded.

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