Repository navigation
[Triton/Gluon] Updates to causal_conv1d_split_qkv kernel - #7028
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
The window kernel mishandles strided cache indices and can overwrite another sequence’s state, while the gfx942 test incorrectly requires a window launch when no window configuration exists.
2 open issues
What changed in this PR
This PR targets long-input prefill slowdowns in the gated-delta-net causal convolution path. It adds a sliding-window implementation for channel-contiguous inputs while retaining the existing tiled fallback.
Changes:
- Add width-4 sliding-window dispatch with gfx950 and gfx1250 configs and an environment opt-out.
- Adjust tiled-kernel sizing and Q/K/V stores, and reuse shared activation helpers.
- Add correctness tests and a benchmark comparing window and tiled paths.
| File | Description |
|---|---|
op_tests/triton_tests/gated_delta_net/test_causal_conv1d_prefill.py |
Add correctness, state-layout, and dispatch tests. |
op_tests/op_benchmarks/triton/bench_causal_conv1d_prefill.py |
Compare window and tiled prefill latency. |
aiter/ops/triton/gated_delta_net/causal_conv1d_prefill.py |
Dispatch eligible inputs to the window kernel and adjust fallback tiling. |
aiter/ops/triton/configs/gfx950/triton/conv/causal_conv1d_split_qkv/DEFAULT.json |
Add gfx950 window-kernel configs. |
aiter/ops/triton/configs/gfx1250/triton/conv/causal_conv1d_split_qkv/DEFAULT.json |
Add gfx1250 window-kernel configs. |
aiter/ops/triton/_triton_kernels/gated_delta_net/prefill/causal_conv1d_fwd_split_qkv.py |
Implement sliding windows and optimize aligned Q/K/V stores. |
aiter/ops/triton/_triton_kernels/common/segment_tile.py |
Add a lower-bound helper for sequence lookup. |
aiter/ops/triton/_triton_kernels/common/activation.py |
Add a shared fast SiLU helper. |
Review effort: Balanced
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
9c284f6 to
997f935
Compare
Window kernel read cache_indices with unit stride, so strided indices (e.g. indices[::2]) hit wrong conv-state slots. Pass the stride as the tiled path does. Send non-contiguous weights to the tiled kernel instead of copying them. Selection test now accounts for archs without a window config and sets the env flag explicitly.
f1dea04 to
5e18409
Compare
Resolve the conflict with the plugin route on causal_conv1d_split_qkv_triton_tile_fn (#8075): keep the route and its provider contract alongside the window kernel. Keep block_n: int = 32 so the routed contract (tests/plugin_contracts.json) is unchanged; the window kernel does not read block_n. Pass pad_slot_id to _window_config in the benchmark.
There was a problem hiding this comment.
🟡 Changes recommended
The dispatch gate admits broadcast inputs that violate the window kernel’s stride precondition, while the benchmark bypasses the required harness and ignores its options.
2 open issues
3 resolved since last review
Review effort: Balanced
…ench Broadcast x (token stride 0) now takes the 2D-tiled path, as the window kernel assumes stride_x > 0. The benchmark uses RotatingBufferBench with the --graph-* and --rot-bufs-* options and shares the unit test's input generator.



Motivation
slowdown when ISL increased on Kimi K3 when this kernel was called
Test Plan
Benchmark, Unit tests, e2e perf/accuracy
Test Result
e2e numbers (32k isl 32 osl 32 conc 32 prompts)
e2e accuracy verified with gsm8k
All benchmarks pass (bit exact result as before)
benchmark numbers:
Submission Checklist
PR Self-Review
Reviewed revision
4e7d587
Behavior and intent
causal_conv1d_split_qkv_triton_tile_fngot slow on Kimi-K3 prefill as ISL grew. In vLLM, x is a column slice of the row-major projection output (unit channel stride). The 2D-tiled kernel reads along tokens, so those loads are strided and poorly vectorized.This PR adds a sliding-window kernel for that case. Each program loads x rows along channels (16 B per lane) and keeps the 4-tap window in registers. Head programs handle the first 3 tokens and the conv-state update of each sequence. The wrapper picks this kernel only when all of these hold:
dim == 2*k_dim + v_dimBDdividesk_dimandv_dimIn every other case it falls back to the 2D-tiled kernel.
AITER_CONV1D_SPLIT_QKV_WINDOW=0turns the window kernel off.Other changes:
block_nnow defaults to 16 B per lane for channel-contiguous x, and stays 32 otherwise.QKV_ALIGNED) do a single store._silu_exp2_fast, which is the samev_rcp_f32path that was inline asm before._silu_exp2._silu_exp2_fastand_lower_bound.cache_indices' stride, so strided indices such asindices[::2]work. No copies are added.Validation and unverified scope
Validated on MI355X (gfx950), torch 2.13.0+rocm10.0.0, triton 3.8.0, at the revision above:
pytest op_tests/triton_tests/gated_delta_net/test_causal_conv1d_prefill.py: 46 passed.cache_indicestest fails on the window kernel when the stride is forced to 1, and passes with the fix.python op_tests/op_benchmarks/triton/bench_causal_conv1d_prefill.py. Times are CUDA-graph replays, Kimi-K3 TP8 shapes (q/k/v = 1536), block_m=8. The baseline is this PR's 2D-tiled kernel with the window kernel off:cache_indicesstride, sends non-contiguous weights to the tiled kernel, and touches tests.Not verified:
AITER_CONV1D_SPLIT_QKV_WINDOW=0tests on gfx950 but was not run on gfx942 itself.exptoexp2, which can change the last bits.PR-specific question
The new configs are
CAUSAL_CONV1D_SPLIT_QKVinconfigs/{gfx950,gfx1250}/triton/conv/causal_conv1d_split_qkv/DEFAULT.json. Only the window kernel reads them, throughget_conv_config(..., M=cu_seqlen), where M is the total number of tokens in the batch:M_LEQ_2048: R=4, BC=4, BD=256any: R=4, BC=8, BD=512If
BDdoesn't dividek_dimandv_dim, the wrapper halvesBDand doublesR(down to BD=64). If that still doesn't divide, it falls back to the tiled kernel.Evidence that unrelated shapes keep their previous selection:
test_token_contiguous_x_uses_2d_kernelchecks for zero window launches.AITER_CONV1D_SPLIT_QKV_WINDOW=0and archs with no config select the 2D-tiled kernel.test_window_kernel_selectionchecks this againsthas_conv_config.causal_conv1d_split_qkv_triton_fn(1D) and the other conv backends don't read these configs.The 2D-tiled kernel's own launch did change for channel-contiguous x (
block_ndefault and theQKV_ALIGNEDsingle store).test_2d_tiled_kernel_kimi_k3_shapescovers that. Token-contiguous x keepsblock_n=32.Changed op tests
op_tests/triton_tests/gated_delta_net/test_causal_conv1d_prefill.py(new): no existing test coveredcausal_conv1d_split_qkv_triton_tile_fnwith channel-contiguous x, which is the layout vLLM passes. It checks q/k/v and the updated conv states against an fp32 reference. Cases:SEQ_VEC)cache_indicesop_tests/op_benchmarks/triton/bench_causal_conv1d_prefill.py(new): no benchmark existed for this op. It times the window kernel against the 2D-tiled kernel on Kimi-K3 prefill shapes, called the way vLLM calls it (block_m=8, prebuilt metadata, CUDA graphs), and reports speedup and TB/s.Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.