Skip to content

AG-GEMM copy engine: pre-bind the submit and trigger kernel launches - #662

Open
dsidler wants to merge 1 commit into
dev/dasidler/ag-gemm-ce-prepostfrom
dev/dasidler/ag-gemm-ce-prebound
Open

dsidler wants to merge 1 commit into
dev/dasidler/ag-gemm-ce-prepostfrom
dev/dasidler/ag-gemm-ce-prebound

Conversation

@dsidler

@dsidler dsidler commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #661 (base dev/dasidler/ag-gemm-ce-prepost).

Summary

Every launch through JITFunction.run binds and re-specializes all arguments in Python before the kernel is enqueued. That host time sits directly in front of the GEMM launch while the GPU idles. It is longest for the 16-argument submit kernel: 18.2 µs per launch, vs 9.5 µs for the 1-argument trigger kernel. Measured on 8× MI300X at M=1024, with the GPU kept busy so launches only enqueue.

_launch_prebound compiles on the first call and afterwards calls the CompiledKernel's launcher directly. The launcher is cached on the workspace (FusedWorkspace.launch_cache, cleared in clear()).

  • The cache key covers everything the specialization depends on that can change between calls on one workspace: A_sharded's dtype and 16-byte alignment, M, K_local and the strides. All other arguments are workspace buffers.
  • The unused flag_iteration kernel argument is dropped, since it changed on every call. The op's public parameter stays.

Host launch time:

  • submit kernel: 18.2 → 7.7 µs
  • trigger kernel: 9.5 → 6.2 µs

End-to-end benchmark differences at M=1024 are within run-to-run drift.

Tests

tests/ops/test_all_gather_matmul_copy_engine.py also checks that the second call on a workspace reused the first call's launcher.

  • 2 ranks: 6 passed, 2 skipped
  • 8 ranks: 3 passed, 5 skipped

🤖 Generated with Claude Code

Every launch through JITFunction.run binds and re-specializes all arguments
in Python before the kernel is enqueued. On the device-initiated path that
host time sits directly in front of the GEMM launch while the GPU idles, and
it is longer for the 16-argument submit kernel: 18.2 us per launch vs 9.5 us
for the 1-argument trigger kernel (8 GPUs, M=1024, GPU kept busy so launches
only enqueue).

_launch_prebound compiles on the first call and afterwards calls the
CompiledKernel's launcher directly, cached on the workspace
(FusedWorkspace.launch_cache, cleared in clear()). The cache key covers
everything the specialization depends on that can change between calls on
one workspace (A_sharded's dtype and 16-byte alignment, M, K_local and the
strides); all other arguments are workspace buffers. The unused
flag_iteration kernel argument is dropped (it changed every call); the op's
public parameter stays.

Host launch: submit kernel 18.2 -> 7.7 us, trigger kernel 9.5 -> 6.2 us.
The op test now also checks that the second call on a workspace reused the
first call's launcher.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added in-progress We are working on it iris Iris project issue labels Nov 25, 2026
@dsidler
dsidler added this pull request to stack #663 November 25, 2026 19:04

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