Skip to content

fix(llama): exclude the Llama 3 BOS attention sink for QQQ by default (#6568) - #6570

Merged
Qubitium merged 1 commit into
mainfrom
fix/llama3-qqq-attention-sink-default
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/llama3-qqq-attention-sink-default

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Fixes #6568

Problem

The #6498 per-model attention-sink default lists only METHOD.GPTQ for Llama 3, so QQQConfig with a default CalibrationConfig keeps the Llama 3 BOS sink in its Hessian. QQQ has no group-aware ordering, so the sink wrecks the model: Llama-3.2-1B QQQ4 g128 scores wikitext2 PPL 1105.

Change

  • LlamaQModel.attention_sink_exclusion_methods = (METHOD.GPTQ, METHOD.QQQ). The llama3 RoPE predicate is unchanged, so TinyLlama/Llama 2 and every other model keep their checkpoints. An explicit exclude_attention_sinks=True/False still wins.
  • Docs: calibration-attention-sinks.md adds the QQQ measurement; quantization-guide.md names QQQ in the default.
flowchart TD
    A["CalibrationConfig.exclude_attention_sinks=None"] --> B{"method in LlamaQModel.attention_sink_exclusion_methods?"}
    B -- "before: GPTQ only" --> C["QQQ: sinks kept, PPL 1105"]
    B -- "after: GPTQ, QQQ" --> D{"rope_type == llama3?"}
    D -- yes --> E["sinks excluded, PPL 11.55"]
    D -- no --> F["sinks kept (unchanged)"]
Loading

Test plan

Hardware: AMD Radeon AI PRO R9700 (gfx1201), ROCm 7.16, torch 2.16 dev. Model unsloth/Llama-3.2-1B, QQQ 4-bit g128, 128 C4 rows, wikitext2 test PPL over 141 x 2048-token windows.

PPL
fp16 9.75
QQQ default, base c649fcb5f 1105.22
QQQ exclude_attention_sinks=True, base 11.55
QQQ default, this branch (log: "excludes BOS attention-sink tokens ... for qqq") 11.5454 (same checkpoint quality as the explicit run)

An FP64 oracle forward (dequantized weights, no activation quantization) on the base checkpoint gives the same per-window PPL as QQQTorchLinear, so the fault is in calibration, not the kernel.

Unit regression (tests/test_attention_sink_model_default_6498.py):

  • red on origin/main: test_llama3_qqq_excludes_attention_sinks_by_default FAILED (resolved False), 17 passed
  • green: tests/test_attention_sink_model_default_6498.py tests/test_calibration_attention_sinks.py tests/test_calibration_config.py tests/test_qqq_config.py -> 122 passed, 1 failed. The failure is test_qqq_linear_per_channel_normalizes_activation_order[native_qqq], which also fails on clean origin/main on ROCm (native CUDA QQQ kernel has no ROCm build, test is not NVIDIA-gated); unrelated.
  • tests/test_docs_contract_refs.py -k "calibration-attention-sinks or quantization-guide": 27 passed.
  • uvx [email protected] check on the touched files: clean.

Not verified: an NVIDIA run of the QQQ e2e (the change is calibration policy, not device-specific).

🤖 Generated with Claude Code

QQQ builds the same calibration Hessian as GPTQ without group-aware
ordering, but the #6498 per-model default only listed METHOD.GPTQ, so QQQ
kept the Llama 3 BOS sink. Llama-3.2-1B QQQ4 g128 scored wikitext2 PPL
1105 by default and 11.5 with the sink excluded.

Fixes #6568

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 03:58
@Qubitium
Qubitium merged commit 071de02 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/llama3-qqq-attention-sink-default branch December 1, 2026 03:58
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.

[QUALITY] QQQ on Llama 3 with default calibration: wikitext2 PPL 1105 (Llama-3.2-1B) because BOS sink exclusion defaults to GPTQ only

1 participant