Skip to content

AG-GEMM copy engine: prepost host transfers and release them with a trigger kernel - #661

Open
dsidler wants to merge 1 commit into
dev/dasidler/sdma-benchmarkfrom
dev/dasidler/ag-gemm-ce-prepost
Open

dsidler wants to merge 1 commit into
dev/dasidler/sdma-benchmarkfrom
dev/dasidler/ag-gemm-ce-prepost

Conversation

@dsidler

@dsidler dsidler commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #496 (base dev/dasidler/sdma-benchmark).

Summary

The host-initiated variant of all_gather_matmul_copy_engine launched the GEMM and then submitted every (batch, rank) transfer from Python. The transfers started only once the host had queued them, so the submission cost sat on the critical path.

The host transfers are now queued behind a trigger:

  • The first transfer on each destination queue polls workspace.trigger_flag until it reaches the call's generation.
  • A one-workgroup _trigger_kernel bumps the flag right before the GEMM.
  • all_gather_matmul_copy_engine_prepost_transfers() queues one launch's transfers ahead of time.
  • The op takes copy_engine_transfers_preposted=True to use them. Without it, the op queues the transfers itself right after the trigger and GEMM launches, which keeps the previous behavior.

This is the unmanaged form of the triggered plans on main: there is no queue-ledger bookkeeping, and each prepost must be paired with exactly one call.

Benchmark

all_gather_matmul_copy_engine_host_prepost queues the transfers in the untimed preamble. 8× MI300X, N=3584, K=8192:

M host host_prepost device
1024 0.560 ms 0.469 ms 0.469 ms
4096 1.012 ms 0.928 ms 0.952 ms

One run of 100 iterations per variant; run-to-run drift at M=1024 is ~±0.05 ms.

Tests

tests/ops/test_all_gather_matmul_copy_engine.py gains a prepost parameter and calls the op twice per workspace. This covers the generation pairing and the GEMM's wait counters.

  • 2 ranks: 6 passed, 2 skipped (prepost + device-initiated is invalid)
  • 8 ranks: 3 passed, 5 skipped (same shape skips as before)

Run with the pinned tritonBLAS b9baf7d and rocm-xio 97fa1663.

🤖 Generated with Claude Code

…rigger kernel

The host-initiated variant launched the GEMM and then submitted every
(batch, rank) transfer from Python, so the transfers started only after the
host had queued them and the submission cost sat on the critical path.

Now the host transfers are queued behind a trigger: the first transfer on
each destination queue polls workspace.trigger_flag until it reaches the
call's generation, and a one-workgroup _trigger_kernel bumps the flag right
before the GEMM. all_gather_matmul_copy_engine_prepost_transfers() queues
one launch's transfers ahead of time; the op takes
copy_engine_transfers_preposted=True to use them. Without it the op queues
the transfers itself right after the trigger and GEMM launches, which keeps
the previous behavior.

Adds the all_gather_matmul_copy_engine_host_prepost benchmark (transfers
queued in the untimed preamble) and runs the op test twice per workspace,
with and without preposting, to cover the generation pairing and the GEMM's
wait counters.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-progress We are working on it iris Iris project issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant