Skip to content

[Triton/Gluon] [GFX950] Keep unified-attention block-table stride runtime - #5772

Merged
cagrikymk merged 1 commit into
ROCm:cagri/unif_2d_gfx950_cleanfrom
vorapolsiloai:fix/pr4614-runtime-block-table-stride-int32
Sep 22, 2026
Merged

cagrikymk merged 1 commit into
ROCm:cagri/unif_2d_gfx950_cleanfrom
vorapolsiloai:fix/pr4614-runtime-block-table-stride-int32

Conversation

@vorapolsiloai

Copy link
Copy Markdown
Contributor

Summary

  • Remove block_table_stride from compile-time AttentionConfig.
  • Pass the stride as runtime tl.int32 state through both gfx950 Gluon KV loaders.
  • Keep the allocated-once KV-cache layout strides as constexpr.
  • Keep the diff code-only, without adding to CI runtime.

Root cause

SGLang serving can produce padded block tables with different row strides across batches. The gfx950 Gluon kernel stored block_table_stride in AttentionConfig, making every new stride part of the JIT compile key.

A matched serving profile observed seven Gluon compilations inside the measured request, adding 5.75 seconds of gaps immediately before unified-attention launches even though the compiled Gluon kernels themselves were faster than the Triton kernels.

The stride is bounded by the per-request block-table width, so runtime tl.int32 is sufficient. AsyncKVLoader and AsyncGatherKVLoader now receive it as runtime state. The gather loader explicitly narrows its clamped block-table indices to gl.int32, as required by the CDNA buffer-load interface.

Validation

Changing-stride probe

The same logical page table was invoked with seven padded strides from 60000 through 60511.

Measurement Compile-time stride Runtime tl.int32 stride
Cold total 5,858.85 ms 2,371.42 ms
Cached total 330.66 ms 332.07 ms
Compile-like cold calls 7 2
Finite-output failures 0 0
Maximum output difference — 6.11e-5

The initial variants are bounded; subsequent changing stride values no longer create a new binary.

Loader coverage

External focused validation exercised changing padded widths through:

  • AsyncGatherKVLoader with block size 1.
  • AsyncKVLoader with block size 64.

Both paths remained finite and produced identical outputs across the tested widths.

Matched serving profile

The same 60K-input, 128-output, concurrency-4 profile was run before and after the change.

Metric Compile-time stride Runtime tl.int32 stride
Successful requests 8/8 8/8
Benchmark duration 130.37 s 108.31 s
Input throughput 3,681.93 tok/s 4,431.69 tok/s
Output throughput 7.85 tok/s 9.45 tok/s
Main-run Gluon compilations 7 0
Prefill gaps 5,724.51 ms 31.22 ms
Decode gaps 8.08 ms 8.04 ms

This is a 20.4% input-throughput recovery and a 16.9% duration reduction, with no main-run compilation left in the trace.

Test plan

  • python3 -m py_compile aiter/ops/triton/_gluon_kernels/gfx950/attention/unified_attention.py
  • Ruff check and format check.
  • Seven-width compile/cache probe.
  • Direct and gather KV-loader output comparison.
  • Matched serving profile with trace inspection.
  • Upstream CI.

Chunked serving rebuilds padded block tables with changing strides, so storing the stride in `AttentionConfig` creates per-width Gluon binaries during live requests. Pass it as runtime `tl.int32` state through both KV loaders while retaining the cache-layout strides as compile-time constants.
@cagrikymk
cagrikymk merged commit dde851c into ROCm:cagri/unif_2d_gfx950_clean Sep 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants