Skip to content

[HIP] [Perf] Pipeline CSR segments in unsplit OPUS sparse prefill - #6831

Merged
kaiyang-1 merged 1 commit into
ROCm:mainfrom
iraj465:perf/opus-prefill-csr-stream
Nov 5, 2026
Merged

kaiyang-1 merged 1 commit into
ROCm:mainfrom
iraj465:perf/opus-prefill-csr-stream

Conversation

@iraj465

@iraj465 iraj465 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pipeline the unsplit sparse-MLA prefill kernel on gfx950 for BF16/FP16 and H≤32. It traverses prefix and extend CSR tiles as one stream, prefetches the next KV tile, and reduces the softmax denominator after the final tile.

At the previously measured revision cd38b45d, MI350X BF16 complete calls improved 1.101–1.162× in eager mode and 1.083–1.208× per graph-replayed call. For default dispatch at N1024/H32, eager latency fell 293.484 → 252.512 µs. The current head 9450a2fde1d4783d32f8b84b39b79e303944bfa9 has now passed its full 42-case GPU correctness suite, including 10 focused additions to the 32 baseline cases; it has not been re-benchmarked.

Motivation

The unsplit kernel can share traversal and normalization work across prefix and extend segments. Combining their tile loops enables prefetching across the segment boundary and defers repeated denominator reductions. The rewrite preserves CSR masking, optional sinks and empty-row behavior.

Changes

  • Rewrite the unsplit body in gfx950/mla_v4_prefill_a16w16_16mx1_16nx4.hpp and enlarge its probability buffer in the traits header.
  • Keep current lane-offset addressing, public APIs and automatic split selection. Kernels with more than one KV split are unchanged by this patch. The prior measured revision also produced identical split machine code.
  • Handle empty warps explicitly and initialize the maximum with the lowest finite FP32 value to preserve softmax behavior on negative scores.
  • Add 10 focused unsplit cases to the existing 32 cases: BF16/FP16 extend-only and prefix-only inputs, omitted sinks, and the two numerical edge tests. The reference and tolerances are unchanged.
  • Remove unrelated C++ formatting changes, as requested in review. The unsplit kernel body is unchanged from the previously benchmarked revision. The port preserves main’s gfx950/ header placement and renamed shared-argument include.

Performance (if applicable)

These are the retained measurements of cd38b45d21b6eb428ea5c51c5d333f83d6ab1bc8 against 269675dead7aa919c9c5eae09cb42e83a35c6567. This review update is based on 5eccc0c7bd79e5fa4c53376946d692575b6a17ed; it removes formatting and redundant tests, and preserves the upstream header relocation and shared-argument include. The updated head has not been re-benchmarked.

MI350X, gfx950, 256 CUs; PyTorch 2.11.0+rocm7.2, HIP 7.2.26015. BF16; N={64,128,1024}, H={16,32}, head dimension 512, prefix pool 4096, extend pool 1024, top-k 1024, causal extend indices, optional sink present, scale 1/√512, seed 42. Timed entry: mla_sparse_prefill(..., backend="opus").

N H Requested splits Eager upstream → PR µs Paired speedup Graph upstream → PR µs/call Paired speedup
64 16 1 59.545 → 53.512 1.113× 37.666 → 31.325 1.202×
64 32 1 59.817 → 53.569 1.117× 38.168 → 31.593 1.208×
128 16 1 61.649 → 56.000 1.101× 40.065 → 33.193 1.207×
128 32 1 62.017 → 55.857 1.110× 40.288 → 33.531 1.202×
1024 16 1 160.331 → 140.208 1.144× 138.551 → 124.503 1.113×
1024 16 auto 160.437 → 140.166 1.145× 138.585 → 124.423 1.114×
1024 32 1 293.362 → 252.727 1.161× 271.545 → 250.695 1.083×
1024 32 auto 293.484 → 252.512 1.162× 271.599 → 250.697 1.083×

All rows above execute the changed unsplit kernel and improved in each of four balanced process pairs. Default dispatch benefits at N1024 in this grid. N64/128 improvements above require explicit split1; automatic dispatch there selects unchanged split kernels. This PR does not retune that choice.

Latencies are arithmetic means of four process means; speedups are geometric means of the four paired upstream/PR ratios. Eager events include Python submission gaps. Graph timing divides a 16-call replay by 16 and excludes repeated Python wrapper work and allocation. Neither is a serving measurement.

Reproduction recipe: exact benchmark helpers and pinned build/run instructions (packaging not re-run on GPU).

Complete benchmark grid, controls and paired measurements

Baseline: 269675dead7aa919c9c5eae09cb42e83a35c6567; candidate: cd38b45d21b6eb428ea5c51c5d333f83d6ab1bc8. Image: lmsysorg/sglang@sha256:3a78acc9d6c191f1a12c7c67631657580f06af3af562c9ee6d88282a71ec5e96; GPU_ARCHS=gfx950, ENABLE_CK=0; no CU masks.

Four fresh process pairs ran upstream/PR, PR/upstream, PR/upstream, upstream/PR. Each process recorded 101 eager samples and 101 graph replays per row. Initial synchronized warmup was ≥0.5 s; later rows, capture and replay each used ≥0.05 s and at least five calls. JIT compilation, inputs, reference computation and artifact writes were outside timing. All samples were retained without filtering or control correction.

Eager complete-call measurements:

N H Requested / actual splits Path Upstream µs PR µs Δ µs Paired GM
64 16 1 / 1 Changed 59.544705 53.512022 6.032683 1.112723202×
64 16 auto / 6 Control 49.593639 49.625408 -0.031770 0.999357115×
64 32 1 / 1 Changed 59.817267 53.569131 6.248136 1.116599528×
64 32 auto / 3 Control 56.429205 56.115413 0.313792 1.005574454×
128 16 1 / 1 Changed 61.648666 56.000166 5.648500 1.100950804×
128 16 auto / 3 Control 58.449725 58.186970 0.262755 1.004494274×
128 32 1 / 1 Changed 62.016713 55.856802 6.159911 1.110277490×
128 32 auto / 2 Control 67.406639 67.417817 -0.011178 0.999832634×
1024 16 1 / 1 Changed 160.330995 140.208203 20.122792 1.143518959×
1024 16 auto / 1 Changed 160.436743 140.166188 20.270554 1.144616617×
1024 32 1 / 1 Changed 293.362260 252.727114 40.635146 1.160786842×
1024 32 auto / 1 Changed 293.483955 252.512079 40.971875 1.162256290×

Graph replay, per complete call:

N H Requested / actual splits Path Upstream µs PR µs Δ µs Paired GM
64 16 1 / 1 Changed 37.665992 31.325476 6.340516 1.202408819×
64 16 auto / 6 Control 21.092741 21.109235 -0.016494 0.999216776×
64 32 1 / 1 Changed 38.168077 31.592553 6.575524 1.208135241×
64 32 auto / 3 Control 27.582174 27.596723 -0.014549 0.999476141×
128 16 1 / 1 Changed 40.065389 33.193143 6.872246 1.207039292×
128 16 auto / 3 Control 29.715407 29.748280 -0.032873 0.998894769×
128 32 1 / 1 Changed 40.288494 33.531261 6.757233 1.201520071×
128 32 auto / 2 Control 38.783026 38.753409 0.029617 1.000763436×
1024 16 1 / 1 Changed 138.550765 124.502725 14.048040 1.112837003×
1024 16 auto / 1 Changed 138.584936 124.423491 14.161445 1.113816868×
1024 32 1 / 1 Changed 271.545041 250.694834 20.850207 1.083173895×
1024 32 auto / 1 Changed 271.599430 250.697113 20.902318 1.083381510×

Automatic N64/128 controls selected 6/3/3/2 splits. Their small deviations are not implementation gains or a universal noise bound. At N128/H32, the PR's explicit split1 measured 33.531261 µs graph / 55.856802 µs eager, compared with 38.753409 / 67.417817 µs for automatic split2; the default caller still uses split2.

In the table, B is upstream and C is this PR. Upstream-first order uses cycles 1 and 4; PR-first order uses cycles 2 and 3. Values below are upstream/PR regardless of execution order. Median GM is the geometric mean of four ratios of within-process medians; it does not replace the primary mean estimator.

N / H / requested splits Mode Pair 1 Pair 2 Pair 3 Pair 4 GM B/C GM C/B Median GM
64 / 16 / 1 Eager 1.112146954 1.111093973 1.123396271 1.104339557 1.108236380 1.117228188 1.111545556
64 / 16 / 1 Graph/call 1.191789881 1.209547354 1.211869044 1.196548619 1.194166879 1.210707643 1.202803397
64 / 16 / auto Eager 0.995431344 0.989125993 1.019081279 0.994056538 0.994743704 1.003991923 0.997146892
64 / 16 / auto Graph/call 0.995046170 0.998475750 1.006330173 0.997051562 0.996048361 1.002395269 0.999494992
64 / 32 / 1 Eager 1.102238130 1.121069303 1.131252420 1.112044963 1.107130688 1.126149352 1.117829749
64 / 32 / 1 Graph/call 1.206521540 1.208543118 1.209225825 1.208252126 1.207386523 1.208884424 1.207696132
64 / 32 / auto Eager 1.015598163 1.004714833 1.017170977 0.985140664 1.000253492 1.010923720 1.005185999
64 / 32 / auto Graph/call 1.003987551 0.996719257 0.999537238 0.997676103 1.000826852 0.998127253 0.999528648
128 / 16 / 1 Eager 1.103596942 1.112196988 1.085415366 1.102766293 1.103181539 1.098724579 1.116619541
128 / 16 / 1 Graph/call 1.208018525 1.206783025 1.205885749 1.207470920 1.207744692 1.206334304 1.206504436
128 / 16 / auto Eager 1.008848480 0.998062654 1.017621777 0.993618619 1.001204591 1.007794766 1.003423274
128 / 16 / auto Graph/call 0.999768325 0.999151018 0.997792129 0.998868626 0.999318375 0.998471342 0.998759705
128 / 32 / 1 Eager 1.107246358 1.116060094 1.112344562 1.105490371 1.106368016 1.114200779 1.114721360
128 / 32 / 1 Graph/call 1.204779985 1.197770358 1.202292033 1.201248464 1.203012928 1.200029065 1.201520985
128 / 32 / auto Eager 0.995967815 1.002217049 1.006831876 0.994363522 0.995165345 1.004521812 1.000579734
128 / 32 / auto Graph/call 1.001964704 1.002006685 0.997360298 1.001729814 1.001847252 0.999680792 1.000870479
1024 / 16 / 1 Eager 1.142082434 1.144898012 1.147024702 1.140082957 1.141082258 1.145960864 1.143152826
1024 / 16 / 1 Graph/call 1.116774508 1.108044320 1.115145832 1.111403968 1.114086002 1.111589404 1.126406222
1024 / 16 / auto Eager 1.144265890 1.145416475 1.145841972 1.142944345 1.143604926 1.145629203 1.145011979
1024 / 16 / auto Graph/call 1.113849465 1.113673610 1.116232901 1.111516501 1.112682371 1.114952521 1.128165911
1024 / 32 / 1 Eager 1.157192414 1.160156176 1.161749362 1.164060171 1.160621213 1.160952496 1.160380106
1024 / 32 / 1 Graph/call 1.084605172 1.085685721 1.083159360 1.079256282 1.081927421 1.084421805 1.092857226
1024 / 32 / auto Eager 1.162727772 1.159643897 1.164973687 1.161686152 1.162206845 1.162305737 1.161718030
1024 / 32 / auto Graph/call 1.085081757 1.086088183 1.079970037 1.082396602 1.083738348 1.083024790 1.094292660

Substituting within-process medians preserves the direction in every changed pair. At N1024 the graph median-based GMs are 1.092857–1.128166× versus mean-based GMs 1.083174–1.113817×, so the magnitude depends on the estimator. Captured-call correctness checks cover the final (16th) output before and after timed replay.

Static compiler output reports unsplit VGPR 203→250 (BF16), 202→250 (FP16), SGPR 43→62, LDS 70,144→72,192 bytes and zero reported private allocation/spills. Split machine code and descriptors are identical. Achieved occupancy, bandwidth and traffic were not measured, and the complete gain is not attributed to one individual change.

The available host observations do not establish continuous GPU isolation. The original monitoring-status flags remain false; they are separate from the passing numerical checks and do not establish interference. Other historical revisions are excluded from these performance tables.

