Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
jcaraban
left a comment
There was a problem hiding this comment.
Rechecked a032997. The split keeps the backing-storage producer fix separate from launcher validation, and I found no new correctness blocker in the source review. The backing allocation, zeroed tail and full-storage as_strided approach address the earlier compiled-storage concern.
One documentation-rule follow-up is inline. Please also coordinate landing with #8683: both PRs change the hd128 final-plane backing, and their sol_jensen_cap changes conflict when combined. Keep the hd256 repack branch, use _sol_attn_pad_scale_rows only for the non-repack branch, and preserve the and not k_packed guard in sol_tilt_planes.
Validation: the seven CPU source/contract checks across these revisions pass. I have not independently rerun the GPU or torch.compile paths; the available test nodes were occupied. This is advisory feedback, not an approval.
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
The non-tilt regression test still accepts tile-only backing, leaving zeroed lookahead rows for both scale tensors unchecked in eager and compiled runs, including full final tiles.
1 open issue
What changed in this PR
This PR prevents out-of-allocation reads in gfx950 MXFP8 Sol-Attn by adding backing rows to pooled E8M0 scales, including the Jensen variance and tilt paths.
Changes:
- Share scale allocation logic that adds zeroed lookahead rows and MXFP4 slack.
- Add lookahead rows after the final tilt scale plane and preserve full backing allocations under
torch.compile. - Extend tilt tests to check zeroed lookahead for both partial and full final tiles.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_sol_tilt.py |
Checks lookahead backing for partial and full scale tiles. |
aiter/ops/triton/attention/utils.py |
Adds shared lookahead-backed pooled scale allocation. |
aiter/ops/triton/attention/sol_tilt.py |
Reuses the shared helper and backs the final tilt scale plane. |
aiter/ops/mha_v4_quant.py |
Uses a whole-allocation view to preserve slack under compilation. |
Review effort: Balanced
5274fbf to
f28d610
Compare
…hey are made The 64x64 MXFP8 Sol-Attn kernel (fmha_fwd_hd128_mxfp8_sol_64x64_gfx950) reads its pooled E8M0 K scales, and the Jensen variance's, past their last 128-row tile and on into the next tile's rows, as it reads K's own. sol_prepare and sol_jensen_cap padded them only to that tile, and sol_tilt_planes stacks the tilt's K-scale planes behind mean_k_scale with nothing past the last one, so the read faulted whenever the allocation ended at an unmapped page. The bytes past the end are read but not used. - utils.py: _sol_attn_pad_scale_rows copies a pooled scale into block_scale_storage, with MHA_V4_KV_SCALE_LOOKAHEAD_ROWS zeroed rows and the MXFP4 K slack past its last tile. sol_prepare and sol_jensen_cap use it, in place of sol_tilt's _backed_scale_copy. - sol_tilt.py: _stack_planes takes tail_rows, and the MXFP8 K-scale stack carries the lookahead rows behind its last plane. - mha_v4_quant.py, sol_tilt.py: block_scale_storage and _stack_planes view their whole allocation. torch.compile cut a slice that is written through down to the slice's own size, which dropped the rows behind it. - test_sol_tilt: the MXFP8 K-scale stack test covers a full last tile too, and checks the zeroed lookahead rows behind the last plane. Signed-off-by: Niko Säkkinen <[email protected]>
Review feedback: the docstring is now two sentences, as the repo's comment rule asks. The backing-storage explanation stays in the PR description. Signed-off-by: Niko Säkkinen <[email protected]>
test_pooled_scales_run_zeroed_to_a_whole_scale_tile now requires MHA_V4_KV_SCALE_LOOKAHEAD_ROWS zeroed rows behind both mean_k_scale and mean_k_var_scale, eager and compiled. It also covers an 8192-token K, where the scale fills a whole 128-row tile at kv_tile 64. Signed-off-by: Niko Säkkinen <[email protected]>
f28d610 to
f04ed99
Compare

Summary
The 64x64 MXFP8 Sol-Attn kernel (
fmha_fwd_hd128_mxfp8_sol_64x64_gfx950) reads its pooled E8M0 K scales, and the Jensen variance's, past their last 128-row tile and into the next tile's rows, as it reads K's own.sol_prepareandsol_jensen_cappadded them only to that tile, andsol_tilt_planesstacks the tilt's K-scale planes behindmean_k_scalewith nothing past the last plane. So the read faulted whenever the allocation ended at an unmapped page. The bytes past the end are read but not used, so this is a fault, not a wrong result.This fixes it where the scales are made, so the tilt and torch.compile paths are covered too. A follow-up PR makes the launch refuse a scale without the backing.
Motivation
Without the backing rows, the kernel reads past the end of the scale allocation and faults on an unmapped page. Padding to the last tile is not enough, because the kernel reads past it. The tilt and torch.compile paths build the scales differently, so the fix goes where the scales are made.
Changes
utils.py:_sol_attn_pad_scale_rowscopies a pooled scale intoblock_scale_storage, withMHA_V4_KV_SCALE_LOOKAHEAD_ROWS(256) zeroed rows and the MXFP4 K slack past its last tile.sol_prepareandsol_jensen_capshare it;sol_tilt._backed_scale_copyis removed.sol_tilt.py:_stack_planestakestail_rows, and the MXFP8 K-scale stack carries the lookahead rows behind its last plane.mha_v4_quant.py,sol_tilt.py:block_scale_storageand_stack_planesview their whole allocation. torch.compile cut a written-through slice down to the slice's own size, which dropped the rows behind it.Performance (if applicable)
Not applicable. This is a fault fix on scale allocation and makes no performance claim. Not measured.
Testing
Results on MI355X (gfx950):
op_tests/triton_tests/attention/test_sol_tilt.pyop_tests/test_mha_v4_sparse.pyop_tests/test_mha_v4.pyThe MXFP8 K-scale stack test now covers a full last tile too, and checks the zeroed lookahead rows behind the last plane. The follow-up PR's new 64x64 checks pass on this PR alone: tilt at ranks 2 and 8, eager and compiled backing, and each allocation placed against an unmapped page.
Documentation
_sol_attn_pad_scale_rowsinaiter/ops/triton/attention/utils.pyDependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
f04ed99
Behavior and intent
The pooled E8M0 K scales of the 64x64 MXFP8 Sol-Attn row, and the Jensen variance's, now have
MHA_V4_KV_SCALE_LOOKAHEAD_ROWSzeroed rows behind their last tile.sol_prepare,sol_jensen_capand the tilt's K-scale planes back them where they are made. The kernel reads those rows as it reads K's own. Before this, nothing supplied them, so a read at the end of an allocation on an unmapped page faulted. The bytes past the end are unused, so this fixes a fault, not a wrong result.Validation and unverified scope
op_tests/triton_tests/attention/test_sol_prepare.py95 passed, including the new 8192-token case. black 26.10.1 and ruff 0.16.0 pass on the changed file.op_tests/triton_tests/attention/test_sol_tilt.py95 passed.test_sol_prepare.pycase: the lookahead assertion fails, for exampleassert 896 >= (368 * 8).test_sol_tilt.py2 failed, 93 passed. The two failures are the new lookahead assertion for padded-tile and full-tile.test_mha_v4_sparse.py609 ran, 5 skipped, 0 failed;test_mha_v4.py357 ran, 0 failed.PR-specific question
Yes, it fails before this PR.
test_tilt_planes_pad_each_mxfp8_k_scale_plane_to_a_whole_scale_tile(padded-tile, full-tile) fails on main at the lookahead assertion. The other 93 tests intest_sol_tilt.pypass on main, so none of them covers those rows. The newtest_sol_prepare.pycheck fails at its lookahead assertion on the merge-base (see Validation).Changed op tests
op_tests/triton_tests/attention/test_sol_tilt.py:test_tilt_planes_pad_each_mxfp8_k_scale_plane_to_a_whole_scale_tile(padded-tile, full-tile) checks that each MXFP8 K-scale plane is zeroed to a whole 128-row tile, and that the lookahead rows behind the last plane are backed and zeroed. It fails on main, and the other 93 tests in the file do not cover these rows.op_tests/triton_tests/attention/test_sol_prepare.py:test_pooled_scales_run_zeroed_to_a_whole_scale_tile(eager and compiled, four sequence lengths) now also requiresMHA_V4_KV_SCALE_LOOKAHEAD_ROWSzeroed rows behind bothmean_k_scaleandmean_k_var_scale, and adds an 8192-token case where the scale fills a whole 128-row tile atkv_tile64. It is the only K-scale lookahead check on the prepare path. The V-scale slack check in the same file covers a different scale.