Skip to content

[examples] Add FlashKDA as a second baseline for kda_varlen - #3291

Draft
tarinduj wants to merge 1 commit into
tarinduj/stack/4from
tarinduj/stack/5
Draft

[examples] Add FlashKDA as a second baseline for kda_varlen#3291
tarinduj wants to merge 1 commit into
tarinduj/stack/4from
tarinduj/stack/5

Conversation

@tarinduj

@tarinduj tarinduj commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Stacked PRs:


[examples] Add FlashKDA as a second baseline for kda_varlen

FlashKDA implements the same KDA forward as kda_varlen. Benchmarking it on the same shapes gives the dashboard a flashkda_speedup column next to helion_speedup, both measured against FLA.

What's here

  • examples/linear/linear_attention_flashkda.py and harness.flashkda_fwd, wiring FlashKDA in as a second baseline for kda_varlen.
  • flashkda_latency_ms and flashkda_speedup in benchmarks/run_linattn.py.
  • The install in benchmark.yml, beside FLA's.

It is forward-only, takes its inputs token-major and pre-activation, and is compiled for D == DV == 128.

Benchmarks

%FLA = 100 * fla_ms / row_ms on H100, autotuned with HELION_AUTOTUNE_EFFORT=full. Higher is faster than FLA.

variant fixed_T8192_H96_D128 fixed_T8192_H64_D128 ragged_T8192_H96_D128 ragged_T8192_H64_D128 uniform_T8192_H96_D128 uniform_T8192_H64_D128
kda_varlen 100% 91% 95% 90% 99% 91%
flash_kda 232% 183% 229% 217% 257% 259%

So FlashKDA is about 2.2x ahead of us. It is written in CuTe, and these numbers are
Helion on the Triton backend, so the next thing to try is HELION_BACKEND=cute.

tarinduj added a commit that referenced this pull request Aug 5, 2026
[FlashKDA](https://github.com/MoonshotAI/FlashKDA) implements the same KDA forward as `kda_varlen`. Benchmarking it on the same shapes gives the dashboard a `flashkda_speedup` column next to `helion_speedup`, both measured against FLA.

## What's here
- **`examples/linear/linear_attention_flashkda.py`** and `harness.flashkda_fwd`, wiring FlashKDA in as a second baseline for `kda_varlen`.
- **`flashkda_latency_ms` and `flashkda_speedup`** in `benchmarks/run_linattn.py`.
- **The install in `benchmark.yml`**, beside FLA's.

It is forward-only, takes its inputs token-major and pre-activation, and is compiled for `D == DV == 128`.

## Benchmarks
`%FLA = 100 * fla_ms / row_ms` on H100, autotuned with `HELION_AUTOTUNE_EFFORT=full`. **Higher is faster than FLA.**

| variant | fixed_T8192_H96_D128 | fixed_T8192_H64_D128 | ragged_T8192_H96_D128 | ragged_T8192_H64_D128 | uniform_T8192_H96_D128 | uniform_T8192_H64_D128 |
|---|---|---|---|---|---|---|
| kda_varlen | 100% | 91% | 95% | 90% | 99% | 91% |
| flash_kda | 232% | 183% | 229% | 217% | 257% | 259% |

So FlashKDA is about 2.2x ahead of us. It is written in CuTe, and these numbers are
Helion on the Triton backend, so the next thing to try is `HELION_BACKEND=cute`.

stack-info: PR: #3291, branch: tarinduj/stack/5
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 5, 2026
[FlashKDA](https://github.com/MoonshotAI/FlashKDA) implements the same KDA forward as `kda_varlen`. Benchmarking it on the same shapes gives the dashboard a `flashkda_speedup` column next to `helion_speedup`, both measured against FLA.

## What's here
- **`examples/linear/linear_attention_flashkda.py`** and `harness.flashkda_fwd`, wiring FlashKDA in as a second baseline for `kda_varlen`.
- **`flashkda_latency_ms` and `flashkda_speedup`** in `benchmarks/run_linattn.py`.
- **The install in `benchmark.yml`**, beside FLA's.

It is forward-only, takes its inputs token-major and pre-activation, and is compiled for `D == DV == 128`.

## Benchmarks
`%FLA = 100 * fla_ms / row_ms` on H100, autotuned with `HELION_AUTOTUNE_EFFORT=full`. **Higher is faster than FLA.**

| variant | fixed_T8192_H96_D128 | fixed_T8192_H64_D128 | ragged_T8192_H96_D128 | ragged_T8192_H64_D128 | uniform_T8192_H96_D128 | uniform_T8192_H64_D128 |
|---|---|---|---|---|---|---|
| kda_varlen | 100% | 91% | 95% | 90% | 99% | 91% |
| flash_kda | 232% | 183% | 229% | 217% | 257% | 259% |

So FlashKDA is about 2.2x ahead of us. It is written in CuTe, and these numbers are
Helion on the Triton backend, so the next thing to try is `HELION_BACKEND=cute`.

stack-info: PR: #3291, branch: tarinduj/stack/5
@tarinduj
tarinduj changed the base branch from tarinduj/stack/4 to main August 5, 2026 22:37
@tarinduj
tarinduj changed the base branch from main to tarinduj/stack/4 August 5, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant