Repository navigation
fix(awq): keep one in eight single-row quotas at the sink position (#5310) - #5315
Merged
Merged
Conversation
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.
Fixes #5310. Follow-up to #5289 (which fixed #5265).
Problem
#5289 moved every single-row token quota to the batch centre. That fixed the
Llama collapse (#5265: 91.7 -> 22.5) but removed the BOS/attention-sink rows
from the sample entirely, and the AWQ scale search then never saw the outlier
channels those positions carry: Qwen2.5-0.5B at
batch_size=1measured 28.01PPL against 24.92 at
batch_size=4and 24.82 for RTN.Both extremes are bad, so the choice must not be all-or-nothing.
Change
AWQProcessor._single_token_row(length, ordinal)keeps row 0 for onesingle-row quota in eight and the batch centre for the rest, in both branches
(
quota == 1andretained_tokens < batch_count). The ordinal countssingle-row quotas in batch order, so the sink rows are spread over the
calibration stream instead of clustering at its start.
issue measured at 24.02 PPL on Qwen2.5-0.5B (vs 24.82 RTN, 24.92 at
batch_size=4) and 21.98 on Llama-3.2-1B (vs 21.89 atbatch_size=4).preserved where there is nothing to spread.
quota >= 2) are unchanged: row 0 plus even spacing.Tests
tests/test_awq_token_row_position_5265.pynow bounds the sink share from bothsides instead of forbidding position 0:
test_single_row_quota_keeps_a_bounded_sink_share-- 64 short documents keepexactly 8 sink rows (batches 0, 8, 16, ...), the other 56 keep the centre.
test_single_row_quotas_bound_the_sink_share-- sweeps lengths and budgets;the share stays in [1%, 50%].
test_budget_below_batch_count_mixes_sink_and_centreandtest_a_single_batch_still_keeps_its_first_row.4 of these fail on
main(0% sink share); the pre-#5289 code (100%) also failsthe two-sided bound.
test_awq_token_rows_bounded_capture_5137andtest_awq_weight_meanexpectations return to row 0 for their single-batch plans.Docs (
docs/awq-calibration-aggregation.md) describe the 1/8 rule.Relevant suites: 200 passed, 1 skipped. The end-to-end PPL numbers above are the
issue's measurements of this exact rule; the plan-level share is what the tests
pin here (512 -> 64 sink rows).