Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
b522c4b
Fix release workflow: runner labels, Docker username, setuptools_scm …
sunway513 Apr 13, 2026
10a1cb9
[OPUS] Optimize opus.hpp compile time: 70% reduction (#2701)
carlushuang Apr 13, 2026
b025f09
Optimize fused_dynamic_mxfp4_quant_moe_sort_hip in small M (#2700)
junhaha666 Apr 13, 2026
a34234d
CI: surface runner-config mapping in AMD CI job monitor (#2711)
gyohuangxin Apr 13, 2026
2446746
CI: auto-update split test FILE_TIMES (#2709)
github-actions[bot] Apr 13, 2026
222b655
CI: add standalone OPUS test workflow (#2716)
gyohuangxin Apr 13, 2026
842a164
add signature and refine lru cache (#2710)
solinzby1 Apr 13, 2026
655d944
CI: separate Aiter Test concurrency for push and schedule (#2718)
gyohuangxin Apr 13, 2026
0f6aede
fix split module jit and retune (#2719)
lalala-sh Apr 13, 2026
1a8fb17
[TRITON] Prevent NUM_KSPLIT from reducing K dim below GROUP_K (#2661)
vgokhale Apr 13, 2026
b633fba
CI: Enable Deepseek ATOM tests on MI35X (#2667)
gyohuangxin Apr 13, 2026
857f4d1
feat: _flash_attn_forward add out args (#2648)
RuibinCheung Apr 14, 2026
d87e599
Replace CK/CK_TILE in MLA Reduce and Metadata Kernel with OPUS (#2717)
ruanjm Apr 14, 2026
bbdc066
docs: add ISA-level kernel optimization guide (#2708)
sunway513 Apr 14, 2026
303a583
Add run_config and compare in tuner (#2375)
yzhou103 Apr 14, 2026
d098ae5
Revert "fix(car): craph capture err (#2638)" (#2735)
TennyWang1223 Apr 14, 2026
7eeb950
[TRITON] Swiglu and reduce refactor (#2583)
nsusanto Apr 14, 2026
9a9f684
[aiter] type hints mismatch (#2728)
amd-ruitang3 Apr 15, 2026
6107fd6
fix: silence false warning in fmha_fwd_v3 when use_asm_v3 is disabled…
suachong Apr 15, 2026
e2ab304
Add FlyDSL GEMM AOT precompile support (#2741)
zhiding512 Apr 15, 2026
267a450
gather support qk_nope_head_dim != v_head_dim (#2739)
jiayyu Apr 15, 2026
47b0966
feat: add/retune BF16 GEMM configs with FlyDSL backend for 6 models (…
sunway513 Apr 15, 2026
f326553
Hoist introspection out of per-call ctype dispatch (#2742)
gronsti-amd Apr 15, 2026
daa8e94
Make FlyDSL LDS checks architecture-aware and reduce tuner failure no…
yzhou103 Apr 15, 2026
70c2030
16x256 kernel (#2722)
JohnNikolay84 Apr 15, 2026
fde73e1
rebase linear attn for new flydsl version (#2746)
xytpai Apr 15, 2026
016ead3
Replace unsafe uses of std::unordered_map with SynchronizedCache (#2221)
draganmladjenovic Apr 15, 2026
954c837
Fix Triton MoE GEMM shared memory exhaustion by reducing stage count …
nidal567 Apr 15, 2026
a4e9890
Annotate moe_sorting_dispatch_policy as int for fused_moe (#2639)
nholmber Apr 16, 2026
c70476c
fix moe splitk aot and jit (#2738)
lalala-sh Apr 16, 2026
0e34d8d
Update quant.pyfix: add pack_dim to per_1x32_f4_quant for tl.dot_scal…
GeisYaO Apr 16, 2026
8090820
Flydsl align if else usage to be compatible with all versions (#2740)
xudoyuan Apr 16, 2026
c849fd5
Add bf16 MLA decode kernel for gqa_ratio=64, qseqlen=1 (non-persisten…
fangche123 Apr 16, 2026
c7bed71
CI: scope check signal artifact downloads to matching run (#2757)
gyohuangxin Apr 16, 2026
0b69f6b
feat: aiter whls nightly (#2514)
kiran-thumma Apr 16, 2026
caca38c
CI: reduce retention for workflow artifacts (#2758)
gyohuangxin Apr 16, 2026
da90169
CI: upgrade sglang downstream to v0.5.10 (#2753)
gyohuangxin Apr 16, 2026
fab6ef3
fix(car): sglang prefill launch error kernel (#2745)
TennyWang1223 Apr 16, 2026
4c3db2c
Add unified attention support to bench_models (#2724)
lucas-santos-amd Apr 16, 2026
4211777
Use AITER_CONFIGS for FlyDSL AOT defaults (#2756)
zhiding512 Apr 16, 2026
1bbd58c
fix fused_dynamic_mxfp4_quant_moe_sort_hip err in EP (#2759)
junhaha666 Apr 16, 2026
cba1303
Fix `test_moe_routing_sigmoid_top1_fused` reference implementation ti…
brunomazzottiamd Apr 16, 2026
ad68fe0
[fix](cache): add eps to avoid diving zero (#2763)
PerryZhang01 Apr 16, 2026
e991be1
[FlyDSL MOE] update a8w4 moe (#2726)
Zzz9990 Apr 16, 2026
fea695b
MI350 mla ps mode suppport nhead128,1 128,2 128,3 128,4 64,4 64,2 32,…
minmengdie Apr 17, 2026
3e8a773
update config (#2771)
lalala-sh Apr 17, 2026
727253a
fix(ck_gemm): fix multi-arch build targeting and kernel dispatch acro…
eppaneamd Apr 17, 2026
67f3217
add triton fallback for mi455 gptoss & dsfp4 (#2657)
HaonanWang98 Apr 17, 2026
73ad002
fix recompile issue (#2777)
xytpai Apr 17, 2026
1bcab14
Fix fused_gemm_a8w8_blockscale_a16w16 unit test failures (#2766)
nidal567 Apr 17, 2026
cf12b13
walkaround invalid kernels in moe tunner (#2785)
lalala-sh Apr 18, 2026
afddcbf
CI: auto-update split test FILE_TIMES (#2795)
github-actions[bot] Apr 20, 2026
0dad434
[fix] remove glm5 triton tuned gemm (#2803)
HaonanWang98 Apr 20, 2026
d3a1e52
add tuned bf16 gemm for qwen3next and qwen3.5 (#2799)
ganyi1996ppo Apr 20, 2026
c5e14ff
[Perf][WIP]update qwen fmoe tuned configs (#2812)
lalala-sh Apr 20, 2026
a3f54e3
CI: run SGLang downstream tests on MI355 (#2807)
gyohuangxin Apr 20, 2026
e3225be
CI: allow nightly check-signal to reuse Checks push runs (#2819)
gyohuangxin Apr 20, 2026
8830d77
[fix] fix compare error (#2805)
yzhou103 Apr 21, 2026
207cd7d
CI: log in to Docker before building aiter image (#2824)
gyohuangxin Apr 21, 2026
02fb8fa
[FLYDSL]: aiter flydsl if const_expr (#2776)
xudoyuan Apr 21, 2026
6792cbf
add tuner test suite (#2734)
yzhou103 Apr 21, 2026
fb770f7
fix lse address compute (#2810)
JaxChen29 Apr 21, 2026
5408edb
Add vcs_versioning as transitive dependency of setuptools_scm>=10 (#2…
kurapov-peter Apr 21, 2026
e19bda6
Revert kimi2.5 fp4 tp4 moe tuned result on bs 32,64 (#2836)
junhaha666 Apr 21, 2026
58ee7e9
remove gemm tuning (#2838)
ganyi1996ppo Apr 21, 2026
7890e4b
disable import flydsl_gdr_decode (#2840)
valarLip Apr 21, 2026
ca33757
Xiaobing/gptoss small m (#2775)
XiaobingSuper Apr 22, 2026
0630232
[CK_TILE] Fix bpreshuffle compile failure due to stale CShuffleEpilog…
DDEle Apr 22, 2026
e60583c
update flydsl version (#2802)
coderfeli Apr 22, 2026
79a0593
CI: fix pre-check signal artifact lookup for PR reruns (#2848)
gyohuangxin Apr 22, 2026
6890159
[Fix]fix moe tunner (#2831)
lalala-sh Apr 22, 2026
95ea3b7
CI: To fix prebuild image issue (#2847)
gyohuangxin Apr 22, 2026
f8a0971
Fix a8w8 flydsl tune (#2809)
solinzby1 Apr 22, 2026
65d737f
fix other lse addr compute issue (#2833)
JaxChen29 Apr 22, 2026
6f72b96
CI: align tuning test workflow with README (#2849)
gyohuangxin Apr 22, 2026
bf4cd5b
gqa ratio support in mha test (#2798)
slippedJim Apr 22, 2026
0814370
ci(release): add manylinux2_28+ROCm builder path with auditwheel gate…
sunway513 Apr 22, 2026
27b9edb
add asm load kernel log (#2800)
yzhou103 Apr 22, 2026
6ac02c5
Update gfx942&gfx950 PA PS kernels and write stride_scale_page in asm…
fangche123 Apr 22, 2026
9522c04
clean code and reduce num_stages to 1 for large tile configs in fused…
nidal567 Apr 22, 2026
863d0e6
[TRITON] Add Gluon-optimized MoE Int8 SmoothQuant kernel for small K …
jwu10003 Apr 22, 2026
0f57b19
[TRITON] Reduce MHA UTs (#2612)
vgokhale Apr 22, 2026
5162472
Add gfx942 Triton A8W8 blockscale GEMM configs for GLM-5 shapes for 7…
amd-pedghazi Apr 22, 2026
09282b3
docs: polish README with ecosystem, news, and performance highlights …
carlushuang Apr 23, 2026
d72c1f9
make rmsnorm quant fusion support gemma (#2853)
ganyi1996ppo Apr 23, 2026
a16a677
ci(release): add torch_pin + torch_index_url inputs for ABI-targeted …
sunway513 Apr 23, 2026
23a0ae8
Revert "CI: run SGLang downstream tests on MI355" (#2873)
gyohuangxin Apr 23, 2026
375252a
ci: rename aiter MI300X runners (#2872)
gyohuangxin Apr 23, 2026
6f31a36
CI: raise atom-test accuracy step timeout to 90 minutes (#2876)
gyohuangxin Apr 23, 2026
6379a3f
Add torch in gemm a16w16 tune (#2860)
yzhou103 Apr 23, 2026
0f463f9
CI: run Triton workflow on MI35X only (#2871)
gyohuangxin Apr 23, 2026
e039817
MLA PS mode support nhead8,2 in MI308 (#2852)
minmengdie Apr 23, 2026
7c4cc6c
Merge pull request #2875 from ROCm/pensun/release-workflow-torch-pin
sunway513 Apr 23, 2026
cc31a1a
Dev/aot fix (#2856)
zhiding512 Apr 24, 2026
8432ff3
Update kimik2 FP4 tuned fMoE config (#2845)
okorzh-amd Apr 24, 2026
6b8ce4e
Fix sliding window mtp (#2829)
fsx950223 Apr 24, 2026
0f059ac
[DO NOT MERGE] CI TESTS (#2894)
gyohuangxin Apr 24, 2026
ed2db5e
CI: Temporarily running the build jobs on linux-aiter-mi300x-1 due to…
gyohuangxin Apr 24, 2026
4858b76
CI: Fix Aiter installation issues in sglang downstream test (#2897)
gyohuangxin Apr 24, 2026
f1f5e06
CI: add opt-in MI300X Triton jobs for PRs and main (#2883)
gyohuangxin Apr 24, 2026
5dda33b
Revert "CI: Temporarily running the aiter build on linux-aiter-mi300x…
gyohuangxin Apr 24, 2026
d9073af
add optimized prefill gdn kernels for qwen3_5 (#2686)
yiijin Apr 24, 2026
f4179e8
Introduce asm fmoe kernels that do not require bf16->fp8 quantization…
JohnNikolay84 Apr 24, 2026
2b2d1b7
Revert "Fix sliding window mtp (#2829)" (#2909)
PerryZhang01 Apr 24, 2026
2b042db
fix(fmha): support >4GB KV cache in batch prefill via runtime dispatc…
Jeff-Huang Apr 24, 2026
08f0e05
Fix top_k_per_row_prefill err when batched_token_numm > 4096 (#2901)
junhaha666 Apr 24, 2026
e50e721
retune a8w8_blockscale_bpreshuffle_gemm for MI308 (#2896)
chuanbowang2026 Apr 24, 2026
033d8b9
revert gptoss tuned config (#2904)
XiaobingSuper Apr 24, 2026
76ea1ed
fix mhc device
valarLip Apr 25, 2026
3391e05
feat(dsv4): add validator scaffold + shape/rank checks (sunway513/ato…
sunway513 Apr 26, 2026
c5a307c
feat(dsv4): validator dtype checks (§5 #2) (sunway513/atom#37)
sunway513 Apr 26, 2026
98ce4e2
feat(dsv4): validator device & contiguity checks (§5 #3) (sunway513/a…
sunway513 Apr 26, 2026
0edeb30
feat(dsv4): validator topk domain checks (§5 #4 — #42 culprit) (sunwa…
sunway513 Apr 26, 2026
fa280fa
feat(dsv4): validator slot/positions/cu domain checks (§5 #5/#6/#7) (…
sunway513 Apr 26, 2026
8fc7d4e
feat(flydsl): scaffold blockscale MoE kernel registry (#37 W4.5 accur…
sunway513 Apr 26, 2026
74bc306
feat(flydsl): port compile_moe_blockscale_gemm1/2/_ex from FlyDSL ups…
sunway513 Apr 26, 2026
4b1eb42
feat(flydsl): export flydsl_moe_blockscale_stage1/stage2 (#37 W4.5)
sunway513 Apr 26, 2026
8fedbc1
feat(flydsl): dispatcher routing for blockscale MoE (#37 W4.5)
sunway513 Apr 26, 2026
b7d4a95
test(flydsl): port blockscale numerical correctness test + DSV4 shape…
sunway513 Apr 26, 2026
0ccce74
test(flydsl): use real DSV4 per-rank TP=8 shape (PASSING) (#37 W4.5)
sunway513 Apr 26, 2026
455da99
feat(flydsl): DSV4 tuned MoE config — TP=8 per-rank shapes, blockscal…
sunway513 Apr 26, 2026
4ca7936
test(flydsl)+config: full CSV coverage + stage2 tile_k=128 fix (#37 W…
sunway513 Apr 26, 2026
e450e4d
feat(flydsl): DSV4 FP4 tuned MoE config — fixes #37 W4.5 lookup MISS
sunway513 Apr 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
274 changes: 274 additions & 0 deletions .claude/skills/opus-kernel-best-practice/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
---
name: opus-kernel-best-practice
description: Compile-time optimization guidance for HIP/C++ kernels using opus.hpp. Use when writing or reviewing OPUS kernels, analyzing compile time, reducing template instantiation overhead, or optimizing hipcc build performance.
argument-hint: [file or topic]
---

# OPUS Kernel Compile-Time Best Practices

Techniques for reducing HIP/C++ kernel compile time when using `opus.hpp`. These patterns were developed while optimizing a GQA flash attention kernel from **4.8s to 1.5s** (70% reduction) in device-only compilation.

## Required headers and include paths

For kernel development with OPUS, use these headers from `csrc/include/`:

- **`opus/opus.hpp`** — the OPUS template library + device intrinsic wrappers. **This is the only include needed for device code.** Provides `opus::thread_id_x()`, `opus::block_id_x()`, `opus::sync_threads()`, `opus::warp_all()`, etc.
- **`opus/hip_minimal.hpp`** — minimal HIP **host-side only** declarations (`dim3`, `hipMalloc`, `hipLaunchKernelGGL`, etc.). Use on the host pass instead of `<hip/hip_runtime.h>`.

```bash
hipcc my_kernel.cu -I<aiter_root>/csrc/include -D__HIPCC_RTC__ -std=c++20 -O3 --offload-arch=gfx950
```

| HIP runtime | opus:: wrapper | LLVM builtin |
|---|---|---|
| `threadIdx.x` | `opus::thread_id_x()` | `__builtin_amdgcn_workitem_id_x()` |
| `blockIdx.x` | `opus::block_id_x()` | `__builtin_amdgcn_workgroup_id_x()` |
| `blockDim.x` | `opus::block_size_x()` | `__builtin_amdgcn_workgroup_size_x()` |
| `gridDim.x * blockDim.x` | `opus::grid_size_x()` | `__builtin_amdgcn_grid_size_x()` |
| `__syncthreads()` | `opus::sync_threads()` | `__builtin_amdgcn_s_barrier()` |
| `__all(pred)` | `opus::warp_all(pred)` | — |

If anything is missing, contact the maintainer (carlus.huang@amd.com) for adding support.

## 0. Always Separate Device and Host Code (Most Important)

**This is the single most impactful technique.** hipcc always performs **two compilation passes** on every `.hip`/`.cu` file — one for the host (x86_64) and one for the device (AMDGPU). The heavy `opus.hpp` template library is only needed on the device side, but without a guard, hipcc parses it on BOTH passes, doubling the frontend cost.

**Always structure your kernel files like this:**

```cpp
// my_kernel.cu
#ifdef __HIP_DEVICE_COMPILE__
// ── Device pass: include opus.hpp and define kernels ──
#include "opus/opus.hpp"

__global__ __launch_bounds__(256, 2)
void my_kernel(const float* src, float* dst, int n) {
// ... opus layout, load, store, MMA, etc.
}

#else
// ── Host pass: minimal declarations + launcher only ──
#include "opus/hip_minimal.hpp"

__global__ void my_kernel(const float* src, float* dst, int n); // declaration only

extern "C" void run_my_kernel(const void* d_src, void* d_dst, int n) {
dim3 grid((n + 255) / 256), block(256);
hipLaunchKernelGGL(my_kernel, grid, block, 0, 0,
(const float*)d_src, (float*)d_dst, n);
hipDeviceSynchronize();
}
#endif
```

**Why this works:**
- The device pass sees `opus.hpp` + kernel definitions — full template expansion
- The host pass sees only `opus/hip_minimal.hpp` (~70 lines) + kernel declaration + launch wrapper
- **Saves ~50% of total compile time** by eliminating opus.hpp parsing on the host pass
- The `extern "C"` launcher can be called from Python via `ctypes.CDLL` — no pybind11/torch extension needed

**Compile flags:**

```bash
hipcc my_kernel.cu \
-I<aiter_root>/csrc/include \
-D__HIPCC_RTC__ \
-std=c++20 -O3 -ffast-math \
--offload-arch=gfx950 \
-fPIC -shared -o my_kernel.so
```

## 1. Minimize Header Overhead

### Replace `<hip/hip_runtime.h>` with `opus/hip_minimal.hpp`

Standard `<hip/hip_runtime.h>` expands to ~190K preprocessed lines. The aiter-provided `opus/hip_minimal.hpp` (~80 lines) declares only what's needed — `dim3`, `hipLaunchKernelGGL`, `hipMalloc`/`hipFree`, `__launch_bounds__`, `__shared__`/`__device__`/`__global__`, and `__all()`. Use AMDGCN compiler builtins for device intrinsics:

```cpp
int tid = __builtin_amdgcn_workitem_id_x(); // threadIdx.x
int bid = __builtin_amdgcn_workgroup_id_x(); // blockIdx.x
int bsz = __builtin_amdgcn_workgroup_size_x(); // blockDim.x
__builtin_amdgcn_s_barrier(); // __syncthreads()
```

### Use `-D__HIPCC_RTC__` to suppress implicit includes

Even with minimal headers, hipcc's implicit `__clang_hip_runtime_wrapper.h` pulls in `<cmath>`, `<cstdlib>`, etc. The `-D__HIPCC_RTC__` flag skips these. Provide `#define INFINITY __builtin_huge_valf()` if needed.

### Use ctypes instead of pybind11/torch extension for Python bindings

The C++ binding layer is often the biggest compile cost. The `extern "C"` + `ctypes.CDLL` pattern from Section 0 eliminates it entirely:

| Binding | Compile time |
|---------|-------------|
| torch `CUDAExtension` | ~21s |
| pybind11 + Ninja | ~4.2s |
| ctypes (`extern "C"`, see Section 0) | ~0.4s |

## 2. Reduce Template Instantiation Count

### Use runtime loops instead of `static_for` where compile-time indices aren't needed

Each iteration of `static_for<N>([&](auto I){...})` creates a unique lambda instantiation. For large N, this dominates compile time. Replace with plain `for` loops when the loop body doesn't need compile-time `I`:

```cpp
// SLOW: N unique lambda instantiations
static_for<N>([&](auto I) {
r[I.value] = load<vec>(offsets[I.value]);
});

// FAST: 1 instantiation, compiler unrolls identically
for (index_t i = 0; i < N; i++) {
r[i] = load<vec>(offsets[i]);
}
```

**When you still need `static_for`**: If the body uses `I` as a template argument (e.g., `number<I.value>{}` for `set_slice`, `slice`, or immediate-offset `_tr_load<vec, off>`), you must keep `static_for`.

### Use runtime `flat_to_coords` instead of compile-time multi-index decomposition

`layout_to_offsets` converts a layout into a precomputed offset array using a runtime loop with `flat_to_coords`, which produces `tuple<index_t, ...>` (one type for all iterations) instead of `tuple<number<a>, number<b>, ...>` (unique type per iteration):

```cpp
// SLOW: N unique coord_to_linear instantiations (one per multi-index combination)
static_ford(issue_space_vec, [&](auto... ids) {
offsets[u_linear(ids...)] = u(ids...);
});

// FAST: 1 coord_to_linear instantiation (all iterations use tuple<index_t, ...>)
for (index_t i = 0; i < num_issues; i++) {
offsets[i] = u(flat_to_coords(i, make_index_seq<ndim>{}, issue_space_vec));
}
```

### Cache constexpr computations in struct members

Repeated constexpr evaluations in multiple methods trigger re-evaluation in each:

```cpp
// SLOW: y_shape_a() + reduce_tuple_mul evaluated in every operator()/step_k() overload
constexpr auto a_len = get<0>(reduce_tuple_mul(MMA::y_shape_a()));

// FAST: cached once as class member
static constexpr index_t mma_a_len = get<0>(reduce_tuple_mul(MMA::y_shape_a())).value;
```

## 3. Use LLVM Builtins for Vector Operations

### `__builtin_convertvector` for type conversion

Replaces N-element element-by-element `cast_impl` pack expansion with a single LLVM intrinsic:

```cpp
// SLOW: 64-element pack expansion
return vector_return_type<D, decltype(cast<D>(get<Is>(s)))...>{cast<D>(get<Is>(s))...};

// FAST: single builtin call
return __builtin_convertvector(s, vector_t<D, size<S>()>);
```

### `__builtin_shufflevector` for vector slice/concat

Replaces element-by-element `make_vector(get<Is>(c)...)` with a single shuffle:

```cpp
// SLOW: N-element braced init
return make_vector(get<Is>(c)...);

// FAST: single shuffle (returns GCC-style vector, bit_cast to ext_vector_type)
using R = vector_t<scalar_type, sizeof...(Is)>;
return __builtin_bit_cast(R, __builtin_shufflevector(c, c, Is...));
```

## 4. Avoid Intermediate Type Creation

### Bypass `concat_tuple` with direct indexing

`concat_tuple` creates intermediate tuple types when concatenating >4 tuples. Replace with direct per-element computation:

```cpp
// unfold_x_stride: instead of concat_tuple(per_group_results...)
// compute each element's stride directly via unfold_x_stride_at<J>()

// pickup_shape: instead of concat_tuple(conditional<match, tuple<T>, tuple<>>{}...)
// build a filtered index sequence, then make_tuple(get<filtered_indices>(Shape{})...)

// flatten_tuple: instead of concat_tuple(explode_tuple(get<Is>(t))...)
// directly index as get<local>(get<group>(t)) via flatten_at<T, J, GS>()
```

### Specify return type explicitly to avoid `std::common_type`

```cpp
// SLOW: triggers recursive std::common_type<D, D, D, ..., D> with 64 types
return vector_return_type<void, decltype(cast<D>(get<Is>(s)))...>{...};

// FAST: D is already known, skip common_type entirely
return vector_return_type<D, decltype(cast<D>(get<Is>(s)))...>{...};
```

### Add fold-expression fast paths for common patterns

```cpp
// reduce_tuple_mul for tuple<number<>...>: fold expression instead of recursive reduction
template<typename... Ns, std::enable_if_t<(is_constant_v<Ns> && ...), bool> = true>
constexpr auto reduce_tuple_mul(const tuple<Ns...>&) { return tuple<number<(Ns::value * ...)>>{}; }
```

## 5. Parallel Compilation

### Split device test files by template-instantiation cost

One file with 14 MFMA template instantiations (~3.9s) bottlenecks parallel builds. Split into per-type files (f16/f32/f8) to balance workload:

```
test_mfma.cu (3.9s) -> test_mfma_f16.cu (0.9s) + test_mfma_f32.cu (0.5s) + test_mfma_f8.cu (0.9s)
```

### Use `hipcc --genco` for device-only compilation when launching from Python

Eliminates the host pass entirely. Python loads the `.hsaco` via `hipModuleLoad` and launches with `hipModuleLaunchKernel` (HIP driver API).

## Compile-Time Measurement

### Use `-ftime-trace` for profiling

```bash
hipcc kernel.cc --cuda-device-only -c -o /dev/null \
-Xclang -ftime-trace=trace.json
```

Analyze with chrome://tracing or a script:

```python
import json
with open('trace.json') as f: data = json.load(f)
events = data.get('traceEvents', data)
inst = [(e['dur'], e['args']['detail']) for e in events
if e.get('name') == 'InstantiateFunction' and 'dur' in e]
inst.sort(key=lambda x: -x[0])
for dur, name in inst[:20]:
print(f"{dur/1000:8.1f}ms {name[:100]}")
```

### Key metrics to track

- **Function instantiations**: total count and per-function time
- **Frontend vs Backend**: frontend = template instantiation, backend = LLVM optimizer + codegen
- **Critical path**: the single slowest template chain determines wall-clock time

## Summary Table

| Technique | Typical savings | Where applied |
|-----------|----------------|---------------|
| **Separate device/host code** (`__HIP_DEVICE_COMPILE__` guard) | **~50% total** | All `.cu`/`.hip` files — always do this first |
| Runtime `for` loops in load/store/MMA | 30-60% frontend | `buffer_view::load/store`, `tiled_mma_adaptor::operator()` |
| Runtime `flat_to_coords` | 40-50% frontend | `layout_to_offsets` |
| `__builtin_convertvector` | 5-10% frontend | `cast` for vectors >16 elements |
| `__builtin_shufflevector` | 3-5% frontend | `slice_impl` for vectors |
| Cache constexpr members | 10-15% frontend | `layout_load_traits`, `mma_a/b/c_len` |
| Direct indexing (bypass concat_tuple) | 5-10% frontend | `unfold_x_stride`, `pickup_shape`, `flatten_tuple` |
| `-D__HIPCC_RTC__` | ~25% per-file | Compiler flags |
| `hipcc --genco` | ~15% per-file | Python-launched kernels |
| Split large TU files | Better parallelism | Test suites, multi-kernel builds |
16 changes: 12 additions & 4 deletions .github/runner-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Used by frameworks-devops-dashboard to display GPU architecture
# Update this when runners are added/changed in CI workflows
runners:
aiter-1gpu-runner:
gpu_arch: MI325
linux-aiter-mi300x-1:
gpu_arch: MI300X
gpu_count: 1

aiter-8gpu-runner:
gpu_arch: MI325
linux-aiter-mi300x-8:
gpu_arch: MI300X
gpu_count: 8

linux-aiter-mi355-1:
Expand All @@ -17,3 +17,11 @@ runners:
linux-aiter-mi355-8:
gpu_arch: MI355
gpu_count: 8

linux-aiter-mi35x-1:
gpu_arch: MI35X
gpu_count: 1

linux-aiter-mi35x-8:
gpu_arch: MI35X
gpu_count: 8
Loading
Loading