Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
d44394c
wip back of sdma integration
dsidler Nov 6, 2025
c50e761
Apply Ruff auto-fixes
github-actions[bot] Nov 6, 2025
2f7bc5e
message passing example working
dsidler Nov 6, 2025
5e38fd6
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Nov 6, 2025
759f662
Apply Ruff auto-fixes
github-actions[bot] Nov 6, 2025
ad7769d
update put example to use ce
dsidler Nov 7, 2025
b8862cc
update api calls
dsidler Nov 7, 2025
75c5626
update submodule
dsidler Nov 7, 2025
2b228ab
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Nov 7, 2025
e3aef16
fix merge
dsidler Nov 7, 2025
df04547
Apply Ruff auto-fixes
github-actions[bot] Nov 7, 2025
c5e4735
wip fixed wrap into ring when placing
dsidler Dec 5, 2025
ea17dd6
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Dec 5, 2025
5362318
to_rank 7 working
dsidler Dec 5, 2025
a6b1d40
Apply Ruff auto-fixes
github-actions[bot] Dec 10, 2025
224511f
Merge branch 'main' into dev/dasidler/sdma
dsidler Jan 14, 2026
400b5b7
use triton commit with fix
dsidler Jan 14, 2026
d06cb72
Apply Ruff auto-fixes
github-actions[bot] Jan 14, 2026
b2e358b
send to all ranks but always same stride
dsidler Jan 20, 2026
b245899
update submodule
dsidler Jan 20, 2026
0e7fbd6
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Jan 20, 2026
1ee4c58
use 32B copy packets workaround
dsidler Jan 30, 2026
1c384c3
submodule update
dsidler Jan 30, 2026
595423d
Add benchmark capabilities for ops.
neoblizz Feb 3, 2026
8c965a1
Merge branch 'main' into neoblizz/iris-xops-perf
neoblizz Feb 7, 2026
ef227b0
Merge conflicts.
neoblizz Feb 7, 2026
f132ceb
Up the tritonBLAS commit.
neoblizz Feb 7, 2026
1628a61
...
neoblizz Feb 10, 2026
c26e872
Apply Ruff auto-fixes
github-actions[bot] Feb 10, 2026
3d4c7d7
Fix load vectorization and transpose config
ryanswann-amd Feb 11, 2026
5b02211
Apply Ruff auto-fixes
github-actions[bot] Feb 11, 2026
4c3b3f4
Add HBM buffered version
ryanswann-amd Feb 11, 2026
a301392
Merge branch 'ryaswann/iris_xops_perf' of github.com:ROCm/iris into r…
ryanswann-amd Feb 11, 2026
1f3b9ef
Apply Ruff auto-fixes
github-actions[bot] Feb 11, 2026
45288ff
Use workgroup specialized variant
ryanswann-amd Feb 13, 2026
b2aadcd
Apply Ruff auto-fixes
github-actions[bot] Feb 13, 2026
7b2321e
Update hbm buffered all gather matmul
ryanswann-amd Feb 16, 2026
a4d845f
Merge branch 'ryaswann/iris_xops_perf' of github.com:ROCm/iris into r…
ryanswann-amd Feb 16, 2026
9692222
Apply Ruff auto-fixes
github-actions[bot] Feb 16, 2026
44ebc97
Add tracing
ryanswann-amd Feb 16, 2026
0c2842e
Merge branch 'ryaswann/iris_xops_perf' of github.com:ROCm/iris into r…
ryanswann-amd Feb 17, 2026
11d017a
Apply Ruff auto-fixes
github-actions[bot] Feb 17, 2026
ace40d0
Add stages to all_gather_matmul_hbm_buffer
ryanswann-amd Feb 17, 2026
950c3a0
Merge branch 'ryaswann/iris_xops_perf' of github.com:ROCm/iris into r…
ryanswann-amd Feb 17, 2026
f7612bd
Apply Ruff auto-fixes
github-actions[bot] Feb 17, 2026
51bccb5
Updates to benchmark and kernel
ryanswann-amd Feb 17, 2026
9b71523
Merge branch 'ryaswann/iris_xops_perf' of github.com:ROCm/iris into r…
ryanswann-amd Feb 17, 2026
cbe2aff
Apply Ruff auto-fixes
github-actions[bot] Feb 17, 2026
11d9001
Add predictive params, fix pointer overflows, fix race conditions
Mar 3, 2026
3c4cb4d
Apply Ruff auto-fixes
github-actions[bot] Mar 3, 2026
f2f755a
Merge branch 'neoblizz/iris-xops-perf' into ryaswann/iris_xops_perf
ryanswann-amd Mar 3, 2026
77eff5b
Reverse 2D block translate
Mar 3, 2026
dcafd2a
Properly use iris tracing APIs
Mar 3, 2026
6fdad6d
Apply Ruff auto-fixes
github-actions[bot] Mar 3, 2026
08755b7
Remove test.sh
Mar 3, 2026
0224866
use window command
dsidler Mar 4, 2026
40c228a
use new acquire function
dsidler Mar 5, 2026
34d4ffc
update submodule
dsidler Mar 5, 2026
c8d4b46
Apply Ruff auto-fixes
github-actions[bot] Mar 5, 2026
88f7767
All gather matmul with improved performance. (#415)
ryanswann-amd Mar 5, 2026
53f1a20
move padding code
dsidler Mar 5, 2026
099a84c
update submodule for nop packet
dsidler Mar 5, 2026
75b55b2
enable flat copy
dsidler Mar 5, 2026
17d0696
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Mar 5, 2026
e5a38dd
Apply Ruff auto-fixes
github-actions[bot] Mar 5, 2026
02d08c9
Merge branch 'main' into dev/dasidler/sdma
dsidler Mar 5, 2026
0b6ff1a
clean up
dsidler Mar 5, 2026
f558293
Fix CI: restore vectorization hints, align tritonBLAS versions, remov…
ryanswann-amd Mar 6, 2026
e5dd77f
Merge main into neoblizz/iris-xops-perf
ryanswann-amd Mar 6, 2026
477b472
Fix CI: increase default N to match FusedConfig block_size_n=256
ryanswann-amd Mar 6, 2026
76cc30d
Revert "Fix CI: increase default N to match FusedConfig block_size_n=…
ryanswann-amd Mar 6, 2026
9743b13
Remove unnecessary block size assertions — Triton handles masking
ryanswann-amd Mar 6, 2026
a86dc04
Initial plan
Copilot Mar 11, 2026
445b25c
Add vectorization hints and tests for HBM buffer all-gather matmul
Copilot Mar 12, 2026
2f0099f
Add vectorization hints and tests for HBM buffer all-gather matmul (#…
ryanswann-amd Mar 12, 2026
39c213d
Merge branch 'main' into neoblizz/iris-xops-perf
ryanswann-amd Mar 16, 2026
bfe4548
add copy engine support to fused gemm-allscatter
dsidler Mar 18, 2026
27040c8
Apply Ruff auto-fixes
github-actions[bot] Mar 18, 2026
bf55b6d
switch to acquire_fadd
dsidler Mar 24, 2026
aef1411
update submodule
dsidler Mar 24, 2026
2cea9f7
initial host initiated sdma
dsidler Mar 24, 2026
53bfeaa
refactor&cleanup
dsidler Mar 24, 2026
831be93
Merge branch 'dev/dasidler/sdma' of https://github.com/ROCm/iris into…
dsidler Mar 24, 2026
d191276
Apply Ruff auto-fixes
github-actions[bot] Mar 24, 2026
71feba4
Merge branch 'dev/dasidler/sdma' into dev/dasidler/sdma-benchmark
dsidler Mar 24, 2026
77a4d1d
initial copy engine ag-gemm
dsidler Mar 25, 2026
bb22e82
Apply Ruff auto-fixes
github-actions[bot] Mar 25, 2026
a44adde
persisten version
dsidler Mar 26, 2026
9891843
use same benchmark initialization to improve gemm time
dsidler Mar 26, 2026
671a622
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Mar 26, 2026
eded63e
Apply Ruff auto-fixes
github-actions[bot] Mar 26, 2026
6c8cdcc
version that performs reasonably
dsidler Mar 30, 2026
d8d136a
avoid local copy of a
dsidler Mar 30, 2026
9d4c7f9
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Mar 30, 2026
dd501a3
Apply Ruff auto-fixes
github-actions[bot] Mar 30, 2026
28f4dc8
add constraints
dsidler Mar 30, 2026
92608d4
adding initial matmul_all_gather
dsidler Mar 30, 2026
acedf8c
device-initiated
dsidler Mar 30, 2026
d88eb87
device initiated
dsidler Mar 30, 2026
39ac9d7
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Mar 30, 2026
0b763ca
Apply Ruff auto-fixes
github-actions[bot] Mar 30, 2026
d140349
initial derive version for copy engine
dsidler Mar 31, 2026
fc4601d
fix batch_id inc
dsidler Apr 1, 2026
29dafac
fix flag allocation
dsidler Apr 1, 2026
01932a1
fix host gemm-ag
dsidler Apr 2, 2026
8764190
importing derived params
dsidler Apr 2, 2026
08cd061
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Apr 2, 2026
933e531
fix host gemm+ag, add gemm only
dsidler Apr 3, 2026
b1c2417
update sweep
dsidler Apr 3, 2026
cac3ee0
gemm-ag host switch to m-tile batch, add tracing
dsidler Apr 3, 2026
623325c
Apply Ruff auto-fixes
github-actions[bot] Apr 3, 2026
e190d30
reuse locks btw iterations
dsidler Apr 6, 2026
654d81a
add host-initiated to iris api
dsidler Apr 6, 2026
69a25c8
add success flag to ag-gemm, update sweep script
dsidler Apr 6, 2026
b6dfb78
gemm-ag benchmark updates
dsidler Apr 6, 2026
39a840f
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Apr 6, 2026
ef26c0d
reuse locks
dsidler Apr 7, 2026
e0d85d5
hbm-buf fix race condition, reuse locks
dsidler Apr 7, 2026
bad3422
Initial plan for PR cleanup
Copilot Apr 8, 2026
2a9f31a
Cleanup PR: address reviewer feedback
Copilot Apr 8, 2026
98d25bf
Clarify bias handling in matmul_reduce_scatter: raise NotImplementedE…
Copilot Apr 8, 2026
196bef7
Merge branch 'main' into neoblizz/iris-xops-perf
Copilot Apr 8, 2026
f4b4e75
Sync with main, remove unneeded scripts, minimize PR footprint
Copilot Apr 8, 2026
9d29d8c
Port HBM buffer benchmark to iris.bench, remove helper scripts
Copilot Apr 8, 2026
2c8b226
Replace shmem with ctx in hbm_buffer kernel and tests
Copilot Apr 9, 2026
1f7f6f1
Updated copilot instructions: you have GPUs, use them
mawad-amd Apr 9, 2026
9999273
Add benchmark comparison plots for HBM buffer vs baseline
Copilot Apr 9, 2026
e6b7114
Merge benchmarks and tests, remove dead code
Copilot Apr 9, 2026
5fac461
Update benchmark comparison plots with MxNxK x-axis labels
Copilot Apr 9, 2026
184331c
Extend trace events with categorized ID ranges and fix tracing abuse
mawad-amd Apr 9, 2026
1b6df88
Apply Ruff auto-fixes
github-actions[bot] Apr 9, 2026
6b70059
Bump trace schema version to 1.2 for new event categories
mawad-amd Apr 9, 2026
8607e38
Add RCCL baseline and rename algorithms to one_shot/prefetch
mawad-amd Apr 9, 2026
63c978b
Fix RCCL benchmark: use regular CUDA memory, not iris symmetric heap
mawad-amd Apr 9, 2026
6a8ad6b
Fix RCCL benchmark: use dist.get_world_size() instead of ctx
mawad-amd Apr 9, 2026
5027f67
add args to matmul
dsidler Apr 9, 2026
292ee11
Update HBM buffer kernel defaults and benchmark for parameter sweep
Copilot Apr 9, 2026
6979787
Update benchmark plots with new vs previous defaults comparison
Copilot Apr 9, 2026
826e78f
add flag_iteration
dsidler Apr 10, 2026
dd50602
more robust sweep script
dsidler Apr 10, 2026
a058856
merge sweep script
dsidler Apr 10, 2026
11d36b8
switch to tritonblas
dsidler Apr 10, 2026
02ea2b6
Fix preamble FusedConfig() defaults and add shape-adaptive auto-config
ryanswann-amd Apr 11, 2026
64a631f
Fix collective ordering deadlock in fd_passing at ws<8
ryanswann-amd Apr 11, 2026
7d3f476
Apply Ruff auto-fixes
github-actions[bot] Apr 11, 2026
b59bbb2
use selector for gemm-ag host
dsidler Apr 13, 2026
cf24173
reuse selector gemm-ag host, cannot change block-size
dsidler Apr 13, 2026
2f9e2a7
switch to tritonblas temporarily
dsidler Apr 14, 2026
7786de8
use m-tile-per-batch=group-size
dsidler Apr 14, 2026
4545b3e
merged sweep
dsidler Apr 14, 2026
3942b10
host issue batch0 ag-gemm
dsidler Apr 14, 2026
053f9c8
remove copy hack
dsidler Apr 14, 2026
8d9f2dd
update heuristic gemm-ag host
dsidler Apr 15, 2026
d1c4e3d
do sdma quiet gemm-ag
dsidler Apr 15, 2026
0d7fed3
improve plotting
dsidler Apr 15, 2026
2c572c3
Apply Ruff auto-fixes
github-actions[bot] Apr 15, 2026
ef0a173
Port auto-config system from ryanswann-amd/iris feature/auto-config-x…
Copilot Apr 15, 2026
2528e8e
Add docs/benchmark-results/ to .gitignore
Copilot Apr 15, 2026
caed8a5
Remove accidentally committed .github/agents and benchmark images
Copilot Apr 15, 2026
b0f8ff6
using wave- and xcd-aware tile transfers
dsidler Apr 16, 2026
59bd83a
gemm-ag device wave-xcd aware
dsidler Apr 16, 2026
55884db
add metadata
dsidler Apr 17, 2026
0a66433
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Apr 17, 2026
86a979d
update fused gemm-ag
dsidler Apr 17, 2026
19eb057
add more scripts
dsidler Apr 17, 2026
7f70cb8
change expected alloc
dsidler Apr 17, 2026
6e7ba74
Merge branch 'neoblizz/iris-xops-perf' into dev/dasidler/sdma-benchmark
dsidler Apr 17, 2026
d52ca11
switch to new benchmarks
dsidler Apr 18, 2026
a3446aa
gemm-ag validation
dsidler Apr 20, 2026
8a1043f
validator updates and fixes
dsidler Apr 20, 2026
5323d95
Apply Ruff auto-fixes
github-actions[bot] Apr 20, 2026
c52e5ed
ag-gemm fixes, tritonblas+rccl
dsidler Apr 21, 2026
6216a32
change allocations in bench
dsidler Apr 22, 2026
e53c532
alloc updates, fix hbm buf
dsidler Apr 22, 2026
43103b8
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Apr 22, 2026
db60651
Apply Ruff auto-fixes
github-actions[bot] Apr 22, 2026
3623b99
include ag-gemm baseline in benchmark
dsidler Apr 22, 2026
9f2066f
no host quiet needed
dsidler Apr 22, 2026
c5caec2
refactor matmul-ag
dsidler Apr 23, 2026
89227df
refactor ag-gemm
dsidler Apr 23, 2026
a04fda9
Merge branch 'dev/dasidler/sdma-benchmark' of https://github.com/ROCm…
dsidler Apr 23, 2026
d790a3f
Apply Ruff auto-fixes
github-actions[bot] Apr 23, 2026
e138b79
make matmul-only async
dsidler May 5, 2026
45bbdf3
updates to sweep
dsidler Jun 15, 2026
d92e482
Merge branch 'dev/dasidler/sdma-benchmark' of github.com:ROCm/iris in…
dsidler Jun 15, 2026
84c9216
Apply Ruff auto-fixes
github-actions[bot] Jun 15, 2026
861b97b
Merge branch 'main' into dev/dasidler/sdma-benchmark
dsidler Oct 1, 2026
b1e244f
switch to new tile API
dsidler Oct 5, 2026
9c22fce
fix hint
dsidler Oct 5, 2026
ab2c327
remove duplicate tests
dsidler Oct 6, 2026
e19df6f
Remove shader_sdma submodule completely
dsidler Oct 6, 2026
262838c
reverting examples, cleanup
dsidler Oct 6, 2026
f91949b
Apply Ruff auto-fixes
github-actions[bot] Oct 6, 2026
d2ee79a
fix ci failure
dsidler Oct 6, 2026
f530358
delete tune files
dsidler Oct 6, 2026
6961726
Merge branch 'dev/dasidler/sdma-benchmark' of github.com:ROCm/iris in…
dsidler Oct 6, 2026
d7f0f54
Point tritonblas and rocm-xio at the updated branches; use Epilogue/P…
dsidler Oct 21, 2026
0d70dd7
remove plot and sweep scripts
dsidler Oct 21, 2026
045eda4
update ag-gemm test
dsidler Oct 21, 2026
8c5c362
Merge branch 'main' into dev/dasidler/sdma-benchmark
dsidler Oct 21, 2026
cd5740d
fix xio dependency
dsidler Oct 22, 2026
0eed958
remove gemm baseline
dsidler Oct 22, 2026
3ddb63a
remove hip_mempcpy backend
dsidler Oct 23, 2026
0f3c1b5
revert flag_iteration
dsidler Oct 23, 2026
b38ad49
handle optional sdma
dsidler Oct 23, 2026
02e3b87
clean up
dsidler Oct 23, 2026
53f7768
remove trace logic
dsidler Oct 23, 2026
e96503f
test cleanup
dsidler Oct 23, 2026
df5c210
Merge branch 'main' into dev/dasidler/sdma-benchmark
dsidler Oct 23, 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
35 changes: 35 additions & 0 deletions benchmark/ops/bench_all_gather_matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import torch
import torch.distributed as dist
import tritonblas
import iris.bench as bench
from iris.ops.all_gather_matmul_hbm_buffer import (
all_gather_matmul_hbm_buffer as _hbm_buffer,
Expand Down Expand Up @@ -57,6 +58,40 @@ def _run():
state.exec(_run)


@bench.register
@bench.axis("num_ranks", [2, 4, 8])
@bench.axis("M", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def tritonblas_rccl_all_gather_matmul(state, ctx):
"""RCCL all_gather + tritonBLAS matmul baseline (same GEMM as the iris ops)."""
M, N, K = state["M"], state["N"], state["K"]
dtype = state["dtype"]
world_size = dist.get_world_size()
rank = dist.get_rank()
K_local = K // world_size

# Per-rank seed for A (each rank holds different shards); shared seed for B
A_sharded = ctx.randn((M, K_local), dtype=dtype, generator=torch.Generator("cuda").manual_seed(42 + rank))
B = ctx.randn((K, N), dtype=dtype, generator=torch.Generator("cuda").manual_seed(123))
A_gathered_list = [ctx.zeros((M, K_local), dtype=dtype) for _ in range(world_size)]
C = ctx.zeros((M, N), dtype=dtype)

selector = tritonblas.OrigamiMatmulSelector(M, N, K, dtype, dtype, dtype, A_sharded.device)
config = tritonblas.matmul_preamble(selector)

state.set_flops(2 * M * N * K)
state.set_bytes((world_size - 1) * M * K_local * A_sharded.element_size())

def _run():
dist.all_gather(A_gathered_list, A_sharded)
A_gathered = torch.cat(A_gathered_list, dim=1)
tritonblas.matmul_lt(A_gathered, B, C, selector, config)

state.exec(_run)


@bench.register
@bench.axis("num_ranks", [2, 4, 8])
@bench.axis("M", [1024, 4096, 16384])
Expand Down
112 changes: 112 additions & 0 deletions benchmark/ops/bench_all_gather_matmul_copy_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.

"""Benchmarks for all-gather + GEMM copy-engine variants."""

import torch
import iris.bench as bench

from iris.ops.all_gather_matmul_copy_engine import (
all_gather_matmul_copy_engine as _copy_engine,
all_gather_matmul_copy_engine_preamble,
)
from tritonblas.matmul import _make_matmul_selector


def _make_selector(M: int, N: int, K: int, dtype: torch.dtype, device: torch.device):
return _make_matmul_selector(
M,
N,
K,
dtype,
dtype,
dtype,
device,
streamk=False,
)


def _register_copy_engine(state, ctx, *, device_initiated: bool) -> None:
if ctx.get_copy_engine_ctx() is None:
state.skip("SDMA engine is not enabled; run with --engines sdma")
M, N, K = state["M"], state["N"], state["K"]
dtype = state["dtype"]
rank = ctx.get_rank()
world_size = ctx.get_num_ranks()
if K % world_size != 0:
state.skip(f"K={K} must be divisible by world_size={world_size}")

K_local = K // world_size
device = torch.device(f"cuda:{torch.cuda.current_device()}")
selector = _make_selector(M, N, K, dtype, device)

if M % selector.block_m != 0:
state.skip(f"M={M} must be divisible by block_size_m={selector.block_m}")
if K % selector.block_k != 0:
state.skip(f"K={K} must be divisible by block_size_k={selector.block_k}")
if K_local % selector.block_k != 0:
state.skip(f"K_local={K_local} must be divisible by block_size_k={selector.block_k}")

A_sharded = ctx.zeros((M, K_local), dtype=dtype)
torch.manual_seed(123 + rank)
A_sharded_data = torch.randn((M, K_local), device="cuda", dtype=dtype)
A_sharded.copy_(A_sharded_data)
torch.manual_seed(456)
B = torch.randn((K, N), device="cuda", dtype=dtype)
C = ctx.zeros((M, N), dtype=dtype)

workspace = all_gather_matmul_copy_engine_preamble(
ctx,
A_sharded,
B,
selector=selector,
)
m_tiles_per_batch = workspace.m_tiles_per_batch

flag_iteration = [0]

def _run():
_copy_engine(
ctx,
C,
A_sharded,
B,
async_op=False,
workspace=workspace,
flag_iteration=flag_iteration[0],
device_initiated=device_initiated,
)
flag_iteration[0] += 1

state.set_flops(2 * M * N * K)
state.set_bytes((world_size - 1) * M * K_local * A_sharded.element_size())
state.add_counter("group_size_m", float(selector.group_m))
state.add_counter("m_tiles_per_batch", float(m_tiles_per_batch))
state.add_counter("device_initiated", 1.0 if device_initiated else 0.0)

state.exec(_run)


@bench.register
@bench.axis("num_ranks", [8])
@bench.axis("M", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def all_gather_matmul_copy_engine_host(state, ctx):
_register_copy_engine(state, ctx, device_initiated=False)


@bench.register
@bench.axis("num_ranks", [8])
@bench.axis("M", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def all_gather_matmul_copy_engine_device(state, ctx):
_register_copy_engine(state, ctx, device_initiated=True)


if __name__ == "__main__":
bench.main()
75 changes: 71 additions & 4 deletions benchmark/ops/bench_matmul_all_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.

"""Benchmark for fused GEMM + all-gather (iris.ops)."""
"""Benchmarks for fused GEMM + all-gather (iris.ops) and its RCCL baselines."""

import torch
import torch.distributed as dist
import tritonblas
import iris.bench as bench
from iris.ops import FusedConfig
from tritonblas.matmul import persistent_matmul_lt


def _make_inputs(ctx, M_local, N, K, dtype):
# Per-rank seed for A (each rank holds a different shard); shared seed for B.
# Same seeding as the all-gather + matmul benchmarks.
rank = ctx.get_rank()
A = ctx.randn((M_local, K), dtype=dtype, generator=torch.Generator("cuda").manual_seed(42 + rank))
B = ctx.randn((K, N), dtype=dtype, generator=torch.Generator("cuda").manual_seed(123))
return A, B


@bench.register
Expand All @@ -21,9 +33,7 @@ def matmul_all_gather(state, ctx):
world_size = ctx.get_num_ranks()
M = M_local * world_size

A = ctx.zeros((M_local, K), dtype=dtype)
A.fill_(1.0)
B = torch.randn((K, N), device="cuda", dtype=dtype)
A, B = _make_inputs(ctx, M_local, N, K, dtype)
C = ctx.zeros((M, N), dtype=dtype)

config = FusedConfig()
Expand All @@ -37,5 +47,62 @@ def matmul_all_gather(state, ctx):
)


@bench.register
@bench.axis("num_ranks", [2, 4, 8])
@bench.axis("M_local", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def pytorch_matmul_all_gather(state, ctx):
"""PyTorch/RCCL baseline: torch.mm + all_gather_into_tensor."""
M_local, N, K = state["M_local"], state["N"], state["K"]
dtype = state["dtype"]
world_size = ctx.get_num_ranks()
M = M_local * world_size

A, B = _make_inputs(ctx, M_local, N, K, dtype)
C_local = ctx.zeros((M_local, N), dtype=dtype)
C = ctx.zeros((M, N), dtype=dtype)

state.set_flops(2 * M_local * N * K)
state.set_bytes((world_size - 1) * M_local * N * A.element_size())

state.exec(
lambda: (
torch.mm(A, B, out=C_local),
dist.all_gather_into_tensor(C, C_local),
),
)


@bench.register
@bench.axis("num_ranks", [2, 4, 8])
@bench.axis("M_local", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def tritonblas_matmul_all_gather(state, ctx):
"""tritonBLAS GEMM + RCCL all_gather_into_tensor baseline (same GEMM as the iris ops)."""
M_local, N, K = state["M_local"], state["N"], state["K"]
dtype = state["dtype"]
world_size = ctx.get_num_ranks()
M = M_local * world_size

A, B = _make_inputs(ctx, M_local, N, K, dtype)
C_local = ctx.zeros((M_local, N), dtype=dtype)
C = ctx.zeros((M, N), dtype=dtype)
selector = tritonblas.OrigamiMatmulSelector(M_local, N, K, A.dtype, B.dtype, C_local.dtype, A.device)

state.set_flops(2 * M_local * N * K)
state.set_bytes((world_size - 1) * M_local * N * A.element_size())

state.exec(
lambda: (
persistent_matmul_lt(A, B, C_local, selector, config=None, work_stealing=False),
dist.all_gather_into_tensor(C, C_local),
),
)


if __name__ == "__main__":
bench.main()
131 changes: 131 additions & 0 deletions benchmark/ops/bench_matmul_all_gather_copy_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.

"""Benchmarks for fused GEMM + all-gather copy-engine variants."""

import torch
import iris.bench as bench

from iris.ops.matmul_all_gather_copy_engine import (
matmul_all_gather_copy_engine as _device_copy_engine,
matmul_all_gather_copy_engine_preamble as _device_preamble,
)
from iris.ops.matmul_all_gather_host_copy_engine import (
matmul_all_gather_host_copy_engine as _host_copy_engine,
matmul_all_gather_host_copy_engine_preamble as _host_preamble,
)
from tritonblas.matmul import _make_matmul_selector


def _make_selector(M_local: int, N: int, K: int, dtype: torch.dtype, device: torch.device):
return _make_matmul_selector(
M_local,
N,
K,
dtype,
dtype,
dtype,
device,
streamk=False,
)


def _register_copy_engine(state, ctx, *, device_initiated: bool) -> None:
if ctx.get_copy_engine_ctx() is None:
state.skip("SDMA engine is not enabled; run with --engines sdma")
M_local, N, K = state["M_local"], state["N"], state["K"]
dtype = state["dtype"]
rank = ctx.get_rank()
world_size = ctx.get_num_ranks()
M = M_local * world_size

device = torch.device(f"cuda:{torch.cuda.current_device()}")
selector = _make_selector(M_local, N, K, dtype, device)

if M_local % selector.block_m != 0:
state.skip(f"M_local={M_local} must be divisible by block_size_m={selector.block_m}")
if K % selector.block_k != 0:
state.skip(f"K={K} must be divisible by block_size_k={selector.block_k}")

torch.manual_seed(123 + rank)
A = ctx.randn((M_local, K), dtype=dtype)
torch.manual_seed(456)
B = ctx.randn((K, N), dtype=dtype)
C = ctx.zeros((M, N), dtype=dtype)

flag_iteration = [0]

if device_initiated:
workspace = _device_preamble(
ctx,
A,
B,
selector=selector,
)

def _run():
_device_copy_engine(
ctx,
C,
A,
B,
async_op=False,
workspace=workspace,
flag_iteration=flag_iteration[0],
)
flag_iteration[0] += 1

else:
workspace = _host_preamble(
ctx,
A,
B,
trace=False,
selector=selector,
)

def _run():
_host_copy_engine(
ctx,
C,
A,
B,
async_op=False,
workspace=workspace,
flag_iteration=flag_iteration[0],
trace=False,
)
flag_iteration[0] += 1

state.set_flops(2 * M_local * N * K)
state.set_bytes((world_size - 1) * M_local * N * A.element_size())
state.add_counter("group_size_m", float(selector.group_m))
state.add_counter("m_tiles_per_batch", float(workspace.m_tiles_per_batch))
state.add_counter("device_initiated", 1.0 if device_initiated else 0.0)

state.exec(_run)


@bench.register
@bench.axis("num_ranks", [8])
@bench.axis("M_local", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def matmul_all_gather_copy_engine_host(state, ctx):
_register_copy_engine(state, ctx, device_initiated=False)


@bench.register
@bench.axis("num_ranks", [8])
@bench.axis("M_local", [1024, 4096, 16384])
@bench.axis("N", [3584])
@bench.axis("K", [8192])
@bench.axis("dtype", [torch.float16])
def matmul_all_gather_copy_engine_device(state, ctx):
_register_copy_engine(state, ctx, device_initiated=True)


if __name__ == "__main__":
bench.main()
Loading
Loading