Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ead2439
test(rocke): C++/Python lowerer byte-identity gate for attention back…
afagaj Oct 31, 2026
cd68840
test(rocke): C++ HIP lowering ctest for tile.buffer_load (AICK-2762)
afagaj Oct 31, 2026
1f12344
feat(rocke): C++ twins of the backward aux kernels and addr/worklist/…
afagaj Oct 25, 2026
dab2195
feat(rocke): C++ twin of the attention band helpers (AICK-2762)
afagaj Oct 25, 2026
c4c0dc0
feat(rocke): C++ twin of the backward spec, caps, tiles and LDS plann…
afagaj Oct 25, 2026
589d900
feat(rocke): C++ twins of the backward fragment and block-GEMM helper…
afagaj Oct 25, 2026
f74191a
feat(rocke): C++ twins of the backward counted, valu, sinks and paged…
afagaj Oct 25, 2026
08ae23e
refactor(rocke): remove duplicated attention backward C++ helpers (AI…
afagaj Oct 25, 2026
4d4b71c
feat(rocke): C++ twin of the backward stage scheduler (AICK-2762)
afagaj Oct 25, 2026
e7f6005
feat(rocke): C++ twin of the backward tile-step body and prefetch rin…
afagaj Oct 25, 2026
dd36d5a
feat(rocke): C++ twin of the backward main-kernel builder (AICK-2762)
afagaj Oct 25, 2026
d1d101d
feat(rocke): C++ twin of the split dQ kernel builder (AICK-2762)
afagaj Oct 25, 2026
fbfa77c
feat(rocke): C++ twin of the dense backward kernels (AICK-2762)
afagaj Oct 25, 2026
d42bbf3
feat(rocke): C++ twin of the unified paged backward main kernel (AICK…
afagaj Oct 25, 2026
c3ebbed
test(rocke): CI check of the attention backward C++ twins against the…
afagaj Oct 31, 2026
94ea1c1
docs(rocke): describe the attention backward C++ twins (AICK-2762)
afagaj Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ test_categories:
- "rocke_portable_ir_dom_decoders"
- "rocke_portable_ir_recipe_vm_replay"
- "rocke_qk_scale_spec_validate"
- "rocke_attention_bwd_spec_reinit"
- "rocke_attention_bwd_dma_slab_int64"
- "rocke_tensor_view_buffer_errors"
- "rocke_mfma_atom_lane_to_output"
- "rocke_scf_for_name_reuse"
Expand All @@ -85,13 +87,15 @@ test_categories:
- "rocke_mx_scale_decode"
- "rocke_buffer_rsrc_hip"
- "rocke_attention_dense_spec"
- "rocke_buffer_load_hip"
- "rocke_tiled_attention_2d_reentrancy"
- "rocke_tiled_attention_entry_guards"
- "rocke_unified_attention_scalar_lower_to_llvm"
- "rocke_python_import_smoke"
- "rocke_golden_static"
- "rocke_differential_golden_ll"
- "rocke_differential_golden_canonical"
- "rocke_native_golden_ll"
Comment thread
afagaj marked this conversation as resolved.
Resolved
- "rocke_library_conv_pytest"
- "rocke_library_attention_cpu_pytest"
- "rocke_library_attention_cache_key_pytest"
Expand Down Expand Up @@ -149,6 +153,8 @@ test_categories:
- "rocke_portable_ir_dom_decoders"
- "rocke_portable_ir_recipe_vm_replay"
- "rocke_qk_scale_spec_validate"
- "rocke_attention_bwd_spec_reinit"
- "rocke_attention_bwd_dma_slab_int64"
- "rocke_tensor_view_buffer_errors"
- "rocke_mfma_atom_lane_to_output"
- "rocke_scf_for_name_reuse"
Expand All @@ -158,13 +164,15 @@ test_categories:
- "rocke_mx_scale_decode"
- "rocke_buffer_rsrc_hip"
- "rocke_attention_dense_spec"
- "rocke_buffer_load_hip"
- "rocke_tiled_attention_2d_reentrancy"
- "rocke_tiled_attention_entry_guards"
- "rocke_unified_attention_scalar_lower_to_llvm"
- "rocke_python_import_smoke"
- "rocke_golden_static"
- "rocke_differential_golden_ll"
- "rocke_differential_golden_canonical"
- "rocke_native_golden_ll"
- "rocke_library_conv_pytest"
- "rocke_library_attention_cpu_pytest"
- "rocke_library_attention_cache_key_pytest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,9 @@ without one, the architecture's full-part CU count.

`attention_bwd/` is the dispatcher of the SDPA backward families (general,
dense, unified; design doc `platform/dsl_docs/instances/attention_bwd.md`,
sections 8 and 9). It is Python-only: the C++ engine has no backward (design
doc 0.3, the C++-engine waiver).
sections 8 and 9). It is Python-only. The C++ engine has twins of the backward
kernel builders, but not of this registry, routing, tuning or the recorded
refusal tables (design doc 0.3).

* **Knob registry** (`tuning_common.py`). Every `AttnBwdSpec` tuning field,
every plan runtime value (`RUNTIME_KNOBS`), every prep / convert tuning
Expand Down Expand Up @@ -596,13 +597,14 @@ doc 0.3, the C++-engine waiver).

