Skip to content

[FlyDSL] [CI] [Kernel] Add a fused Kimi-K3 KDA target-verify kernel on gfx942 and gfx950 - #7529

Closed
yuychang wants to merge 62 commits into
ROCm:mainfrom
yuychang:k3/kda-verify-flydsl-pr
Closed

yuychang wants to merge 62 commits into
ROCm:mainfrom
yuychang:k3/kda-verify-flydsl-pr

Conversation

@yuychang

@yuychang yuychang commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds flydsl_kda_verify_with_f_b: Kimi-K3 KDA target verify of T draft tokens per sequence in one FlyDSL launch.
    • gfx942 and gfx950; tuned on gfx950.
    • Fuses per token: f_b projection, Q/K/V short conv, decay gate, gated delta rule, gated RMSNorm.
    • Verify semantics: conv_state and state are read-only.
    • Each step writes its conv window plus either a state snapshot or a ReplaySSM ring record.
    • FP32 or BF16 state, 1 to 8 tokens, 4 or 8 waves per workgroup.

Motivation

  • SGLang verifies KDA drafts with an unfused chain per layer.
    • The chain: f_b GEMM, causal_conv1d_update, Triton target verify, rms_norm_gated.
  • 69 KDA layers per verify step make that chain visible in the DSpark verify step at medium and large batch.
  • One kernel keeps the intermediates on chip and removes three launches per layer.