Benchmark helper: CSR_6831_NATIVE_BENCH_03.py, SHA256 cb79f58383b98a8c12c87841c35d50ace946b4a2ff556d1f96c0e0d3e32b6315. Result SHA256: 552545840e025af5ab947cf2016746b4baece1618ed9e1efd3890bf7c5437b3a. All 19,392 separately recorded timing rows match the retained raw arrays; source and native-module hashes were checked before and after execution.

Testing

Current review update:

  • Python syntax, Black 26.3.0, Ruff 0.15.7 and git diff --check.
  • The unsplit kernel body matches the previously measured revision apart from formatting. Main’s header relocation and renamed shared-argument include are preserved; unrelated helpers, the pipelined accumulator, epilogue and other traits retain upstream formatting.
  • All 32 baseline cases remain unchanged. The 10 retained input combinations are a subset of the previously passing 118-case expansion, with num_kv_splits=1 in each case.
  • Current-head OPUS Tests (MI35X) passed on gfx950 in rocm/pytorch:rocm7.2.4_ubuntu24.04_py3.12_pytorch_release_2.10.0. These are OPUS primitive/header and device tests; they do not invoke op_tests/test_mla_sparse_prefill.py.
  • Current-head repository dependency, Black and Ruff checks passed.
  • The ATOM DeepSeek-R1-0528 accuracy job attached to this PR head also passed its run and result-check steps. Its uploaded three-shot GSM8K table reports 0.9477 flexible-extract exact match. This is separate hosted integration evidence; it does not qualify the changed sparse-prefill path or its 42-case matrix.
  • Current-head ATOM GPT-OSS-120B accuracy passed: GSM8K three-shot flexible-extract exact match 0.9014404852, above the configured 0.87 threshold. The log records editable AITER at 9450a2f, TP1 and FP8 KV cache. This is hosted integration accuracy; it does not establish execution of the changed sparse-prefill path or replace its 42-case matrix.
  • Local native GPU qualification of current head 9450a2fde1d4783d32f8b84b39b79e303944bfa9 completed on 2026-11-05: 42 collected, 42 passed, zero skips, errors or failures in op_tests/test_mla_sparse_prefill.py, on one visible gfx950 GPU. The 42 JUnit cases match the 42 collected test IDs. The run built module_aiter_core and module_mla_prefill_opus in an initially empty private native JIT directory, verified source and native-module integrity before/after testing, and exited successfully. The source snapshot covers 8,168 files and is unchanged. This is correctness evidence for the current suite; the earlier timing table remains tied to cd38b45d.
  • The current-head hosted Aiter Test workflow subsequently passed: both wheel jobs, all eight MI35X standard-test shards, Standard Test Results and the Aiter Test Gate completed successfully on November 5. The earlier Python 3.12 attempt stopped before compilation on a DockerHub HTTP 429 and skipped its downstream tests; that failed attempt remains historical. These hosted checks are separate from the completed local 42-case qualification and do not add a benchmark or serving result.
    Two separate local attempts stopped before collection. The first built and loaded module_aiter_core, then Triton HIPUtils initialization tried to create /root/.triton on the read-only container root. With a private Triton cache, the second passed that initialization but the C++ interface import tried to create /root/.aiter on the same read-only root. These retained runner cache-path failures produced no sparse-prefill test result and are not observed kernel numerical failures. The third attempt used a private HOME, AITER_JIT_DIR and TRITON_CACHE_DIR, with AITER_ROOT_DIR absent, and completed the 42-case suite successfully.
Current-head native qualification details

Source: 9450a2fde1d4783d32f8b84b39b79e303944bfa9; image: lmsysorg/sglang@sha256:3a78acc9d6c191f1a12c7c67631657580f06af3af562c9ee6d88282a71ec5e96. The isolated source mount was read-only. The run used HOME=/results/home, AITER_JIT_DIR=/results/aiter_jit and TRITON_CACHE_DIR=/results/triton-cache; AITER_ROOT_DIR was unset. The native cache started empty.

After fresh module compilation, the actual suite commands were:

/opt/venv/bin/python3 -B -m pytest -q -rs --override-ini addopts= op_tests/test_mla_sparse_prefill.py --collect-only
/opt/venv/bin/python3 -B -m pytest -q -rs --override-ini addopts= op_tests/test_mla_sparse_prefill.py --junitxml /results/suite.xml

