Skip to content

test(awq): guard #5085's position cap on the capture-time token-row plan (#5215) - #5220

Merged
Qubitium merged 1 commit into
mainfrom
fix/awq-5085-guard-capture-plan-5215
Nov 18, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/awq-5085-guard-capture-plan-5215

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #5215.

Problem

#5175 moved token-row sampling from replay (AWQProcessor._pack_token_rows) to capture (_token_row_plan_for_module / _compute_token_row_quotas), so tests/test_awq_gpt_neo_packed_replay_5085.py's _pack_token_rows spy was never called. Two of its tests were red on main:

FAILED tests/test_awq_gpt_neo_packed_replay_5085.py::test_awq_gpt_neo_batch_of_two_quantizes_within_the_limit
FAILED tests/test_awq_gpt_neo_packed_replay_5085.py::test_control_batch_of_one_keeps_every_row

The product behaviour was still correct, but #5085's position cap had no working guard: dropping _cap_token_rows from _token_row_plan_for_module would not turn anything red.

Fix

  • Spy on _token_row_plan_for_module instead: assert plan.max_tokens <= max_position_embeddings and sum(plan.quotas) <= max_position_embeddings.
  • The batch-of-two case also asserts max(plan.budget) > _LIMIT while max(plan.max_tokens) == _LIMIT, proving the cap is what keeps the replay legal.
  • The batch-of-one control now uses one document so it can assert every row is retained (plan.quotas == [40]).
  • Keep direct unit coverage of the legacy _pack_token_rows cap for the no-provenance fallback.

Verification

  • pytest tests/test_awq_gpt_neo_packed_replay_5085.py -q → 6 passed (was 2 failed, 3 passed).
  • Injected the regression (removed _cap_token_rows from _token_row_plan_for_module): test_awq_gpt_neo_batch_of_two_quantizes_within_the_limit fails as intended.
  • ruff check clean.

…lan (#5215)

#5175 moved token-row sampling from replay (AWQProcessor._pack_token_rows)
to capture (_token_row_plan_for_module), so the #5085 regression test's spy
was never called and its two integration tests were red on main while the
cap itself had no working guard.

Spy on the plan that now decides the replay length and assert
plan.max_tokens and sum(plan.quotas) stay within max_position_embeddings;
the batch-of-two case also proves the cap fires (uncapped budget 80 > 64).
The batch-of-one control now uses a single document so it asserts that every
row is kept, and a direct unit test keeps the legacy packer's cap covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant