Repository navigation
feat(hip-kernel-provider): port the rocKE unified-attention mask band and split-KV LSE to C++ - #14759
Merged
amd-khushbu merged 1 commit intoOct 30, 2026
Conversation
… and split-KV LSE to C++ JIRA ID : AICK-2712 ## Summary This is PR 9, the last of a stack of 9 that brings the rocKE C++ unified-attention engine to parity with Python (see the stack below). It sits on PR 8. It ports the two remaining features Python has and C++ did not: the top-left / right-bound mask band on gfx950 (tiled 2D and 3D), and the optional split-KV LSE output on both arches (develop's #13955). Both were rejected by the C++ gates as "not ported"; those rejects are removed, so C++ now admits and builds the same problems as Python. PR 7's `emit_lse` stopgap is replaced. ## Changes All paths are under `dnn-providers/hip-kernel-provider/rocke/`. - **Split-KV LSE output (gfx942 and gfx950).** - The reduce spec gains `emit_lse` (default off): "lse" kernel-name suffix, a trailing `lse_ptr` param, and a lane-0 FP32 natural-log LSE store after the output pass. - New C twin of `_lse_store` (`lse_store` / `natural_lse_from_log2_stats`), shared by both reduce builders. - The C problem gains `emit_lse`; the tiled 2D and 3D gates run Python's `_reject_lse` first, with its exact messages (2D path, non-split-KV arch, sinks). - The problem bindings read `emit_lse` instead of refusing it (PR 7's stopgap). - **Mask band on gfx950 tiled 2D.** - The shared tiled-2D spec gains `causal_top_left` and `right_bound` (defaults off / 0); the validator raises Python's errors with the same text; the kernel name gains the `tl` / `rbu` / `rb<R>` tokens. - Body: top-left pins `context_len` to 0; the right bound feeds `max_seq_prefix_len`, the sliding-window tile range and the per-element mask on the transposed 32x32, MFMA 32x32 and 16x16 paths, the transposed mask-limit path (`valid_tail`), and the D256 mask-phase-split peel. - **Mask band on gfx950 tiled 3D** (split-KV segment kernel): same fields, validation, name tokens and body changes. The reduce kernel is mask-agnostic. - **Routing.** Spec-from-problem copies the band fields (2D before the D256 fast-route override, as Python does); the 2D and 3D gates drop their "masks are not ported to C++ yet" rejects; the problem hooks, the scalar binding (the scalar C++ builder already had the band) and the spec dicts carry both fields. - **gfx942 is unchanged.** Python's gfx942 specs have no band fields and its gate rejects non-default masks; C++ keeps the gate reject, and its gfx942 validators reject a hand-built spec with a band (C++-only message, since Python cannot express one). - **Cleanup:** the unused gfx950 tiled-2D ctx prologue copy (`rocke_gfx950_attn2d_build_ctx_init`) is removed; the public entry builds through its own init, and the copy had fallen behind it. - `known_gaps.md` drops the LSE section. ## Test plan - [x] New parity configs: gfx950 tiled 2D 76-85 (band on every mask path, incl. mask-limit and the D256 fast path), gfx950 tiled 3D 21-23 (band, with sinks and fp8 K/V), and two `emit_lse` configs per arch in the tiled 3D families; golden entries blessed for those only, no existing entry moved - [x] `attention_unified_routing_test.cpp`: the gfx950 2D and 3D gates admit top-left and rb5 problems - [x] `test_attention_routing_cpp_parity.py`: LSE problems (with sinks, a non-default mask, fp8) in the gate grid, on every arch - [x] Selector parity matrix: four band problems, including a D256 bf16 prefill with `right_bound=-1` - [x] Binding tests: band round-trip, gfx950 validator messages, gfx942 reject; a scalar top-left rb5 problem lowers byte-identical to Python - [x] CTest, pybind build: 39/39 - [x] Byte-identity gate GREEN at llvm20, llvm22, llvm23 and llvm24 - [x] Golden check (ll ×4 + ir canonical): no unblessed change, nothing missing - [x] pre-commit's black (25.12.0) and clang-format (18) hooks, run by hand on every file this PR changes: clean (pre-commit itself is not installed locally) - [ ] Not run on a GPU: the LSE reduce and the band emit the same bytes as Python's, which the Python numeric tests cover (#13955 for LSE) Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Oct 30, 2026
Merged
feat(hip-kernel-provider): bring the rocKE C++ unified-attention engine to parity with Python
#14522
Open
Base automatically changed from
users/khuagarw/rocke/aick-2712-cpp-parity-8-i64-ring
to
users/khuagarw/rocke/aick-2712-cpp-parity-1-stopgaps
October 30, 2026 16:39
amd-khushbu
merged commit Oct 30, 2026
8032a6f
into
users/khuagarw/rocke/aick-2712-cpp-parity-1-stopgaps
74 of 82 checks passed
amd-khushbu
deleted the
users/khuagarw/rocke/aick-2712-cpp-parity-9-mask-band-lse
branch
October 30, 2026 16:39
Contributor
Author
|
This stack is now combined into one PR, #14522, so it can be reviewed and merged as one change. GitHub shows this PR as merged because its commit is now on #14522's branch; nothing has gone into develop. This PR's change is one commit there, unchanged. Open review comments from here are listed in #14522's description and will be answered there. |
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.
JIRA ID : AICK-2712
Summary
This is PR 9, the last of a stack of 9 that brings the rocKE C++ unified-attention engine to parity with Python (see the stack below). It sits on PR 8.
It ports the two remaining features Python has and C++ did not: the top-left / right-bound mask band on gfx950 (tiled 2D and 3D), and the optional split-KV LSE output on both arches (develop's #13955). Both were rejected by the C++ gates as "not ported"; those rejects are removed, so C++ now admits and builds the same problems as Python. PR 7's
emit_lsestopgap is replaced.Changes
All paths are under
dnn-providers/hip-kernel-provider/rocke/.emit_lse(default off): "lse" kernel-name suffix, a trailinglse_ptrparam, and a lane-0 FP32 natural-log LSE store after the output pass._lse_store(lse_store/natural_lse_from_log2_stats), shared by both reduce builders.emit_lse; the tiled 2D and 3D gates run Python's_reject_lsefirst, with its exact messages (2D path, non-split-KV arch, sinks).emit_lseinstead of refusing it (PR 7's stopgap).causal_top_leftandright_bound(defaults off / 0); the validator raises Python's errors with the same text; the kernel name gains thetl/rbu/rb<R>tokens.context_lento 0; the right bound feedsmax_seq_prefix_len, the sliding-window tile range and the per-element mask on the transposed 32x32, MFMA 32x32 and 16x16 paths, the transposed mask-limit path (valid_tail), and the D256 mask-phase-split peel.rocke_gfx950_attn2d_build_ctx_init) is removed; the public entry builds through its own init, and the copy had fallen behind it.known_gaps.mddrops the LSE section.Stack
Each PR is based on the one before it. Review from 1 upward; each diff shows only its own slice.
Test plan
emit_lseconfigs per arch in the tiled 3D families; golden entries blessed for those only, no existing entry movedattention_unified_routing_test.cpp: the gfx950 2D and 3D gates admit top-left and rb5 problemstest_attention_routing_cpp_parity.py: LSE problems (with sinks, a non-default mask, fp8) in the gate grid, on every archright_bound=-1🤖 Generated with Claude Code