Result: PASSED_42_OF_42; 42 collected, 42 matching JUnit cases passed, zero skips/errors/failures. The container ran 2026-11-05 03:13:50–03:15:10 UTC and exited 0. Qualification-result SHA256: 425e9c57d34730dbb5470b4ccd58c0acdabbd6e27725e825fdfc2a6bcaf6836a; JUnit SHA256: 8adc682b13bf1b6166ff48e485b24c1a270218c641fa1eb40daade81b8754a9f. No timing or serving performance was measured in this qualification.

Prior measured revision cd38b45d21b6eb428ea5c51c5d333f83d6ab1bc8:

  • 142 passed on upstream and 142 on that PR revision, zero failures, errors or skips.
  • All 12 benchmark cases passed finite-output, shape/dtype and numerical checks before/after timing in all eight processes; recorded mismatch counts were zero.
  • Four balanced pairs completed in eager and graph modes on MI350X/gfx950, with all samples retained. Complete ctypes modules compiled in the pinned image.
PYTHONOPTIMIZE=0 python3 -B -m pytest -q -rs --override-ini addopts= op_tests/test_mla_sparse_prefill.py

Tests retain rtol=atol=0.01 and error ratio ≤0.01. The new unsplit cases also check finite output. The current matrix retains BF16, FP8 and NVFP4 coverage; the new cases specifically exercise the modified BF16/FP16 OPUS path. Other GPUs, FP16 performance and serving performance remain unverified.

Documentation

  • Implementation comments explain the unsplit dataflow.
  • No separate user guide change is needed; public API and dispatch are unchanged.

Dependencies

  • No new third-party dependencies added.

Breaking Changes

None. Reduction order and buffering change, with the existing numerical reference and tolerances retained.

PR Self-Review

Reviewed revision

9450a2fde1d4783d32f8b84b39b79e303944bfa9

Behavior and intent

Join prefix/extend CSR tile traversal, stage upcoming KV tiles and defer denominator reduction in the gfx950 H≤32 unsplit kernel. The measured BF16 cases improve while split kernels and automatic split selection remain unchanged.

Validation and unverified scope

The updated head passes Python syntax, Black, Ruff, diff hygiene, and comparison with the measured kernel body, accounting for main’s shared-header include relocation. It retains 10 previously tested additions and the current 32-case matrix. Current-head OPUS primitive/device CI, repository dependency, Black and Ruff checks pass. The OPUS job does not run the 42-case sparse-prefill matrix. Hosted ATOM GPT-OSS GSM8K flexible-extract accuracy also passed (0.9014404852 against 0.87) with current-head AITER; this does not attribute execution to the modified sparse kernel. The current head now also passes the full 42-case local native GPU suite on gfx950 with fresh native compilation and unchanged source/module checks. The subsequent current-head hosted run passed both wheel jobs, all eight MI35X standard-test shards, Standard Test Results and the Aiter Test Gate; its earlier DockerHub HTTP 429 failure remains historical. The earlier 142-case and balanced timing results remain bound to cd38b45. Other GPUs, FP16 performance, serving performance, roofline efficiency and continuous isolation remain unverified.

PR-specific question

The existing dispatcher selects this gfx950 A16W16 kernel for supported BF16/FP16 inputs, head dimension 512 and H≤32. Only resolved split count one enters the changed body; higher counts use unchanged code. Wrapper eligibility is not widened. The 10 new cases force split1. The unchanged baseline matrix retains automatic dispatch, partial heads, CSR transitions/tails and empty pools.

Changed op tests

