Repository navigation
[Triton/Gluon] [FlyDSL] feat(flydsl): Add HSTU Backward kernel - #4885
Merged
Merged
Conversation
…tead of two (for dV/DK and dQ), bringing minor performance gain
added 5 commits
September 8, 2026 14:06
damien-lejeune
marked this pull request as ready for review
September 11, 2026 12:16
coderfeli
reviewed
Sep 15, 2026
coderfeli
reviewed
Sep 15, 2026
coderfeli
reviewed
Sep 15, 2026
Collaborator
|
move the hstu related files in kernels/ into a sub folder and hstu_attention_kernels.py ->hstu_attention.py? |
Contributor
Good suggestion. Fixed in a598aac |
Collaborator
|
need rebase @damien-lejeune |
coderfeli
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The purpose of this work is to implement the backward counterpart to the FlyDSL HSTU forward kernel.
Jira ID : SILOTIGER-616
Technical Details
Depends on the FlyDSL HSTU forward kernel in #4441. This PR adds the backward pass for the same attention block defined in HSTU (arxiv 2402.17152v2).
The backward does not stash activations from the forward — it recomputes
S = alpha * Q K^Tand the SiLU derivative from(Q, K), then produces(dQ, dK, dV)via two lock-free FlyDSL kernels:hstu_attention_bwd.py) — owns a KV tile, streams query tiles, and computes dV and dK from a singleSrecompute.hstu_attention_bwd_dq.py) — mirrors the forward layout; each program owns a query tile and streams KV tiles to compute dQ.Shared indexing/layout helpers live in
hstu_attention_common.py. The public API isflydsl_hstu_attention_bwdinhstu_attention_kernels.py, wired intoFlydslHstuAttentionfor end-to-end autograd.Feature parity with the forward kernel:
seq_offsetsnum_targets, sliding window (max_attn_len), and contextual prefix (contextual_seq_len)attn_dim != hidden_dim(asymmetric head dims){f16, bf16}inputs, fp32 accumulation, fast-math SiLU (same conventions as forward:alpha-in-score,1/NondS)Tuning & dispatch:
hstu_attention_bwd_tuned.csvTest Plan
Correctness (pytest) —
op_tests/flydsl_tests/test_flydsl_hstu_attention_bwd.pyPerf / op-test gate —
op_tests/test_flydsl_hstu_attention_bwd.pyBenchmark harness — extended
op_tests/op_benchmarks/triton/bench_hstu_attn.pywith--provider flydsl --mode bwd(and optional--sort_by_length).Test Result
op_tests/flydsl_tests/test_flydsl_hstu_attention_bwd.pypass on gfx942 and gfx950.Submission Checklist