Changes

  • kernels/kda_verify.py (new): create_kda_verify_kernel(...)
    • Specializations are cached per device (device_index keys the cache, maxsize=1024, graph-safe).
  • linear_attention_kernels.py: the flydsl_kda_verify_with_f_b wrapper
    • Validates shapes, dtypes, devices, unit strides and int32 addressing.
    • Requires dense, non-overlapping written buffers; handles padding rows.
    • No written buffer may overlap any input: caches, weights, activations or index tensors (ValueError).
      • This also rejects passing output_gate storage as out.
    • Wave count: 8 while batch x 12 workgroups fit the CUs (ring <= 1x CUs, snapshot <= 1.25x CUs), else 4.
    • Tags .state_dtypes, .max_tokens and .num_warps == (4, 8) let callers pre-build before graph capture.
  • aiter/ops/flydsl/__init__.py: lazy exports.
  • op_tests/test_flydsl_kda_verify.py (new): 211 pytest cases plus a timing sweep (-b/-t/-d/-m).
    • The padding test fills scratch with a sentinel and passes a NaN-filled out.
    • The sweep gates on is_flydsl_kda_decode_supported() and on the per-region bounds of the pytest cases.
  • .github/scripts/aiter_test.sh: runs pytest and then the script sweep for the two KDA test files.
  • Contract
    • Rows are dense: sequence b owns rows b*T .. b*T+T-1.
    • cache_indices[b] selects the state/conv slot and intermediate_indices[b] the snapshot/window line.
    • A negative or out-of-range index is padding: zero output, no write.
    • Pass exactly one of intermediate_states and replay_ring ((raw_v, raw_k, g, beta), L >= T).
    • Token 0 matches flydsl_kda_decode_with_f_b at zero tolerance: output and snapshot state, FP32 and BF16.
      • Tested in snapshot mode only.
  • Opt-in slot check (keyword-only validate_slots=False, padding_slot=None; same arguments as [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026's decode)
    • validate_slots=True: host sync, skipped during graph capture.
      • Verify: live intermediate lines must be unique; cache slots must be unique only with a ring.
    • padding_slot=<slot>: the check treats a row on that slot as padding
      • It changes validation only; the kernel still writes those rows.
    • No environment variables are added.

Performance (if applicable)

  • New op, so there is no base-vs-head timing of the same target.
    • SGLang's unfused chain (its own Triton target verify and rms_norm_gated) is not in this tree,
    • so no in-tree before/after can be built.
    • An earlier author before/after table (1.06x-1.44x over the unfused chain) is dropped:
      • its script, SGLang revision and ROCm version were not recorded, so it cannot be reproduced.
  • Kernel time of the verify op alone, one Kimi-K3 KDA layer at TP8 (12 heads x 128), BF16 state, us
    • Reproduce: python op_tests/test_flydsl_kda_verify.py -b 1 2 16 60 -t 5 6 8
    • Run on the code of 9dd0b1a54 (the later head edits a docstring only), single run.
    • MI355X (gfx950, 256 CU), ROCm 10.0.0, torch 2.11.0+rocm10.0.0, FlyDSL 0.5.0, one GPU;
      • warm run_perftest, single run.
T Mode b=1 b=2 b=16 b=60
5 snapshot 20.42 22.64 25.46 44.53
6 snapshot 21.20 23.63 24.29 50.26
8 snapshot 24.66 25.99 29.79 60.43
5 ring 16.97 17.29 19.28 31.48
6 ring 19.20 19.41 21.76 35.66
8 ring 23.73 23.98 26.70 44.95
  • End to end: SGLang Kimi-K3 AgentX, 8x MI355X, one 3600 s hour per arm, off then on (earlier author run)
    • c56: +3.5% tok/s/GPU, P90 ITL -6.8%; c16: P90 ITL -4.5%, throughput flat; c4: flat
    • One round only; repeated hours of this recipe spread by up to ~4%.
    • Not re-measured at this head and not reproducible from this repo:
      • it needs the 8-GPU SGLang server, the Kimi-K3 checkpoint and an AgentX workload;
      • the SGLang and AITER revisions and the ROCm version were not recorded.
  • Wave policy, cold L2 on MI355X over 39 batch sizes x T 5/6/8 x ring/snapshot (BF16 state), earlier author run
    • Historical: its script, ROCm and FlyDSL versions were not recorded, and it was not re-run at this head.
    • Within 2% of the faster wave count everywhere.
    • 4-wave/8-wave time: b24 0.79 (ring), 1.01-1.04 (snapshot); b60 0.64-0.66 and 0.89-0.92.
    • vs a fixed batch-16 cutoff: 2-8% faster at batch 17-26, unchanged elsewhere.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • Docstrings updated

  • User guide updated

  • Performance guide updated

  • No documentation change is needed, with the reason stated below

  • New op with a full docstring; no user-guide page covers the FlyDSL linear-attention ops.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. New API; #6026's decode is unchanged.

PR Self-Review

Reviewed revision

888b8f974a025110f6505f7d08cbf82648070c7d

  • 888b8f974 merges [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head f786d8d37 (exact overlap check fix: merged-run budget, CPU-only)
    • No verify code change.
  • 3392c8a5f merges [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head 258cb0915 (docstring-only change)
  • 9dd0b1a54 merges [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head e460a0f55
    • Head-interleaved alias fix, in-tree crossover sweep; no verify code change
  • b75e612e3 merges [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head e76275d0d and moves the verify slot check to keyword arguments
    • AITER_KDA_DECODE_SLOT_CHECK[_PADDING_SLOT] are gone (HK9);
      • flydsl_kda_verify_with_f_b takes validate_slots / padding_slot like the decode ops.
    • The sweep now also runs the pytest cases' per-region bounds:
      • zeroing one token/head of a batch-60, T=8 output passed the pool-wide ratio (1/5760 < 1e-3) before.
    • The padding-row test passes a NaN-filled out; a new test covers the lazy export and the op's tags.
    • Merges the earlier [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head ee2c3d460 too: decode out overlap check and the FP32-Q/K/V Triton reference.
    • The _check_no_alias helpers now live in [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026; the merge keeps that text and this branch's early-commit note.
    • _slot_blocks splits on the largest-stride axis; verify's rejections are unchanged.
  • Root cause of the Triton baseline's 9.4% region in the script sweep (not a bug; no bound was loosened)
    • Triton keeps the convolved Q/K/V in FP32; _kda_reference rounds them to BF16, as the model and FlyDSL do.
    • Against that reference, 6-15% of one token/head row sits one BF16 ULP away (0.0156 at |x| in [2, 4)).
    • Measured on MI355X, FP32 state, batch 1/16/64/96/128/160/256, worst region over the output rows:
      • Triton vs the BF16-Q/K/V reference: 0.008, 0.063, 0.078, 0.094, 0.094, 0.141, 0.086; 6-9% of rows > 3%.
      • Triton vs a reference without the Q/K/V rounding: 0 at every batch, state exact; BF16 state 0 too.
      • FlyDSL is the mirror image: about 0 vs the BF16 reference, 0.06-0.14 vs the FP32 one.
      • Batch 128 is not special: seeds 1-3 give 0.086, 0.070, 0.148; the worst row moves across heads and tokens.
    • The sweep now checks Triton against _kda_reference(round_qkv=False) with the same 0.03 bound as FlyDSL.
      • Its worst region there is 0.0078 (one element) over batches 1-256 and 4 seeds.
  • 21606a719 and its parents (review follow-up)
  • f60fb7e11 merges [FlyDSL] [CI] [Kernel] Add fused KDA decode kernels on gfx942 and gfx950 #6026 head 118109b3a into this branch (its import-time env parsing is gone since the head above)
  • 847d2619e and b93176f40 follow the Copilot review
    • The verify and decode factories take device_index, so each GPU gets its own launcher
      • test_kda_verify_runs_on_a_second_gpu fails before the fix and passes after it
    • _assert_close uses checkAllclose and allows at most 1% mismatches per token/head and snapshot head
      • Worst measured regions: 23 of 16384 snapshot values, 1 of 128 ring-g values
    • The sweep gates on get_gfx_runtime().
  • f756f7d70 merges main 5c1489c24; the only conflict, .github/scripts/aiter_test.sh, keeps both sides.

Behavior and intent

Validation and unverified scope

  • Head 888b8f974 (MI355X gfx950, ROCm 10.0.0, torch 2.11.0+rocm10.0.0, FlyDSL 0.5.0, one GPU)
    • pytest -q op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py: 463 passed, 4 skipped
  • Head 3392c8a5f (docstring-only over 9dd0b1a54); tests re-run on 9dd0b1a54 code
    • MI355X gfx950, ROCm 10.0.0, torch 2.11.0+rocm10.0.0, FlyDSL 0.5.0, one GPU
    • pytest -q op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py:
      • 456 passed, 4 skipped (need 2 GPUs)
  • Head b75e612e3 (same machine)
    • pytest -q op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py:
      • 454 passed, 4 skipped (need 2 GPUs); the verify file has 211 cases (209 passed, 2 skipped)
    • Script sweep python op_tests/test_flydsl_kda_verify.py -b 1 2 16 60 -t 5 6 8:
      • exit 0 with the per-region gate (table under Performance)
  • Head 55b04411c (same machine): 446 passed, 4 skipped; sweep -b 1 16 -t 5 exit 0, all errors 0
  • Review follow-up, head 21606a719 (same machine)
    • pytest -q op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py:
      • 432 passed, 4 skipped (need 2 GPUs); the verify file adds 3 cases
    • With the alias-check tuple cut back to the weights and caches,
      • the two new rejection tests fail (done by patching _check_no_alias in-process)
    • Script sweep python op_tests/test_flydsl_kda_verify.py -b 1 16 -t 5: exit 0, 4 rows on gfx950, all errors 0
  • Head f60fb7e11 (MI355X gfx950, ROCm 10.0.0, torch 2.11.0+rocm10.0.0, GPU 0)
    • pytest -q op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py:
      • 429 passed, 4 skipped (need 2 GPUs)
    • Repeated on GPU 0 at f60fb7e11: the same command, 429 passed, 4 skipped (need 2 GPUs)
    • validate-kernel-pr was not run at this head
  • Historical author runs (logs not kept)
    • MI355X (gfx950), ROCm 7.2
      • At 847d2619e, 2 GPUs: pytest op_tests/test_flydsl_kda_verify.py op_tests/test_flydsl_linear_attention.py:
        • 432 passed
      • At f756f7d70: the same command, 428 passed
      • Earlier run (revision not recorded): pytest -q op_tests/test_flydsl_kda_verify.py 189 passed;
        • pytest -q op_tests/test_flydsl_linear_attention.py -k kda 184 passed
    • MI300X (gfx942, 304 CU), FlyDSL 0.4.2, at 0057b5211
      • pytest -q op_tests/test_flydsl_kda_verify.py: 205 passed
      • With test_flydsl_linear_attention.py: 407 passed, 21 skipped (existing gfx950-only GDN varlen)
      • validate-kernel-pr (pre-push local head) PASS on both files
        • Verify file: independent (batch, num_tokens) grid of 117 cases
        • KDA decode file: 182 cases, perf 0.998 vs base
  • Coverage
    • Snapshot and ring; FP32/BF16 state; T = 1/2/5/6/8; 4 and 8 waves
    • Padding rows; SGLang's strided pool layouts; CUDA-graph replay bit-exact vs eager; 4 GiB slot offsets
    • Rejection of int32 overflow, unsafe layouts and written buffers overlapping a weight
    • Duplicate-slot check: unique cache slots required only in ring mode; the padding slot may repeat
  • End to end, Kimi-K3 GSM8K (200 questions, real acceptance)
    • Not repeated at this head.
    • 98.0-98.5% with the kernel vs 98.5-99.0% without; accept length 3.96 vs 3.99-4.02
    • At c4f41fbce with SGLang #48701 head 3a9117f078: 98.0% in both modes vs 98.0-98.5%;
      • accept 4.04-4.05 vs 4.05-4.11
  • Unverified
    • Any speedup over SGLang's unfused chain, and the end-to-end gain (see Performance)
    • SGLang end to end on gfx942; gfx942-specific tuning (wave thresholds were measured on MI355X)
    • MI300X at the current head 888b8f974 (the last MI300X run is at 0057b5211), and the 2-GPU cases at this head
    • End-to-end accuracy at this head

PR-specific question

  • aiter_test.sh only adds a case arm that runs pytest and then the script for two op_tests/ files.
    • It runs inside the existing op-test job: no new workflow, trigger, permission, secret or token.
  • Fork PR code already runs in this job unchanged; this change gives it no new privileged path.
  • No PR text is interpolated: the arm passes only the file path, as $1 to bash -c.

Changed op tests

🤖 Generated with Claude Code

yuychang and others added 19 commits October 29, 2026 01:49
- Add create_kda_decode_kernel to kernels/gdr_decode.py: KDA is the gated delta rule with a per-channel decay
- Fixed to the Kimi-K3 TP8 layout on gfx950: 12 local heads, 128-dim state, 256-thread blocks
- One launch fuses the width-4 Q/K/V causal conv, L2 norm, FP32 recurrent-state update and gated RMSNorm output
- fuse_f_b selects a variant that computes the head-local f_b projection in FP32 and keeps the BF16 gate in LDS
- The two variants share one kernel body; they differ in gate source, LDS layout and waves-per-EU (3 vs 2)
- state_dtype "f32" or "bf16": BF16 state is widened on load, updated in FP32 and rounded back on store
- State moves in 16-byte transactions (f32x4 or bf16x8); the FP32 kernels keep names without a dtype suffix
- Negative or out-of-range state indices zero the output and leave both caches untouched; slot 0 is live
- Cache slots are rebased with 64-bit byte offsets, so state and conv caches larger than 4 GiB work
- Specializations are cached per (norm_eps, lower_bound, fuse_f_b, state_dtype) and reuse the module's _LOG2E
…ps.flydsl

- Add flydsl_kda_decode and flydsl_kda_decode_with_f_b to linear_attention_kernels.py, next to flydsl_gdr_decode
- Add is_flydsl_kda_decode_supported(device): true for a visible device index when get_gfx_runtime() reports gfx950
- conv_state may be channel-major [cache, 4608, 3] or SGLang's width-major [cache, 3, 4608] seen via transpose(-1, -2)
- Validate shapes, dtypes, devices, dense non-overlapping cache slots, out row layout and int32 buffer addressing
- Cache slot strides are passed as int64; slots beyond min(state, conv_state) capacity are treated as padding
- Accept an FP32 or BF16 state and advertise it as state_dtypes; set zeroes_invalid_output = True on both APIs
- Accept a preallocated out buffer, as SGLang's KDA backend passes out=
- AITER_KDA_DECODE_SLOT_CHECK=1 rejects duplicate live state_indices; read once at import, skipped in graph capture
- Document that live slots must be unique and that the fused f_b projection pays off only at decode batch sizes
- Export the three APIs lazily from aiter.ops.flydsl
…n baseline

- Extend op_tests/test_flydsl_linear_attention.py next to the GDR tests; KDA tests skip unless the device is gfx950
- Check both APIs against an FP32 torch reference for both conv layouts at batch 1/8/16/64/128, FP32 and BF16 state
- Check BF16 state at batch 1/2/8/64/128 with dense or padded slots and over recurrent sequences; reject fp16/fp64
- Cover negative, out-of-range and slot-0 indices, the opt-in duplicate-slot check and >4 GiB cache slot offsets
- Cover input validation, unsafe and padded out layouts, int32 address overflow bounds and the public exports
- test_flydsl_kda_decode times flydsl, flydsl_f_b and Triton fused_kda_decode (width-major only) into a preallocated out
- Batches above 16 allow a 1e-3 mismatch ratio for one-ULP BF16 state rounding ties; conv state must match exactly
- main() adds --conv-layout and --state-dtype axes and a KDA summary table, run only when get_gfx() is gfx950
… broadcasts

- Check AITER_KDA_DECODE_SLOT_CHECK's capture state on the input's device, not the current one.
- Document that the debug slot check also flags SGLang's eager DP padding rows sharing scratch slot 0.
- Reject a conv_weight with no unit-stride axis before compiling; FlyDSL's tensor argument needs one.
- Size the KDA specialization cache like the GDR caches (1024), so captured graphs never outlive their module.
- Drop three shuffle_idx broadcasts: the xor butterfly already leaves the K-group sum in all eight lanes.
- MI355X graph replay, batch 1/32/128 with FP32 and BF16 state: within +-2% of the previous kernel.
- Add a test for the conv_weight stride check; 197 tests pass with FLYDSL_RUNTIME_ENABLE_CACHE=0.
…ion sweep

- aiter_test.sh ran op_tests/test_flydsl_linear_attention.py only as a script, which runs the benchmark sweep.
- Run pytest and the sweep for that file and fail the step if either fails.
…it for bit

- Capture both APIs (plain and fused f_b) with FP32 and BF16 state, rewrite inputs in place, replay three steps.
- Output, recurrent state and conv state must equal an eager run exactly; a stale captured f_a fails the fused cases.
# Conflicts:
#	.github/scripts/aiter_test.sh
… cover odd batches

- An independent grid failed batch 3: a BF16 rounding tie moved 23 of 983040 FP32 state elements by <= 4.9e-6.
- Ties occur at any batch (worst 6.9e-5 over batch 1-256 on MI355X), so use _TOL_ERR_RATIO for every batch.
- Parametrize batch 3 and 33; the pytest check skips the Triton baseline, which stays in the benchmark sweep.
- is_flydsl_kda_decode_supported(device) range-checked device but returned the cached first-GPU arch.
- Read gcnArchName of the device asked about, and require FlyDSL's build target (GDR_GPU_ARCH) to be gfx950 too.
- Memoize the answer per device index, so eager calls skip the get_device_properties query.
- Test a mocked gfx942 device, a non-gfx950 build target, the per-device memo and an out-of-range index.
…s-outer

- The out check required stride(1) >= 11 * stride(2) + 128, so it rejected valid heads-outer [H, B, D] storage.
- Add _check_disjoint_rows: by increasing stride, each row dim must step past what the narrower dims span.
- Batch-outer layouts, padded rows and batch 1 keep their previous answer.
- Test padded heads-outer outputs against the reference, plus two overlapping heads-outer rejects.
…padding

- SGLang's eager DP-attention padding rows all map to its reserved mamba slot 0, so the opt-in check always fired there.
- AITER_KDA_DECODE_SLOT_CHECK_PADDING_SLOT=<slot> lets that slot repeat like a negative index; unset keeps it live.
- Mask the slot at the decode call site, so _check_unique_live_slots and its signature stay unchanged.
- The kernel still decodes the slot; only the debug check changes. A non-integer value fails at import.
- Test the default, the opt-in, a repeated live slot alongside it, and the env parsing.
- conv_weight, A_log and dt_bias must be FP32, norm_weight and activations BF16; the validation already enforces it.
- Note that the Triton fused_kda_decode also takes BF16 conv_weight and FP32 norm_weight, so callers cast once at load.
- _kda_reference skipped only negative slots; the kernel also pads slots >= min(state, conv_state) slot counts.
- Skip those too, so the reference states the documented contract instead of indexing past the cache.
- The out-of-range test now mixes in a live row and checks output and both caches against the reference.
- Seven KDA tests bound the generated KdaInputs to `seed`, next to helpers whose `seed` is the RNG integer.
- Rename them to `base_inputs`; no behaviour change.
- flydsl_kda_verify_with_f_b runs f_b, Q/K/V conv, decay gate, delta rule and gated RMSNorm for T tokens in one launch
- Verify semantics: conv_state and state stay read-only; writes conv windows and state snapshots or ReplaySSM rings
- FP32 or BF16 recurrent state, 1 to 8 tokens; 8 waves up to batch 16 and 4 waves above, measured on MI355X
- Token 0 matches flydsl_kda_decode_with_f_b bit for bit; op test covers snapshot/ring, padding rows and SGLang layouts
…ted 16-wave build

- Reject overlapping intermediate_conv_window, intermediate_states and replay_ring layouts with dense-slot checks
- Keep the channel-major and SGLang transposed conv windows and pool slices whose slot stride exceeds one slot
- Require a unit-stride conv_weight axis, as the decode wrapper does
- Slot check: query capture on the launch device and also reject repeated live intermediate_indices
- Treat a sequence as live only when both indices are in range, as the kernel does
- KDA_VERIFY_NUM_WARPS is (4, 8); tag flydsl_kda_verify_with_f_b.num_warps so callers can pre-build before capture
- Size the specialization cache to 1024 so graph-captured kernels are not evicted
- Fix stale wave-count comments and record the measured 4- vs 8-wave crossover
- Drop the unused _KDA_PROJECTION_ITERS import and apply black
- Parametrize the reference matrix over flydsl_kda_verify_with_f_b.num_warps so both wave counts are checked
- Add CUDA-graph replay (bit-exact vs eager) and 4 GiB slot offsets via strided views of one shared buffer
- Add rejection tests for unsafe write layouts, int32 addressing overflow, conv_weight stride and num_warps=16
- Cover AITER_KDA_DECODE_SLOT_CHECK for duplicate live cache and intermediate indices, and padded pool slices
- Make the script sweep assert on numeric mismatches instead of only logging them
- Rename the state dtype flag to the standard -d/--dtype and use a dict literal for C408
- Dispatch op_tests/test_flydsl_kda_verify.py like test_flydsl_linear_attention.py: pytest, then the script sweep
…decode padding slot

- Reuse _check_disjoint_rows for the verify out check, so heads-outer layouts pass as they do for decode
- Mask the reserved padding slot (AITER_KDA_DECODE_SLOT_CHECK_PADDING_SLOT) in the verify slot check, as decode does
@yuychang
yuychang requested review from a team and a balanced review from Copilot November 5, 2026 19:35
@github-actions

github-actions Bot commented Nov 5, 2026

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 7529 --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.

@github-actions github-actions Bot changed the title [FlyDSL] [Kernel] Add a fused Kimi-K3 KDA target-verify kernel on gfx950 [FlyDSL] [CI] [Kernel] Add a fused Kimi-K3 KDA target-verify kernel on gfx950 Nov 5, 2026
@aiter-bot

aiter-bot commented Nov 5, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 81330de57e6c · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

Copilot AI 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.

🟡 Changes recommended

Unchecked overlap between scratch buffers and committed caches can cause verification to overwrite read-only caches and prematurely commit speculative state.

2 open issues
What changed in this PR

Builds on #6026’s fused KDA decode to add an opt-in gfx950 kernel that verifies multiple draft tokens in one launch while keeping committed caches read-only.

Changes:

  • Fuses projection, convolution, recurrence, and gated normalization for 1–8 tokens, with snapshot or replay-ring output.
  • Adds a validated public wrapper, lazy export, and configurable wave counts.
  • Adds correctness, graph-replay, layout-safety, and performance checks, integrated into CI.
File Description
op_tests/​test_flydsl_linear_attention.py Decode regression tests and benchmarks inherited from #6026.
op_tests/​test_flydsl_kda_verify.py New verify correctness tests and benchmark sweep.
aiter/​ops/​flydsl/​linear_attention_kernels.py Verify wrapper, input validation, and specialization selection.
aiter/​ops/​flydsl/​kernels/​kda_verify.py Fused multi-token verify kernel with snapshot and ring modes.
aiter/​ops/​flydsl/​kernels/​gdr_decode.py Decode implementation and shared KDA helpers inherited from #6026.
aiter/​ops/​flydsl/​__init__.py Lazy exports for the KDA APIs.
.github/​scripts/​aiter_test.sh Runs KDA pytest cases and benchmark sweeps in CI.

Review effort: Balanced

Comment thread op_tests/test_flydsl_kda_verify.py Resolved
…lidation

- Slot check: rows on AITER_KDA_DECODE_SLOT_CHECK_PADDING_SLOT are padding for both the cache and intermediate checks
- Snapshot verify only reads conv_state/state, so live sequences may share a cache slot; ring mode still rejects it
- Reject a non-int num_warps (8.0, numpy ints) before the KDA_VERIFY_NUM_WARPS membership check
- Take the base slot count from _num_cache_slots and fold the ring minimum into it, keeping one int32 clamp
- Test reference decides padding like the kernel: min slot count over state, conv_state and every ring tensor
- Add tests for padding-slot masking, a shared snapshot cache slot, a repeated ring slot and num_warps=8.0
- Brings in the FP32-reference Triton check and the decode out-alias check from sweep/pr-6026
- Conflict in _check_no_alias and its helpers: the decode branch now defines them, so its text is kept
- The docstring keeps the verify early-commit rationale
Copilot AI balanced review requested due to automatic review settings November 21, 2026 11:21

Copilot AI 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.

🔵 Needs a closer look

Missing head-matched GPU validation for the fused speculative recurrence and ReplaySSM commit contract leaves numerical accuracy and graph-replay behavior on gfx942 and gfx950 unverified, requiring kernel-maintainer review.

No open issues 🎉

Review effort: Balanced

…s and reject aliased caches

- Drop AITER_KDA_DECODE_SLOT_CHECK[_PADDING_SLOT]; add keyword-only validate_slots and padding_slot to both decode APIs
- Reject a state or conv_state that shares a byte with the other cache or a read-only operand, before compilation
- Pass a NaN-filled out in the padding-slot tests so a row the kernel never zeroes fails them
- Add rejection tests for aliased caches (8 cases; all fail with the check removed)
…ot check to keyword arguments

- Take ROCm#6026's validate_slots / padding_slot keyword arguments; flydsl_kda_verify_with_f_b gets the same two
- The verify slot-check tests pass the arguments instead of patching the removed env flags
- Gate the verify sweep on the per-region bounds of the pytest cases, so one corrupted token/head fails it
- Pass a NaN-filled out in the verify padding-row test so an unzeroed padding row fails it
- Add a test for the lazy export and the state_dtypes / max_tokens / zeroes_invalid_output tags
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:03

Copilot AI 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.

🔵 Needs a closer look

The new GPU recurrence, replay commit contract, and graph-captured launch path lack head-matched runtime validation, with gfx942 and two-GPU coverage still unverified.

No open issues 🎉

Review effort: Balanced

…on crossover reproducible in-tree

- Compare dense byte runs exactly once the span check suspects an overlap, so per-head interleaved buffers pass
- Add a flydsl_proj candidate (BF16 F.linear, then the decode) to the KDA sweep; the docstring cites its crossover
- State that the sweep times are GPU-only and give the host validation cost per eager call
- Add head-interleaved accept cases for both APIs, and capture a graph with validate_slots=True
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:22

Copilot AI 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.

🔵 Needs a closer look

The fused GPU recurrence and ReplaySSM writes lack head-matched runtime validation, with current-head gfx942, two-GPU execution, and end-to-end accuracy explicitly unverified.

No open issues 🎉

Review effort: Balanced

…e in-tree sweep

- Re-ran the sweep for the docstring's numbers; they moved slightly within run-to-run noise
- Fused f_b is faster than F.linear plus decode by about 1-4 us up to batch 32 and slower by 6-23% from batch 64
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:26

Copilot AI 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.

🔵 Needs a closer look

Missing exact-head GPU validation leaves numerical parity, snapshot/ring commit semantics, and gfx942 and multi-GPU behavior requiring runtime review by a GPU reviewer.

No open issues 🎉

Review effort: Balanced

…erlap check

- The run budget multiplied unmerged dimension products, so head-interleaved buffers at batch 171 and up were rejected
- Budget the merged runs of both tensors instead of their product
- Build the run starts on the CPU, so a CUDA default device neither launches kernels nor breaks graph capture
- Add a batch 256 head-interleaved accept case and a graph-capture case; the 4 new cases fail on the old check
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:39

Copilot AI 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.

🔵 Needs a closer look

The fused recurrent GPU kernel and launcher lack head-matched native validation, leaving gfx942 behavior, multi-GPU execution, and end-to-end accuracy unverified.

No open issues 🎉

Review effort: Balanced

- Preserve the PR behavior while integrating upstream changes.
- Fix reviewed regressions and pass the repository pre-commit checks.
- Verify the final candidate with Gemini 4 Argon; GPU validation remains pending.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:12

Copilot AI 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.

🔵 Needs a closer look

The new GPU recurrence and scratch/ring commit contract require human review and head-matched gfx942/gfx950 validation on FlyDSL 0.5.3, which neither the reported runs nor this GPU-unavailable environment establish.

No open issues 🎉

Review effort: Balanced

@yuychang

Copy link
Copy Markdown
Contributor Author

Closing: its only consumer, sgl-project/sglang#48701, is closed. With sgl-amd-mono serving verify steps, only 1-2 of 69 KDA layers still used this kernel.

@yuychang yuychang closed this Nov 28, 2026
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.

5 participants