You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] AWQ crashes on GPT-Neo with batch_size>1: packed token-row replay exceeds max_position_embeddings and GPTNeoSelfAttention's fixed causal bias buffer cannot be sliced (RuntimeError, no fallback) #5085
Found on main @ e75181d, CPU (tiny model). The round-16 base 4f287eb fails the same way, so this is not a recent regression.
What is wrong
AWQ scale search packs the captured rows of several calibration documents into one [1, retained_tokens, hidden] replay sequence (AWQProcessor._pack_token_rows, gptqmodel/looper/awq_processor.py:1357). The budget comes from _token_row_budget (:1327): max(largest batch's kept tokens, number of batches). So with batch_size > 1 the packed sequence is about batch_size x seq_len tokens long. A block-diagonal mask and the original position_ids keep that semantically correct for rotary/mask-driven attention.
GPTNeoSelfAttention does not take its causal mask from the attention_mask argument. It slices a fixed self.bias buffer of [max_position_embeddings, max_position_embeddings]:
When the packed replay is longer than max_position_embeddings (2048 for every EleutherAI GPT-Neo checkpoint), the slice is clipped and torch.where raises. This is a plain RuntimeError, not _AWQScaleGroupError, so the configured fallback never runs and quantize() aborts in layer 0. GPTQ on the same model and data succeeds, and so does AWQ with batch_size=1.
Repro
GPT-Neo with the real gpt-neo-125m position geometry (max_position_embeddings=2048, window_size=256, global/local layers), narrowed to 2 layers × 128 hidden. Calibration is 4 wikitext rows of 1100 tokens, each well under the 2048 limit.
awq bs 1 OK
awq bs 2 FAILED: RuntimeError The size of tensor a (2048) must match the size of tensor b (2200) at non-singleton dimension 3
gptq bs 2 OK
The replay that fails is GPTNeoAttention(x=[1, 2200, 128], attention_mask=[1, 1, 2200, 2200], position_ids=[1, 2200]), the ln_1 -> q/k/v group.
Suggested fix
Cap the token-row replay length at the model's position limit, for example min(budget, config.max_position_embeddings) (or a per-definition awq_input_feature_aggregation(...)["max_tokens"] for GPTNeoQModel). Alternatively, replay the packed rows per document when the packed length would exceed max_position_embeddings. Either way, a replay failure in the scale search should become an _AWQScaleGroupError so the configured fallback applies instead of aborting the run.
Test that should have caught it
No AWQ test runs GPT-Neo with batch_size > 1. A tiny gpt_neo quantize with batch_size=2 and rows longer than max_position_embeddings / 2 would catch it.
Severity
AWQ crashes on every GPT-Neo checkpoint whenever batch_size > 1 and one batch's non-pad tokens exceed 2048. The same happens if the calibration set has more than 2048 batches. There is no workaround short of batch_size=1.
Confirmed on current main (e75181df5), and fixed in #5120.
I reproduced the reported failure exactly with the real gpt-neo-125m
position geometry (max_position_embeddings=2048, window_size=256,
global/local layers, 2 layers x 128 hidden) and four 1100-token rows:
Run
Result
AWQ, batch_size=1
OK
AWQ, batch_size=2
RuntimeError: The size of tensor a (2048) must match the size of tensor b (2200) at non-singleton dimension 3
GPTQ, batch_size=2
OK
The replay that fails is the ln_1 -> q/k/v group, as described. Two notes
that broadened the fix:
The same fixed causal buffer exists on OpenAI GPT
(self.bias[:, :, :w.size(-2), :w.size(-1)]), where the slice is clipped
without raising. Those rows would have been scored against a silently
truncated causal mask rather than aborting, so the bound is worth having for
correctness even where nothing crashes.
The second half of the suggested fix is needed too. Capping the budget covers
the default policy, but a definition-declared max_tokens, or a module that
bounds its context below the config value, can still produce an over-long
replay. Such a replay now becomes an _AWQScaleGroupError so the configured
plain-quantization fallback applies; fallback=None still propagates it.
Memory, kernel and numerical RuntimeErrors keep propagating unchanged.
The applied fix is the resolve_position_limit(...) cap on the token-row
budget and on a definition-declared max_tokens, using the same config keys
calibration truncation already reads, plus the geometry-error conversion around
the reference replay. Fixes #5085 in #5120.
Activity
ZX-ModelCloud commentedon Nov 18, 2026
Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.
ZX-ModelCloud commentedon Nov 18, 2026
Agent claim released:
agent-aeb7dd7a0ca2finished this issue.Pull request: #5120
User-directed fix of AWQ GPT-Neo batch_size>1 replay crash: reproduce on latest main, then correct scale-search replay budget and fallback
ZX-ModelCloud commentedon Nov 18, 2026
Confirmed on current
main(e75181df5), and fixed in #5120.I reproduced the reported failure exactly with the real
gpt-neo-125mposition geometry (
max_position_embeddings=2048,window_size=256,global/local layers, 2 layers x 128 hidden) and four 1100-token rows:
batch_size=1batch_size=2RuntimeError: The size of tensor a (2048) must match the size of tensor b (2200) at non-singleton dimension 3batch_size=2The replay that fails is the
ln_1 -> q/k/vgroup, as described. Two notesthat broadened the fix:
(
self.bias[:, :, :w.size(-2), :w.size(-1)]), where the slice is clippedwithout raising. Those rows would have been scored against a silently
truncated causal mask rather than aborting, so the bound is worth having for
correctness even where nothing crashes.
the default policy, but a definition-declared
max_tokens, or a module thatbounds its context below the config value, can still produce an over-long
replay. Such a replay now becomes an
_AWQScaleGroupErrorso the configuredplain-quantization fallback applies;
fallback=Nonestill propagates it.Memory, kernel and numerical
RuntimeErrors keep propagating unchanged.The applied fix is the
resolve_position_limit(...)cap on the token-rowbudget and on a definition-declared
max_tokens, using the same config keyscalibration truncation already reads, plus the geometry-error conversion around
the reference replay. Fixes #5085 in #5120.
test(awq): guard #5085's position cap on the capture-time token-row p…
fix(awq): cap packed token-row replay at the model position limit (Mo…