op_tests/test_mla_sparse_prefill.py adds exactly 10 cases: extend-only and prefix-only inputs in BF16/FP16 (4), mixed segments without a sink in BF16/FP16 (2), extremely negative BF16 logits with no sink or a lower sink (2), and one-key scale-one BF16/FP16 inputs (2). They all force split1 and use the existing FP32 reference and tolerances. The redundant split-K, auto-dispatch, tail, head and empty-pool expansions have been removed.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6831 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@iraj465
iraj465 force-pushed the perf/opus-prefill-csr-stream branch from bc750cf to cd38b45 Compare October 29, 2026 12:51
@iraj465
iraj465 marked this pull request as ready for review October 29, 2026 12:51
@iraj465
iraj465 requested a review from a team October 29, 2026 12:51
@github-actions github-actions Bot changed the title [Perf] Pipeline CSR segments in unsplit OPUS sparse prefill [HIP] [Perf] Pipeline CSR segments in unsplit OPUS sparse prefill Oct 29, 2026
@github-actions github-actions Bot added the HIP label Oct 29, 2026
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 9450a2fde1d4 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Join prefix/extend CSR tile traversal, stage upcoming KV tiles and defer denominator reduction in the gfx950 H≤32 unsplit kernel. The measured BF16 cases improve while split kernels and automatic split selection remain unchanged.

Validation and unverified scope

The updated head passes Python syntax, Black, Ruff, diff hygiene, and comparison with the measured kernel body, accounting for main’s shared-header include relocation. It retains 10 previously tested additions and the current 32-case matrix. Current-head OPUS primitive/device CI, repository dependency, Black and Ruff checks pass. The OPUS job does not run the 42-case sparse-prefill matrix. Hosted ATOM GPT-OSS GSM8K flexible-extract accuracy also passed (0.9014404852 against 0.87) with current-head AITER; this does not attribute execution to the modified sparse kernel. The current head now also passes the full 42-case local native GPU suite on gfx950 with fresh native compilation and unchanged source/module checks. The subsequent current-head hosted run passed both wheel jobs, all eight MI35X standard-test shards, Standard Test Results and the Aiter Test Gate; its earlier DockerHub HTTP 429 failure remains historical. The earlier 142-case and balanced timing results remain bound to cd38b45d. Other GPUs, FP16 performance, serving performance, roofline efficiency and continuous isolation remain unverified.

PR-specific question

The existing dispatcher selects this gfx950 A16W16 kernel for supported BF16/FP16 inputs, head dimension 512 and H≤32. Only resolved split count one enters the changed body; higher counts use unchanged code. Wrapper eligibility is not widened. The 10 new cases force split1. The unchanged baseline matrix retains automatic dispatch, partial heads, CSR transitions/tails and empty pools.

Changed op tests

`op_tests/test_mla_sparse_prefill.py` adds exactly 10 cases: extend-only and prefix-only inputs in BF16/FP16 (4), mixed segments without a sink in BF16/FP16 (2), extremely negative BF16 logits with no sink or a lower sink (2), and one-key scale-one BF16/FP16 inputs (2). They all force split1 and use the existing FP32 reference and tolerances. The redundant split-K, auto-dispatch, tail, head and empty-pool expansions have been removed.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@kaiyang-1

Copy link
Copy Markdown
Contributor

@iraj465 Thanks for this! Prefetching the next tile across the joined prefix/extend stream, and folding the max and sum reductions into the P exchange, is a nice way to cut the exposed latency and barriers. Two requests:

  1. Please keep the diff to the functional change. About two thirds of the C++ diff only reformats code this PR doesn't change (helpers, mla_v4_prefill_accum_pipelined, the epilogue, and other kernels' traits). This looks like the optional clang-format pre-commit hook. CI doesn't enforce it and these files aren't formatted on main, so could you revert those hunks?

  2. Can the new tests be trimmed? The existing _PYTEST_CASES already run the unsplit path (auto resolves to split 1 for the 64x16, 128x24, 256x32 and empty-pool cases) and cover the segment transition, tails, partial heads and empty pools. Many of the 118 new cases repeat these or test split-K, which this PR doesn't change. I'd keep only the gaps, which come to about 10 cases at split 1:

    • extend-only and prefix-only;
    • fp16;
    • no sink;
    • the two extreme-value tests.

Stream prefix and extend CSR tiles through the current gfx950 OPUS kernel. Keep the functional diff and add ten focused unsplit tests while preserving the current precision matrix and relocated headers.

Signed-off-by: Saptarshi Majumder <[email protected]>
@iraj465
iraj465 force-pushed the perf/opus-prefill-csr-stream branch from cd38b45 to 9450a2f Compare November 4, 2026 17:58
@iraj465

