Skip to content

feat(flydsl): Add HSTU Forward kernel - #4354

Closed
damien-lejeune wants to merge 18 commits into
mainfrom
users/relbers/hstu_attention_fwd
Closed

damien-lejeune wants to merge 18 commits into
mainfrom
users/relbers/hstu_attention_fwd

Conversation

@damien-lejeune

@damien-lejeune damien-lejeune commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The purpose of this work is to implement a FlyDSL HSTU forward kernel.

Jira ID : SILOTIGER-617

Technical Details

The HSTU block is defined here: https://arxiv.org/pdf/2402.17152v2
The full HSTU layer, implemented here (paper Eq. 1–3) is:

$$U, V, Q, K = \text{Split}\big(\phi_1(f_1(X))\big)$$

$$A(X),V(X) = \phi_2!\big(Q K^\top + \text{rab}^{p,t}\big),V$$

$$Y(X) = f_2\big(\text{Norm}(A(X)V(X)) \odot U(X)\big)$$

where $f_1, f_2$ are linear layers, $\phi_1,\phi_2$ are SiLU, $\odot$ is elementwise product, and $\text{rab}^{p,t}$ is a relative attention bias (positional + temporal).

Test Plan

  • Unit tests were written validating correctness on the input shapes of interest. The tests check the FlyDSL kernel against a PyTorch oracle across a handful of shapes and each feature (causal, targets, sliding window, contextual prefix, and various head/hidden dims). They also cover input validation (rejecting bad device/shape/rank/dtype/target-length) and tuned-CSV config loading.
  • Tested support and performance on gfx942. Performance was externally validated to match requirements.
  • Tested correctness on gfx950

Test Result

  • All unit tests are (and should be) passing

Submission Checklist

@github-actions

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:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4354 --add-label <label>

@damien-lejeune damien-lejeune changed the title Users/relbers/hstu attention fwd feat(flydsl): Add HSTU Forward kernel Jul 23, 2026
@damien-lejeune
damien-lejeune marked this pull request as ready for review July 23, 2026 13:06
@damien-lejeune
damien-lejeune requested a review from a team July 23, 2026 13:06
@zufayu
zufayu requested a review from coderfeli July 24, 2026 01:32

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <B008> reported by reviewdog 🐶
Do not perform function call torch.device in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

device: torch.device = torch.device("cuda"),


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found <<


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found <<


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found <


⚠️ [ruff] reported by reviewdog 🐶
Expected an expression


⚠️ [ruff] reported by reviewdog 🐶
Expected an expression


⚠️ [ruff] reported by reviewdog 🐶
Expected an expression


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found >>


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found >>


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found >>


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found >


⚠️ [ruff] reported by reviewdog 🐶
Expected ,, found string

"flydsl_preshuffle_gemm_a8",

@damien-lejeune

Copy link
Copy Markdown
Contributor Author

Unfortunately, I have to close this PR, due to performance regression introduced by failing to take into account a force push change on the original branch.

@zufayu
zufayu deleted the users/relbers/hstu_attention_fwd branch August 11, 2026 06:44
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