Skip to content

fix(calibration): per-model attention-sink default; Llama 3 GPTQ excludes BOS sinks (#6498) - #6500

Merged
Qubitium merged 1 commit into
mainfrom
gptq-sink-row-exclusion
Nov 30, 2026
Merged

Qubitium merged 1 commit into
mainfrom
gptq-sink-row-exclusion

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6498.

GPTQ on Llama 3 loses the whole model to the BOS attention sink. The BOS row dominates the layer-0 down_proj Hessian (its diagonal is ~40,000× the median), and the error GPTQ propagates from that column saturates the module. Excluding the BOS token from calibration statistics fixes it. That option already exists (CalibrationConfig(exclude_attention_sinks=True)), but it isn't a safe global default. This PR makes the default per model: it is off unless measured, so other models are unchanged.

Change

  • CalibrationConfig.exclude_attention_sinks now defaults to None, meaning the model default. An explicit True/False always wins.
  • A model definition opts in with:
    • attention_sink_exclusion_methods, declared in its own class body. It is not inherited, so Qwen2/3, Gemma, OLMo2 and the other LlamaQModel subclasses are unaffected;
    • an optional attention_sink_exclusion_applies(config) predicate.
  • Weight-only runs and staged GSQ resolve to False.
  • When the default turns the exclusion on, it is logged, and meta.calibration_exclude_attention_sinks records it.
  • Llama opts in for GPTQ on Llama 3 checkpoints only (rope_type == "llama3").
flowchart TD
    A["exclude_attention_sinks"] --> B{"value"}
    B -- "True / False" --> Z["use it"]
    B -- "None (default)" --> C{"definition's own methods list has the run's method?"}
    C -- no --> F["False: unchanged"]
    C -- yes --> D{"calibrated, not staged GSQ, applies(config)?"}
    D -- no --> F
    D -- yes --> T["True: drop every attended BOS (logged, recorded in meta)"]
Loading

Results

4-bit g128 GPTQ, desc_act=True, 128 wikitext2 train rows; wikitext2 test perplexity:

checkpoint main this PR (default)
Llama-3.2-1B-Instruct 53.85 15.05 (same digest as main + explicit True)
Llama-3.2-1B 130.05 12.51
Llama-3.1-8B-Instruct 14.01 7.46
Qwen2.5-0.5B-Instruct 14.85 14.85 (digest-identical)
TinyLlama-1.1B-Chat (Llama 2 arch) 9.02 9.02, not opted in (it would get worse: 9.14)

For reference, Llama-3.2-1B-Instruct scores 12.64 unquantized and 16.9 with round-to-nearest.

Replaces this PR's first version, a row-norm Hessian exclusion. That version fixed Llama but cost Qwen2.5-0.5B 0.4–0.5 perplexity, because Qwen's large first-token rows carry useful signal. A norm threshold can't tell those apart from Llama's sink.

Validation (targeted)

  • Red/green: tests/test_attention_sink_model_default_6498.py fails on main and passes here. It pins:
    • the None default and strict type checks;
    • Llama 3 → on, other Llama checkpoints → off;
    • no inheritance (Qwen2 subclasses Llama);
    • only the measured method gets the default (AWQ → off), and weight-only runs → off;
    • explicit values win.
  • Calibration suites: test_calibration_config.py and test_calibration_attention_sinks.py were updated for the new default; 101 passed.
  • A/B against main over 157 test files that quantize a Llama-type model or touch sink exclusion (per file, CPU): identical results, except the new test file, which doesn't exist on main.
  • The ruff gate passes.

🤖 Generated with Claude Code

…udes BOS sinks (#6498)

GPTQ on Llama 3 loses the model to the BOS attention sink: its row dominates
the layer-0 down_proj Hessian (diag ~40,000x median). Excluding the BOS token
(`CalibrationConfig(exclude_attention_sinks=True)`, already supported) fixes
it, but it is not a safe global default, so:

- `CalibrationConfig.exclude_attention_sinks` defaults to `None` = model
  default; explicit True/False always win.
- A definition opts in via `attention_sink_exclusion_methods` in its own class
  body (not inherited) plus an optional `attention_sink_exclusion_applies(config)`
  predicate. Weight-only runs and staged GSQ resolve to False.
- Llama opts in for GPTQ on Llama 3 checkpoints only (rope_type "llama3").

wikitext2 PPL, 4-bit g128 GPTQ (kept -> excluded):
  Llama-3.2-1B-Instruct 53.85 -> 15.05, Llama-3.2-1B 130.05 -> 12.51,
  Llama-3.1-8B-Instruct 14.01 -> 7.46.
Unchanged (digest-identical to main): Qwen2.5-0.5B-Instruct; TinyLlama
(Llama 2 arch, would be 9.02 -> 9.14) is not opted in.

The earlier row-norm Hessian exclusion is dropped: it cost Qwen2.5-0.5B
~0.4-0.5 PPL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium force-pushed the gptq-sink-row-exclusion branch from a54a17f to 44aa8d9 Compare November 30, 2026 19:57
@Qubitium Qubitium changed the title fix(gptq): leave attention-sink rows out of the Hessian in every mode (#6498) fix(calibration): per-model attention-sink default; Llama 3 GPTQ excludes BOS sinks (#6498) Nov 30, 2026
@Qubitium
Qubitium marked this pull request as draft November 30, 2026 19:57
@Qubitium
Qubitium marked this pull request as ready for review November 30, 2026 19:59
@Qubitium
Qubitium merged commit 0166ac3 into main Nov 30, 2026
6 checks passed
@Qubitium
Qubitium deleted the gptq-sink-row-exclusion branch November 30, 2026 19:59
Qubitium added a commit that referenced this pull request Dec 1, 2026
…6506)

`tests/test_docs_contract_refs.py` had 8 failures on main:

- docs/cancelled-run-contract.md (+ the citation table) still cited
  `_copy_checkpoint_tensors_into_submodule` / `_publish_checkpoint_param_`
  in gptqmodel/utils/structure.py; #6473 moved both to
  gptqmodel/weight_loader/source.py.
- docs/weight-loader.md blocks 0/1 (#6473) executed on a CPU-only host:
  a two-accelerator `accel:0`/`accel:1` placement map and a continuation
  that needs `model` and a real checkpoint. Skip-listed with reasons.
- docs/measurement.md block 3 is a continuation snippet (prose-defined
  `texts`, `tokenizer`, models); skip-listed.
- Skip-list digests refreshed for docs/calibration-config.md::0 (#6500
  added `exclude_attention_sinks=None`) and
  docs/looper-checkpoint-redesign.md::0 (#6492 added subset intervals);
  both reasons still hold.

The eighth, docs/jit-kernel-builds.md::0, is fixed in #6505.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@Qubitium Qubitium mentioned this pull request Dec 1, 2026
3 tasks done
Qubitium added a commit that referenced this pull request Dec 1, 2026
This release carries breaking changes (Accelerate removed and placement=
replacing device_map= in #6473, pickle checkpoints refused, sccache >= 0.18
for JIT builds, model-owned attention-sink defaults in #6500) and many new
features, so it is a minor release per the rule in version.py, not the
7.12.4 patch number main carried.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPTQ 4-bit on Llama-3.2-1B-Instruct is ~3x worse than RTN (PPL ~50 vs 18): layers.0.mlp.down_proj sink channel

1 participant