iraj465 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. Updated in 9450a2fde1d4783d32f8b84b39b79e303944bfa9:

  • Removed the unrelated clang-format changes. Helpers, the pipelined accumulator, epilogue and other traits retain main's formatting; the diff contains the unsplit rewrite and its probability-buffer sizing.
  • Reduced the 118 added cases to 10, all explicitly split1: extend-only/prefix-only BF16 and FP16 (4), mixed segments without a sink (2), negative-logit no-sink/lower-sink cases (2), and one-key scale-one BF16/FP16 cases (2).
  • Ported the patch onto 5eccc0c7, preserving the new gfx950/ header layout, shared-argument include and current 32-case precision matrix. The suite now contains 42 cases.

Python syntax, Black, Ruff and diff checks pass. The unsplit kernel body is retained from the previously measured revision, apart from formatting. Completed MI350X work on cd38b45d21b6eb428ea5c51c5d333f83d6ab1bc8 includes 142 passing tests on each source and four balanced benchmark pairs: 1.101–1.162× eager and 1.083–1.208× graph speedups on the changed unsplit rows. GitHub also records successful OPUS Tests (MI35X) and the Aiter Test Gate for that commit. These timing and 142-case results remain bound to cd38b45d.

At current head 9450a2fde1d4783d32f8b84b39b79e303944bfa9, OPUS Tests (MI35X) now passed on gfx950 with the ROCm 7.2.4 / PyTorch 2.10.0 image. I checked the log: it runs the OPUS primitive/header, FP4 and device-instruction suites, not op_tests/test_mla_sparse_prefill.py, so this is not the requested 42-case qualification. Black, Ruff and dependency checks also pass.

The earlier Python 3.12 wheel attempt failed before compilation: DockerHub returned 429 Too Many Requests while resolving the image, followed by Docker exit 125 and missing prebuild metadata. Its downstream standard GPU tests were skipped. The subsequent current-head Aiter Test run completed successfully on November 5: both wheel jobs, all eight MI35X standard-test shards, Standard Test Results and the Aiter Test Gate passed. The separate local native run described below qualifies the current 42-case matrix. Neither correctness record adds a kernel speedup or serving result.

The current-head ATOM GPT-OSS-120B accuracy job has also completed successfully. Its three-shot GSM8K flexible-extract exact-match score is 0.9014404852, above the configured 0.87 threshold, using TP1 and FP8 KV cache. The log records installation of editable AITER at 9450a2f. This is integration-accuracy evidence; it does not demonstrate execution of the modified sparse-prefill path or substitute for the 42-case suite.

The ATOM DeepSeek-R1-0528 accuracy job attached to this PR head also completed its accuracy and result-check steps successfully. The uploaded three-shot GSM8K table reports 0.9477 flexible-extract exact match. As with the GPT-OSS result, this does not establish changed sparse-kernel dispatch, the 42-case matrix or performance.

Two local exact-head attempts stopped before test collection. AITER core built and loaded in the first, then Triton HIPUtils initialization hit read-only /root/.triton. After binding a private Triton cache, the second passed that initialization but the C++ interface import hit read-only /root/.aiter. Both runner-environment failures are retained. Neither provides a sparse-kernel numerical or speedup result.

The third local attempt has now completed on current head 9450a2fde1d4783d32f8b84b39b79e303944bfa9: all 42 sparse-prefill GPU cases passed, with zero skips, errors or failures. It ran on one visible gfx950 GPU in lmsysorg/sglang@sha256:3a78acc9d6c191f1a12c7c67631657580f06af3af562c9ee6d88282a71ec5e96, using a private HOME, native JIT and Triton cache (AITER_ROOT_DIR unset). module_aiter_core and module_mla_prefill_opus were built in the initially empty native cache. The 42 executed JUnit cases match collection, the 8,168-file source snapshot and built native modules remained unchanged, and the container exited 0. The completed run was 2026-11-05 03:13:50–03:15:10 UTC; result SHA256 425e9c57d34730dbb5470b4ccd58c0acdabbd6e27725e825fdfc2a6bcaf6836a. The PR body includes the exact pytest commands and qualification environment. This closes the local current-head correctness gap; historical benchmarks remain bound to cd38b45d. The subsequent hosted standard-test CI success is recorded above, with the earlier image-resolution failure retained as history.

@kaiyang-1 kaiyang-1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants