Repository navigation
fix(gptq): retain BOS sink decisions after the calibration dataset is released (#4568) - #4610
Merged
Merged
Conversation
…4568) ModuleLooper deletes processor.calibration_dataset before the layer loop, so the #4526 hook-time BOS lookup always saw a deleted attribute and exclude_attention_sinks masked nothing. Resolve one decision per calibration batch in release_calibration_dataset (while the dataset still exists) and look it up by batch index in the hook. Gate the lookup on any per-module task/dynamic rule, not only the global flag, so dynamic overrides mask too. Add exclude_attention_sinks to the shared-Hessian accumulation signature so a follower with a different per-module setting does not adopt the leader's Hessian. Flag-off stays bit-identical, and BOS-less tokenizers still keep their first real token (#4459). Add regression tests that run the release lifecycle and assert nsamples/Hessian differ from the flag-off control and match the BOS-masked reference.
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
…mask (#4393) Move the attention-sink opt-in from `GPTQConfig.exclude_attention_sinks` to the calibration config, `quantize(..., calibration_exclude_attention_sinks=True)` (`CalibrationConfig.exclude_attention_sinks`), and apply it once, in the shared calibration keep-mask, so every calibration method drops the same rows. Rule: every attended BOS token is excluded (the leading one, after left or right padding, and each document-boundary BOS of concatenated calibration). Nothing else is: a tokenizer without a BOS token (Qwen2/2.5/3) keeps every row and its checkpoint is bitwise identical to the default run (#4459). - `LoopProcessor.calibration_keep_mask` edits the padding mask per batch; `_mask_tls.padding_value` keeps the padding-only mask for forward-visible consumers (MoE padding zeroing, NVFP4 amax, EXL3/DeepSeek-V4 router evidence). Token totals and the zero-sample threshold use the retained rows. - Consumers: GPTQ/GPTAQ/FOEM/native capture, QQQ, MACaQ, EXL3 capture, AWQ features and token-row structure, calibrated FP8 GSQ. Natively routed experts and VLM batches whose sequence cannot be placed keep their rows. - VPTQ rejects the option (PPL 4.5-4.7x worse on Llama-3.2-1B/-Instruct); ParoQuant and staged GSQ reject it; `quantize()` rejects a `dynamic[...].exclude_attention_sinks` rule. - Remove the GPTQConfig field and its per-method plumbing from #4440, #4525, #4526 and #4610 (`attention_sink_mask_supported`, factory/dynamic/load sanitizers, `GPTQ._attention_sink_row_keep`, `attention_sink_bos_flags`). `GPTQConfig(exclude_attention_sinks=...)` now raises `TypeError`. - Supersede the GPTQ-only #4568 fix (#4610): the BOS positions are resolved from the prepared `input_ids` and `tokenizer.bos_token_id` when the processor is built, before `release_calibration_dataset()`, for every calibration method; #4610's per-batch decision cache in `GPTQProcessor`, its dynamic gating and its Hessian-share signature field are removed. - Provenance: `meta.calibration_exclude_attention_sinks: true` only when on. - test_llama3_2: forward the switch through the new kwarg and re-baseline the slow metrics for the new rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
…mask (#4393) (#4663) * feat(calibration): exclude attention sinks in the shared calibration mask (#4393) Move the attention-sink opt-in from `GPTQConfig.exclude_attention_sinks` to the calibration config, `quantize(..., calibration_exclude_attention_sinks=True)` (`CalibrationConfig.exclude_attention_sinks`), and apply it once, in the shared calibration keep-mask, so every calibration method drops the same rows. Rule: every attended BOS token is excluded (the leading one, after left or right padding, and each document-boundary BOS of concatenated calibration). Nothing else is: a tokenizer without a BOS token (Qwen2/2.5/3) keeps every row and its checkpoint is bitwise identical to the default run (#4459). - `LoopProcessor.calibration_keep_mask` edits the padding mask per batch; `_mask_tls.padding_value` keeps the padding-only mask for forward-visible consumers (MoE padding zeroing, NVFP4 amax, EXL3/DeepSeek-V4 router evidence). Token totals and the zero-sample threshold use the retained rows. - Consumers: GPTQ/GPTAQ/FOEM/native capture, QQQ, MACaQ, EXL3 capture, AWQ features and token-row structure, calibrated FP8 GSQ. Natively routed experts and VLM batches whose sequence cannot be placed keep their rows. - VPTQ rejects the option (PPL 4.5-4.7x worse on Llama-3.2-1B/-Instruct); ParoQuant and staged GSQ reject it; `quantize()` rejects a `dynamic[...].exclude_attention_sinks` rule. - Remove the GPTQConfig field and its per-method plumbing from #4440, #4525, #4526 and #4610 (`attention_sink_mask_supported`, factory/dynamic/load sanitizers, `GPTQ._attention_sink_row_keep`, `attention_sink_bos_flags`). `GPTQConfig(exclude_attention_sinks=...)` now raises `TypeError`. - Supersede the GPTQ-only #4568 fix (#4610): the BOS positions are resolved from the prepared `input_ids` and `tokenizer.bos_token_id` when the processor is built, before `release_calibration_dataset()`, for every calibration method; #4610's per-batch decision cache in `GPTQProcessor`, its dynamic gating and its Hessian-share signature field are removed. - Provenance: `meta.calibration_exclude_attention_sinks: true` only when on. - test_llama3_2: forward the switch through the new kwarg and re-baseline the slow metrics for the new rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(gptq): keep process_batch signature compatible with its overrides --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Summary
Fixes #4568 — a regression from my #4526.
exclude_attention_sinksbecame a silent no-op because the BOS lookup readprocessor.calibration_dataset, which the looper deletes before the layer loop.release_calibration_dataset()override before the dataset is deleted and looks them up by batch index in the hook.g.qcfg) plus_attention_sink_requested()scanning the global flag / tasks /dynamicrules, so a dynamic-only override still captures.exclude_attention_sinksis now part of_hessian_accumulation_settings.Validation
CPU repro (2 samples × 3 tokens, BOS id 1, releasing the dataset first):
pytest tests/test_gptq.py -k attention_sink tests/test_attention_sink_config_coverage_4447.py -q→ 53 passed (including the previously failing dynamic-override test)pytest tests/test_gptq.py tests/test_shared_input_hessian_dedup.py -q→ 122 passed, 3 skippedruff check gptqmodel docs/eora tests setup.pycleanResidual: end-to-end Llama-3.2-1B PPL was not measured here (CPU-only); the fix restores the pre-#4526 decision data.
Resolves #4568.