Repository navigation
[FlyDSL] [Feature] Add the Kimi-K3 KDA per-channel decay gate to GDR decode - #4577
waqahmed-amd-fi wants to merge 86 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
… harness Expose the in-package decode check as `check_gdr_decode` so `op_tests` can reuse the Triton reference, and add f32 `dt_bias` test cases against lower-precision queries. The new `op_tests/test_flydsl_gdr_decode.py` covers both package-namespace exports and numeric correctness.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Detect KDA mode from 4D `a` and 2D `dt_bias`; keep the existing GDR scalar path unchanged. - Implement per-channel decay in the FlyDSL kernel as `g_min * sigmoid(exp(A_log) * (a + dt_bias))` with vectorized K loads. - Add a pure-PyTorch KDA reference in `aiter/ops/torch_ref/kda.py`. - Extend op tests to validate the per-channel kernel against the torch reference and pin the reference itself.
K3 decodes at H_k == H_v == 12, which matches no row in gdr_decode_tuned.csv --
every row there is GQA at ratio 2 or 4 -- so the kernel fell back to
NUM_BLOCKS_PER_V_DIM=1, NUM_WARPS=4, WARP_THREADS_K=8. Untuned it is slower than
the Triton kernel it is meant to replace at three of four batch sizes, so the
sweep is what makes this a win rather than a regression.
Adds op_tests/op_benchmarks/flydsl/bench_gdr_decode_kda.py:
--sweep parity-checks all 44 legal configs against the torch reference, then
re-times the top 5 over 5 trials and ranks on the median. A
single-shot argmin is not enough: the leaders land within a few
percent, the same order as run-to-run variation.
--bench A/B against vLLM's fused_recurrent_kda_packed_decode on identical
inputs, with both sides parity-checked so a timing cannot be
reported for a kernel that computes the wrong thing.
gfx950, H=12, K=V=128, bf16 over an f32 state, per-call us:
B Triton untuned tuned speedup
1 7.36 8.94 6.85 1.07x
4 7.87 9.47 7.34 1.07x
64 22.48 23.69 21.00 1.07x
256 79.41 87.49 76.35 1.04x
WARP_THREADS_K is 16 or 32 in every winning row, never the fallback's 8, which
is the register-pressure behaviour the per-channel gate was expected to show.
The four new csv rows are additive: 12x12 appears nowhere in that file, so no
existing shape's config moves and the scalar path stays bit-identical.
Also copies two landmines from vLLM's setup that the tests were missing: the
exact padded-state stride assertion (stride()[1:] == (D*D, D, 1), which pins
that only the outer stride is padded) and a strided state_indices column, which
vLLM parametrizes and a serving stack really does hand over.
The comparator is loaded directly from a vLLM checkout with three stubbed
imports rather than importing vllm, which would drag in pydantic and the rest of
the config stack. The stubs are faithful -- under the default FLA_USE_FAST_OPS=0
vLLM's exp/log are tl.exp/tl.log -- and the script refuses to run if that
variable is set, so it cannot silently benchmark different math.
gfx942 is still outstanding; the ticket asks for both architectures.
…inclusive call_us timing
…bias `a` is vector-loaded along D_k, so require stride(-1)==1 and reject strided views. Drop the dt_bias contiguity assertion since it is copied contiguous below. Add tests covering strided-a rejection and non-contiguous dt_bias acceptance.
samremes
left a comment
There was a problem hiding this comment.
Code-level review only; no tests, builds, imports, or benchmarks were run. The per-channel recurrence math looks consistent with the intended formula. Residual gaps: confirm first-call JIT-only deployment is intentional, and extend automated coverage to the larger supported head counts and target batches.
| ) | ||
| # `a` reaches the kernel with its own strides and is read as vectors | ||
| # along D_k, so that axis has to be dense -- a strided one would be | ||
| # misread, not rejected. dt_bias needs no such check: it is copied |
There was a problem hiding this comment.
High: Allowing non-contiguous dt_bias introduces an explicit-stream race. The later .contiguous() is enqueued on PyTorch's current stream, while _run_compiled launches on the caller-provided stream; the kernel can start reading before the copy completes. The shuffled-state copies have the same issue before and after launch. Please put preprocessing, launch, and postprocessing in the supplied stream context, or add explicit event dependencies.
There was a problem hiding this comment.
Fixed, and it reproduced: with the launch on a side stream and the current stream held busy, the output came back at RMSE ratio 0.98 — the kernel was reading unwritten staging memory.
| dt_bias.dim() == 2 | ||
| ), f"per-channel `a` needs a 2D (H_v, D_k) dt_bias, got {tuple(dt_bias.shape)}" | ||
| assert ( | ||
| a.shape[-1] == query.shape[-1] |
There was a problem hiding this comment.
High: This only checks the last dimension, not the complete a == (B, Sq, H_v, D_k) shape. A consumer-native (1, B, H, K) view passes these checks but the kernel indexes it as (B, Sq, H, K), causing wrong-row or out-of-bounds reads for B > 1. Please validate the full shapes of q/k/v/a/b, indices, state, and out before creating the kernel.
There was a problem hiding this comment.
Fixed. key, value, out, a, b, dt_bias, A_log, read_indices, write_indices and state are now validated against the full (B, Sq, H, D) layout before the kernel is created.
| @@ -105,6 +116,7 @@ def gdr_decode_kernel( | |||
| dtype_ = get_dtype_in_kernel(dtype) | |||
| fx_dtype_ = fx.BFloat16 if dtype == "bf16" else fx.Float16 | |||
There was a problem hiding this comment.
High: Activation and state storage types are still conflated. vec_t is derived from dtype_, so fp16 activations with bf16 state truncate the final state vector to fp16 before the bf16 store. The wrapper also accepts fp32 activations, but this fallback selects fp16 for output conversion. Please restrict activation dtypes to the intended fp16/bf16 set and derive a separate state-store vector type from state_dtype_; add mixed fp16-activation/bf16-state coverage.
There was a problem hiding this comment.
(Probably this mixed case won't ever happen though?)
There was a problem hiding this comment.
Both fixed. The state store derives its vector type from state_dtype_ now, and activations are restricted to fp16/bf16 — asserted in the kernel factory, rejected with a clear error in the wrapper so fp32 callers don't trip an assert deep inside. Added mixed coverage parametrized over both activation types; it fails on fp16 if I revert just the vector type.
On whether it can happen: not today, no tuned row uses fp16 activations. But bf16 state is half the table (2688 rows), fp16 activations are already in the tests, and the two are independent arguments — so only coincidence keeps them apart, and the failure is silent state corruption. The fix costs nothing at runtime and the scalar path stays bit-identical, so I kept it.
| gfx950,torch.bfloat16,torch.float32,254,1,16,64,128,128,8,4,16,360.0035000000007 | ||
| gfx950,torch.bfloat16,torch.float32,255,1,16,64,128,128,8,1,4,361.3235000000004 | ||
| gfx950,torch.bfloat16,torch.float32,256,1,16,64,128,128,8,4,16,362.8634999999995 | ||
| gfx950,torch.bfloat16,torch.float32,1,1,12,12,128,128,8,2,16,6.80 |
There was a problem hiding this comment.
Medium: get_default_kwargs does not include gate_mode in its key, so these per-channel-tuned 12:12 rows are also selected by scalar GDR and change its previous fallback geometry. Please add gate mode to the CSV schema/lookup key, treating existing rows as scalar mode. Also, all four new rows are gfx950-only; gfx942 still takes the untuned fallback despite being an explicit target.
There was a problem hiding this comment.
Fixed. Added a gate_mode column to the CSV and to the lookup key; the 5376 existing rows are tagged gdr, the four new ones kda, and --sweep emits the tag. Scalar GDR at 12:12 is back on the (1,4,8) fallback (new test pins that). The column is appended last so an old-format row still parses as scalar, which is why the diff touches every line.
gfx942 is still outstanding: no gfx942 box available. The rows are additive now that the key distinguishes gates.
| x = a.float() + dt_bias.float() | ||
| A = A_log.float().exp() | ||
| # a is (..., H) or (..., H, K); line A up with the head axis either way. | ||
| A = A if a.shape[-1] == A.shape[0] else A[:, None] |
There was a problem hiding this comment.
Medium: Inferring scalar versus per-channel mode from a.shape[-1] == len(A_log) is ambiguous. For a legal channel shape with H == K, this chooses scalar broadcasting and applies A_log over K instead of H, corrupting the oracle. Please branch on a.dim() and validate the expected shapes explicitly.
There was a problem hiding this comment.
Fixed. kda_gate branches on a.dim() now, and validates the head axis against A_log plus dt_bias against the selected mode, so a tensor meant for the other gate raises instead of broadcasting. Added a square H == K case that fails under the old shape-based rule.
| if not shuffle: | ||
| initial_state = initial_state.transpose(-1, -2) | ||
|
|
||
| kernel_pool = pool.clone() |
There was a problem hiding this comment.
Medium: For the padded, non-dense view built above, pool.clone() materializes contiguous storage, so the kernel never sees the outer padded stride this test claims to exercise. Please clone the padded backing allocation and recreate the view, or use empty_strided(pool.shape, pool.stride()) followed by a copy; assert the resulting kernel pool keeps the original stride.
There was a problem hiding this comment.
Switched to empty_strided(pool.shape, pool.stride()) plus a copy, with the stride assertion you suggested
…ed geometries and 64-head fallback Add test cases for B=1/64/256 with H=12 to exercise the tuned rows in gdr_decode_tuned.csv, and a B=2 H=64 case to cover the fallback geometry past K3's head count.
#4609 removed the `vector`/`arith` imports the per-channel branch still used, and the merge left `r_g_vec` outside the scalar `else`, so building a `gate_mode="kda"` kernel raised NameError. The benchmark's direct kernel call also needed #4573's q/k/v strides and read/write index split. Scalar path bit-identical; 47 tests pass on gfx950.
…opies `a` was checked on D_k alone, so a consumer-native (1, B, H_v, D_k) view was read row-shifted for B > 1. Validate every tensor against query's layout; shape only, since callers pass strided views. The `.contiguous()` staging and state copies ran on the caller's stream while the kernel launched on `stream`, reading unwritten memory. Run them on `stream`, entered only when it is foreign (~5us against a ~7us kernel).
…lar and KDA rows Add `gate_mode` to the `gdr_decode_tuned.csv` schema and use it as a lookup key in `get_default_kwargs()`, so KDA-tuned rows cannot be selected for scalar GDR calls. Update the KDA benchmark to emit `gate_mode=kda` rows and add a regression test ensuring scalar GDR falls back to default configs at 12-head K3 geometries.
samremes
left a comment
There was a problem hiding this comment.
I think the tests need some streamlining.
| ) | ||
|
|
||
|
|
||
| def test_flydsl_gdr_decode_is_importable_from_package_namespace(): |
There was a problem hiding this comment.
I think this test is really quite unnecessary, all test should be only about testing it, not checking if it importable in some specific way.
| assert callable(flydsl_ops.flydsl_gdr_decode) | ||
|
|
||
|
|
||
| def test_flydsl_gdr_decode_is_advertised_in_all(): |
There was a problem hiding this comment.
Same here, not really relevant for testing the kernel itself.
| assert "flydsl_gdr_decode" in flydsl_ops.__all__ | ||
|
|
||
|
|
||
| def test_package_export_is_the_kernel_wrapper_itself(): |
| not is_flydsl_available(), reason="flydsl is not installed" | ||
| ) | ||
|
|
||
| # Skips at import when flydsl or a GPU is missing, taking this module with it. |
There was a problem hiding this comment.
What does this comment mean?
There was a problem hiding this comment.
Revised. The helper module calls pytest.skip(allow_module_level=True) at import when flydsl or a GPU is missing, so this import can skip this file's tests as a side effect.
|
|
||
| CI collects only ``op_tests/test_*.py`` at depth 1 (see | ||
| ``.github/scripts/split_tests.sh``), so the in-package suite at | ||
| ``aiter/ops/flydsl/test_flydsl_linear_attention.py`` never runs automatically. |
There was a problem hiding this comment.
Should we still have the test under flydsl? And we could have the CI pull in the tests from there as likely intended. Anyway, this kind of commentary is not relevant to have in this test file.
| assert not torch.equal(kernel_pool[0], pool[0]) | ||
|
|
||
|
|
||
| def test_kda_tuned_rows_are_not_reachable_from_the_scalar_gate(): |
There was a problem hiding this comment.
Is this test relying on the CSV having a specific set of tuned rows? The test definitely should be independent of any CSV file and only test the dispatch/lookup logic. So remove this one and maybe replace with one where the tuning data is constructed explicitly in the test itself, and testing that the lookup picks the right one.
There was a problem hiding this comment.
Rewritten.
It now patches the parsed config map with rows built in the test and asserts only the lookup: two rows differing only in gate_mode each resolve to their own config, and with just a per-channel row present the scalar gate falls back.
| @@ -0,0 +1,121 @@ | |||
| # SPDX-License-Identifier: MIT | |||
There was a problem hiding this comment.
Why are we testing the reference? I'd just remove this file.
There was a problem hiding this comment.
I'd keep it. aiter/ops/torch_ref/kda.py is shipped code, not test scaffolding, and it has three consumers: the KDA kernel tests, the benchmark, and this file. It's the oracle those kernel tests judge against. if it drifts, they either fail and send you into the kernel, or agree with a wrong kernel and pass.
There was a problem hiding this comment.
I'd say that's the wrong place to put the torch_ref/kda.py then, it is not supposed to be "shipped code" in the sense that somebody would use it. The reference should be test-only oracle implementation that is simple enough to reason about without tests. If we want to have some tests for it, then the reference that the reference is judged against has to be something else, especially not the flydsl kernel, and also not something that just essentially reduces to torch.something() == torch.something()
There was a problem hiding this comment.
Agreed, and done in b4e6545.
aiter/ops/torch_ref/kda.py -> op_tests/kda_ref.py, so test-only is structural rather than a claim in a docstring, and op_tests/test_kda_torch_ref.py is gone.
The gate is the KDA form only now. The scalar softplus branch and the rank dispatch that chose between the two lost their last caller with that test, and the kernel's scalar path is already covered by the Triton reference in test_flydsl_linear_attention.py. What's left is a port of vLLM's naive_recurrent_kda plus a two-line gate, which is the "simple enough to reason about without tests" bar.
The benchmark under op_tests/op_benchmarks/flydsl/ imports it via a repo-root sys.path insert, since it is no longer reachable from an installed wheel.
| head_k_dim: int | ||
| head_v_dim: int | ||
| use_qk_l2norm: bool = True | ||
| # KDA pairs an f32 bias with a lower-precision query; None is pre-847 behaviour. |
There was a problem hiding this comment.
This is an existing file, but should the test file be moved under op_tests? Or does it make sense to have it here?
There was a problem hiding this comment.
Claude suggests to keep it where it is, for two reasons.
First, it doubles as a helper module. op_tests/test_flydsl_gdr_decode.py imports Args and check_gdr_decode from it, and only the in-package path works under both ways tests get run. CI executes files as python3 , which puts just op_tests/ on the path; pytest instead imports them as op_tests.* from the repo root. So after a move, neither from op_tests.test_… import … nor the bare from test_… import … would work in both modes.
Second, moving it would start running 22 tests that have never run in CI. If any of them is unhappy on another runner, this PR takes the blame.
There was a problem hiding this comment.
True, this has to be another PR that fixes the situation properly also for some existing flydsl tests.
| # Set only for a foreign launch stream, the one case needing reordering. | ||
| producer_stream = None | ||
| if stream is None: | ||
| stream = torch.cuda.current_stream(device) | ||
| else: | ||
| current_stream = torch.cuda.current_stream(device) | ||
| if stream != current_stream: | ||
| producer_stream = current_stream |
There was a problem hiding this comment.
This logic does not make sense to me. If the stream is given, or we use the current_stream, we just need to put all operations on that stream. There is no need to have a separate producer stream?
There was a problem hiding this comment.
Agreed, removed. The launch stream now simply defaults to the device's current one, and all the work runs on it.
| nullcontext() if producer_stream is None else torch.cuda.stream(stream) | ||
| ): | ||
| if producer_stream is not None: | ||
| stream.wait_stream(producer_stream) |
There was a problem hiding this comment.
why are we waiting for anything? we should just put everything on the user-given stream (which defaults to current stream of the device) and it will run them in the correct order.
There was a problem hiding this comment.
Dropped it. Also fixed the regression test.
…ctivations fp16 activations truncated the final state to fp16 before a bf16 store; the two types agreeing is what hid it. Activations are now restricted to fp16/bf16, so the out store's f16 fallback can no longer narrow a wider type.
…, not shape When heads equaled channels, `a.shape[-1] == len(A_log)` silently routed a per-channel gate through the scalar path. Pick the mode from `a`'s rank (3-D scalar vs 4-D per-channel) and validate `a`, `A_log`, and `dt_bias` shapes explicitly so mismatches raise instead of broadcasting.
samremes
left a comment
There was a problem hiding this comment.
LGTM, thanks. All the findings so far are addressed at 64f1e5f: the in-package test is gone, the KDA cases are in the canonical op_tests/test_flydsl_linear_attention.py against the fp32 reference, the tuning-table scope is documented, and the comments and description are cleaned up. python3 op_tests/test_flydsl_linear_attention.py and pytest both pass locally on MI355X, and CI passes it on MI300X and MI35X. The remaining red shard is a runner that lost its connection.
|
@waqahmed-amd-fi There is also a conflict in the tests now. |
@samremes Fixed now. |
Refresh the MI355X (gfx950, 256 CUs) decode tile selections for head_dim 1 and 256 in the FlyDSL linear attention kernel config table.
Refresh the MI300X (gfx942, 304 CUs) decode tile selections for head_dim 1, 4, and 256 in the FlyDSL linear attention kernel config table.
Keep both `flydsl_fp8_quant` and `flydsl_gdr_decode` in the FlyDSL export list. Co-authored-by: Cursor <[email protected]>
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
Summary
This PR extends the existing FlyDSL GDR decode kernel with a compile-time per-channel decay path for Kimi Delta Attention (KDA).
ais per-channel(B, Sq, H, K)instead of per-head(B, Sq, H).dt_biasis per-channel(H, K)instead of per-head(H), and may be f32 while activations stay bf16/fp16.g = g_min * sigmoid(exp(A_log) * (a + dt_bias))withg_min = -5.gate_modeis inferred froma.dim()("kda"if 4-D, else"gdr"), so existing callers keep the same signature.flydsl_gdr_decodeis exported fromaiter.ops.flydsl.Technical details
Kernel (
kernels/gdr_decode.py):gate_modeis a factory argument, so"gdr"and"kda"compile to separatelru_cachebinaries andPER_CHANNELfolds out underconst_expr. Only a non-gdrmode is suffixed onto the kernel name, so existing GDR symbols are unchanged. The scalar arm's one edit is thedt_biascopy atom, which is the same 16-bit copy wheneverdt_biascarries the activation dtype.Wrapper (
linear_attention_kernels.py): in KDA modeais(B, Sq, H_v, D_k)anddt_biasis(H_v, D_k), and both are checked against the shapes thatqueryandvalueimply. The kernel bakes in a few layout assumptions, so the wrapper now rejects the inputs that would break them:amust be dense alongD_k,outmust be contiguous, and an unshuffledstatemust have unit stride in K. A caller-suppliedstreammust be onquery's device, and the staging copies are enqueued on that same stream so they complete before the launch reads them. A negative slot index marks a CUDA-graph padding row: the kernel zeroes that row ofoutand leaves the state pool untouched.Tuning:
_KDA_DECODE_BY_PARTstores one(NUM_BLOCKS_PER_V_DIM, NUM_WARPS, WARP_THREADS_K)triple per batch size, measured at B ∈ {1, 4, 64, 256} for a single shape: 12 key and value heads, 128 wide, bf16 activations over an f32 state. Only those four batch sizes are tuned; every other batch size and shape uses_decode_tiling().NUM_BLOCKS_PER_V_DIMsplits the value dimension so that one decode launches more blocks, which is how a small batch fills the GPU, and the split that pays therefore depends on how many CUs the part has. An arch name does not pin that down — MI300X has 304 CUs and MI308X 80, or 64 on some parts, all gfx942 — so the table is keyed on(arch, CU count), and a part with no entry of its own uses_decode_tiling(), which reads the CU count at runtime.Tests and benchmark: the KDA cases live in
op_tests/test_flydsl_linear_attention.py, the canonical test for this op. Gate mode,dt_biasdtype and state dtype are sweep axes next to the existing ones, and every case is checked against the fp32 torch reference in that file. The same run then checks each tuned tiling of the current part, that staging copies run on a caller-supplied stream, and that the KDA table is keyed by gate and part.bench_gdr_decode_kda.pysweeps FlyDSL tilings, parity-checks each one against the same reference, ranks them by kernel time from the profiler, and prints a_KDA_DECODE_BY_PARTrow.Test plan
python3 op_tests/test_flydsl_linear_attention.py, the command CI runs: 384 sweep cases, the 4 tuned MI355X tilings and 3 contract checks pass on MI355X, alongside main's GDN packed decode/verify cases in the same filepytest op_tests/test_flydsl_linear_attention.py: 43 passed on MI355X: 22 GDR decode cases, 4 of them new in this PR, and main's 21 packed GDN casesrtol/atol1e-3, or 1e-2 for a bf16 state, which rounds on store; the benchmark's parity check uses an RMSE-ratio-or-absolute 1e-3 pairdt_bias, f32 and bf16 state, both gates, sequence lengths 1 and 2, batch 1, 2 and 128, GQA ratios 4 and 2, with and without in-kernel Q/K normalization_decode_tiling()dispatch as main, and the existing GQA cases still passTest result
Kernel time per call, read from the PyTorch profiler with L2 flushed before every call, so launch overhead is excluded; 5 trials on fresh inputs, mean ± std. Triton is vLLM's
fused_recurrent_kda_packed_decode_kernelon the same inputs, launched from a script outside this PR. "Untuned" is FlyDSL on the config_decode_tiling()picks, so it shows what the tuned row buys.MI355X, gfx950, 256 CUs:
do_benchtimes between events, and at B ≤ 4 that window also holds launch time the L2 flush does not cover, so neither these tables nor the tuner use it.MI300X, gfx942, 304 CUs:
PR Self-Review
Reviewed revision
6c0c2968c242844245b4d97a8bc75de0ba55be29Behavior and intent
flydsl_gdr_decodegains a per-channel decay gate for Kimi Delta Attention (KDA). Before this PR it had only the per-head GDR gate: one decay per head, fromaof shape(B, Sq, H)and adt_biasof shape(H)in the activation dtype. KDA needs one decay per key channel,g = g_min * sigmoid(exp(A_log) * (a + dt_bias)), fromaof shape(B, Sq, H, K)and adt_biasof shape(H, K)that may be f32. So KDA decode could not use this kernel; it ran on vLLM's Triton kernel, which is slower at every batch size in Test result. A 4-Daselects the new gate at compile time, so existing GDR callers keep the same signature and the same kernel. The wrapper also rejects layouts the kernel cannot read, runs its staging copies on the caller'sstream, and picks tuned KDA tilings by architecture and CU count.Validation and unverified scope
Run on MI355X (gfx950, 256 CUs) and MI300X (gfx942, 304 CUs), as listed under Test plan and Test result:
python3 op_tests/test_flydsl_linear_attention.py, the command CI runs: the 384 sweep cases, each part's 4 tuned KDA tilings and the 3 contract checks pass.pytest op_tests/test_flydsl_linear_attention.py: 43 passed on MI355X; 22 passed and 21 skipped on MI300X, where the packed GDN cases are gfx950-only.6c0c2968c2on MI355X (gfx950):op_tests/test_flydsl_linear_attention.pyran clean, and pytest passed 43 tests. This is the tested code at8fc2524666plus the 3-line rename ofGDR_GPU_ARCHto_gdr_gpu_arch()in the test file.Unverified:
6c0c2968c2._decode_tiling()config; the sweep checks some of them for correctness, but they are not tuned.python3run covers onlymain(): the sweep, the tuned tilings and the 3 contract checks. The other pytest items, including the newastride check, are not covered by CI; they passed under pytest above.PR-specific question
Run against
main's wrapper and kernel:dt_biasdtype differs from the activations, such as an f32dt_bias, tripsmain's assertion thatdt_biashas the activation dtype. The otherkdacases fail too, becausemainhas only the per-head softplus gate.test_flydsl_gdr_decode_kda_tiling_is_kda_onlyandtest_flydsl_gdr_decode_kda_tiling_needs_this_parts_rowfail becausemainhas no_KDA_DECODE_BY_PARTtable.test_flydsl_gdr_decode_rejects_noncontiguous_vector_dimension[4-a-kda]fails becausemainnever checksa's strides, so it does not raise the expectedValueError.test_flydsl_gdr_decode_stages_inputs_on_the_launch_streamtrips the same dtype assertion through its f32dt_bias. Past that,mainreshuffles the state on the current stream but launches onstream, so with the current stream busy the launch can read the state before the reshuffle runs.The
gdrcases withdt_biasin the activation dtype exercise behaviormainalready has; they guard the per-head path, whosedt_biasload this PR edits.No existing test covers the new behavior.
op_tests/test_flydsl_linear_attention.pyis the canonical test forflydsl_gdr_decodeand the only one that calls it; before this PR it built only per-head inputs withdt_biasin the activation dtype and never passed astream. The KDA decode tests underop_tests/triton_tests/gated_delta_net/cover the Triton kernels, not this one.Changed op tests
op_tests/test_flydsl_linear_attention.py: the canonical test for this op, extended in place rather than with a second suite. It adds gate mode,dt_biasdtype and state dtype as sweep axes, all checked against the file's fp32 reference, which now models the per-channel gate. It also runs each tuned KDA tiling of the current part and adds 4 pytest items: theastride check, staging copies on a caller's stream, and two checks that the KDA table applies only tokdaand only to its own(arch, CU count). No other test reaches the per-channel path, so none of it is redundant.op_tests/op_benchmarks/flydsl/bench_gdr_decode_kda.py: the tuner behind_KDA_DECODE_BY_PART. It sweeps tilings, parity-checks each one against the test file'sref_func, ranks them by profiler kernel time and prints a table row; CI does not run it. It is not redundant: the test file'smain()times only the tiling the wrapper picks, and the GDR benchmarks underop_tests/op_benchmarks/triton/time Triton kernels, so this script is the only way to add a row for a new part.