Repository navigation
[Triton/Gluon] fix(gluon): harden paged MQA logits prefetch masks (context_length + block-table capacity bounds) - #5600
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
Two critical safety findings and missing regression coverage remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes non-preshuffle Gluon paged MQA logits addressing for block-sized KV caches.
Changes:
- Converts pool positions into block-table columns and offsets.
- Adds bounds masking for KV and scale prefetches.
- Updates KV and scale addressing logic.
File summaries
| File | Description | Findings |
|---|---|---|
aiter/ops/triton/gluon/pa_mqa_logits.py |
Updates Gluon paged-MQA addressing and prefetch masking. | Critical (2 votes): Guard negative prologue offsets before dereferences. Critical (1 vote): Enforce block_col < max_block_len. Nit (3 votes): Add non-preshuffle regression coverage. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
d052db1 to
6afc358
Compare
|
Thanks for pointing me at #5749! Rebased onto What remains in this PR is the mask hardening that #5749 does not have:
In-contract the window tops out at |
|
I think the formatting is off, can you fix? |
…block-table capacity bounds) The two-step addressing (pool coord -> block column + offset) that this branch originally carried is already on main via ROCm#5749, together with 64-bit addressing, the negative-prologue clamp and the preshuffle tail store -- so this commit drops the duplicate and keeps only the mask hardening that ROCm#5749 does not have: 1. Prologue prefetch masks bound BOTH directions: the existing >= 0 lower bound, plus context_length and the block-table row capacity (max_block_len * KVBlockSize pools) as upper bounds. ROCm#5749 only guards the lower bound, so a first split shorter than ChunkK can prefetch past the row's valid kv_indices columns. 2. In-loop prefetch masks + out-of-window lanes forced to block 0. ROCm#5749's in-loop buffer_load is unmasked and relies solely on the loop bound; with the masks, an out-of-contract context_length (which the wrapper does not validate) can only ever read block 0, never a garbage block id dereferenced into KV_buffer. In-contract the window tops out at split_context_length, so the new bounds never mask a valid lane; they only fire for out-of-contract callers. This also answers the Copilot review's block_col bound finding.
6afc358 to
254aeb3
Compare
|
Fixed — |
Summary
The two-step addressing (pool coord → block column + offset) this PR originally carriedis already onmainvia #5749, together with 64-bit addressing, the negative-prologue clamp and the preshuffle tail store — so after rebasing ontomainthis PR keeps only the mask hardening that #5749 does not have:>= 0); a first split shorter thanChunkKcan prefetch past the row's validkv_indicescolumns. Addedcontext_lengthand the block-table row capacity (max_block_len * KVBlockSizepools) as upper bounds.buffer_loadis unmasked and relies solely on the loop bound; with the masks, an out-of-contractcontext_length(which the wrapper does not validate) can only ever read block 0 — never a garbage block id dereferenced intoKV_buffer.In-contract the window tops out at
split_context_length, so the new bounds never mask a valid lane; they only fire for out-of-contract callers. The capacity bound (pool < max_block_len * KVBlockSize⇒block_col < max_block_len) also answers the Copilot review'sblock_colbound finding.Why this is a follow-up, not a duplicate
gl.maximum(logical, 0))Reproduction context (original bug, now fixed by #5749)
GLM-5.3-Flash, 8× MI308X (gfx942), TP4, fp8 e4m3 KV, page 64,
index_kpool=4: any request with KV length > 16384 tokens faulted deterministically on the first decode step after prefill (4-rankMemory access fault), pinned to_gluon_deepgemm_fp8_paged_mqa_logitsviaAMD_LOG_LEVEL=3+HIP_LAUNCH_BLOCKING=1. The addressing fix for that is #5749's; what this PR adds on top is defense-in-depth for the mask path.Notes for reviewers
op_tests/test_pa_mqa_logits_offset.py(the harness [Triton/Gluon] [Bugfix] [Perf] Support page size 8 in paged MQA logits on both layouts, and fix large KV offsets #5749 introduced) with an out-of-contractcontext_lengthcase if maintainers want regression coverage for the masks specifically.