**Production status: dormant.** Like the forward registry, the backward
dispatcher is not load-bearing for production yet: no provider calls it (the
hip-kernel-provider serves rocKE kernels through the C++ engine, which has no
backward), so hipDNN backward requests go to the provider's other engines.
hip-kernel-provider serves rocKE kernels through the C++ engine, which has the
backward kernel builders but not this dispatcher), so hipDNN backward requests
go to the provider's other engines.
Its callers are the CPU tests (`tests/dispatch/attention_bwd/test_registry.py`,
`test_serving_policy.py`, which plans every accepted case with the shipped
policy and no override). Follow-up: a provider backward
engine that calls `run_attention_bwd` (with the C++ port of the backward, or a
Python-serving path).
engine that calls `run_attention_bwd` (a C++ port of this routing on top of the
kernel builder twins, or a Python-serving path).

`tests/test_attention_bwd_dispatch.py` checks that every accepted case-table
request gets exactly one family and never the dense one when ineligible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""Address generators for the attention backward kernels.

Family glue for the backward kernels (prep, main, convert and the paged
roles): Python-only, no C++ twin. Everything here emits integer IR through
roles). C++ twin:
``platform/cpp/include/rocke/helper_rocke.instances.common._attention_bwd_addr.h``,
which lists what is not ported yet. Everything here emits integer IR through
the builder it is handed and only calls integer / pointer / load / store
methods of ``IRBuilder``, so the same code can be evaluated with a
duck-typed integer builder on the host (that is how the unit tests check the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

"""Inverse band, tile classifier and mask policies of the attention backward.

Family glue for the backward kernels (Python-only, no C++ twin). The forward
Family glue for the backward kernels. The C++ twin of everything below but
``HostInt`` (no C object) is
``helper_rocke.instances.common._attention_bwd_band.h``; the pair
``tests/parity/attention_bwd_band_emit`` holds the two byte-identical. The forward
band (``rocke.helpers.attention_band``) is imported, never edited: the keep
rule is the frozen one,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""Shared inner body of the attention backward kernels (dQ, dK, dV).

Family glue for the backward kernels (Python-only, no C++ twin; packs pin
Family glue for the backward kernels (C++ twin:
``helper_rocke.instances.common._attention_bwd_body.h``, byte-identical by
``tests/parity/attention_bwd_body_emit``; the packs still pin
``ROCKE_BACKEND=python``). One :class:`BwdTileStep` emits the work of one q
step (``kM0`` query rows of one query head) against the CTA's resident key
tile (``kN0`` keys), on a multi-wave CTA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""Counted in-loop waits of the attention backward q step (``loop_sync = "counted"``).

Family glue for the backward kernels (Python-only, no C++ twin). Under
Family glue for the backward kernels (C++ twin:
``helper_rocke.instances.common._attention_bwd_counted.h``, byte-identical by
``tests/parity/attention_bwd_counted_emit``). Under
``loop_sync = "counted"`` the q step changes its issue order and the wait of its
in-loop barriers; the math, the LDS buffers and every accumulator chain stay
those of the default step, so dK / dV and every dQ partial are bit for bit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""Body of the split dQ kernel of the attention backward (Q-parallel, no atomics).

Family glue for the backward kernels (Python-only, no C++ twin; packs pin
Family glue for the backward kernels (C++ twin:
``helper_rocke.instances.common._attention_bwd_dqbody.h``, byte-identical by
``tests/parity/attention_bwd_dq_emit``; the packs still pin
``ROCKE_BACKEND=python``). The second orientation of the backward tile step:
one CTA owns ``kM0`` query rows (of one query head, or of ``G`` query heads
that share one K head and one V head, packed onto the rows) and walks the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""Paged address generator of the unified attention backward main kernel.

Family glue for the backward kernels (Python-only, no C++ twin). Like
Family glue for the backward kernels (C++ twin:
``helper_rocke.instances.common._attention_bwd_paged.h``, byte-identical by
``tests/parity/attention_bwd_paged_emit``). Like
:mod:`._attention_bwd_addr`, everything here emits integer / pointer / load /
store IR through the builder it is handed.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""Q / dO prefetch ring of the attention backward q loop.

Family glue for the backward main kernel (Python-only, no C++ twin; packs pin
Family glue for the backward main kernel (C++ twin:
``helper_rocke.instances.common._attention_bwd_ring.h``, byte-identical by
``tests/parity/attention_bwd_body_emit``; the packs still pin
``ROCKE_BACKEND=python``). Two knobs of the spec select it:

* ``ring_depth`` ``R`` in ``{1, 2, 3}``: Q, dO and the lse2 / Dsum rows of a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""dQ sinks of the attention backward tile step.

Family glue for the backward kernels (Python-only, no C++ twin). The tile
Family glue for the backward kernels (C++ twin:
``helper_rocke.instances.common._attention_bwd_sinks.h``, byte-identical by
``tests/parity/attention_bwd_sinks_emit``). The tile
step hands each q step's partial ``dQ = dS K`` fragment to a sink:

sink.begin_head(b, h) # i64 rebase when the head changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

"""Softmax-gradient VALU levers of the attention backward main kernel.

Family glue (Python-only, like the rest of the backward body). Each lever is a
Family glue (C++ twin: ``helper_rocke.instances.common._attention_bwd_valu.h``,
byte-identical by ``tests/parity/attention_bwd_valu_emit``). Each lever is a
defaulted :class:`~kernels.common.attention_bwd.AttnBwdSpec` field whose
default emits the shipped code; this module holds their emitters so the body
keeps one small hook per lever.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

"""CTA work decode of the KV-parallel attention backward main kernels.

Family glue for the backward kernels (Python-only, no C++ twin). Everything
Family glue for the backward kernels. C++ twin:
``platform/cpp/include/rocke/helper_rocke.instances.common._attention_bwd_worklist.h``,
which lists what stays Python (the host-only helpers). Everything
here emits CTA-uniform integer IR through the builder it is handed and only
calls integer methods of ``IRBuilder``, so the duck-typed host evaluator of the
tests can execute it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

"""Shell of the dense SDPA backward main kernel (family glue, Python-only).
"""Shell of the dense SDPA backward main kernel (family glue).

C++ twin: ``helper_rocke.instances.common._attention_dense_bwd_shell.h``,
byte-identical by ``tests/parity/attention_dense_bwd_main_emit`` and
``tests/parity/attention_dense_bwd_dq_emit``.

The dense backward runs the shared backward body of the layout-general family
(:class:`~kernels.common._attention_bwd_body.BwdTileStep`, the dQ sink, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

"""Shared prep / convert kernels of the attention backward (all families).

Python-only family glue (no C++ twin; packs pin ``ROCKE_BACKEND=python``).
One spec, :class:`AttnBwdAuxSpec`, drives four builders:
Family glue with a byte-identical C++ twin
(``platform/cpp/include/rocke/instance_attention_bwd_aux.h``; parity pair
``tests/parity/attention_bwd_aux_emit.{py,c}``). The packs still pin
``ROCKE_BACKEND=python``. One spec, :class:`AttnBwdAuxSpec`, drives four builders:

* ``build_attn_bwd_prep``: per query row ``lse2 = lse * LOG2E`` and
``Dsum = rowsum(dO * O)`` (fp32), both gated on one
Expand Down
Loading
Loading