Repository navigation
[RFC] Roadmap: NPU support for flash-linear-attention #942
Description
Thanks to the flash-linear-attention community for merging our native NPU support PR.
This roadmap outlines upcoming plans for native NPU support. Feedback and discussion are welcome.
Native NPU Support in flash-linear-attention
Native support is built on top of flash-linear-attention's dispatch system:
We have validated this approach for NPU adaptation work:
The following diagram illustrates the flow for adapting kernels under fla/modules/:
User / model code (unchanged)
│
▼
fla/modules/<module>.py # Public API + @dispatch('modules') hooks only
│
▼
fla/ops/backends # Runtime backend selection (BackendRegistry)
│
▼
fla/modules/backends/triton_ascend/ # NPU Triton kernels + launchers
├── __init__.py # TritonAscendBackend registration
├── rotary.py
├── fused_cross_entropy.py
├── fused_linear_cross_entropy.py
├── activations.py
├── fused_kl_div.py
├── layernorm.py
├── grpo.py
└── causal_conv1d.py
Dependency Installation
Note that flash-linear-attention already supports other devices such as XPU and AMD:
- [Docs] Add Ascend NPU installation section to README #938
- [Refactor] Decouple torch/triton backend from base deps #937
NPU CI Setup
Future native adaptations will introduce a substantial amount of triton-ascend code, making NPU CI especially important. We plan to use the CI tooling provided by ascend-gha-runners:
- [CI] Add ascend-a2-ci workflow for Atlas A2 NPU module tests #944
- [Ops] Expand triton-ascend backends(fla/modules, fla/ops/utils) and upgrade CANN to 9.0.0 #973
- [CI] Parallelize Ascend A2 CI tests with pytest-xdist across 8 NPUs #987
Reference:
- https://github.com/ascend-gha-runners/docs/blob/main/docs/user-manual-gha-en.md
- https://github.com/ascend-gha-runners/docs/blob/main/docs/user-manual-gha-zh.md
This is our top priority at the current stage, and work is still in progress.
Adaptation Order
At a high level, adaptation work is organized as follows:
-
fla/modules/- [Ops] Feat: Add triton-ascend backend support for FLA module kernels #927
- [Conv] Chunk Ascend causal_conv1d launches for 65535 grid limit #992
- [Conv] Harden triton-ascend causal_conv1d silu/add against Ascend launch limits #997
- [Perf] Optimize Ascend NPU activation kernels #995
- [Fix] remove redundant decorators, add PowGlu kernel and pin the version of torch_npu to 2.7.1.post4 for npu. #982
- [Fix] fix benchamrk issues and add ub management for npu #1001
- [Ops] Add triton-ascend backend for l2norm and fused_norm_gate kernels #1002
- [Fix] [Test] Remove unused GeLU/SquaredReLU NPU kernels and add Ascend UB Manager tests #1006
-
fla/ops/ -
fla/layers/ -
fla/models/
For the remaining work, we propose the following order within fla/ops/:
-
fla/ops/based/native.py,tests/ops/test_based.py -
fla/ops/based/parallel.py,tests/ops/test_based.py -
fla/ops/based/fused_chunk,tests/ops/test_based.py -
fla/ops/utils/cumsum.py,tests/ops/utils/test_cumsum.py -
fla/ops/utils/index.py,tests/ops/utils/test_index.py -
fla/ops/utils/cache.py,tests/ops/test_cache.py -
fla/ops/common/* -
fla/ops/gated_delta_rule/* -
fla/ops/gated_delta_product/* -
fla/ops/gdn2/* -
fla/ops/kda/* -
Other kernels
Skills
Because triton-ascend differs from upstream triton in programming model and performance characteristics, migrating kernels to NPU requires additional tuning time. We plan to capture reusable migration skills to improve efficiency over time.
Hardware Coverage
For current migration work, we recommend validating on the following hardware:
- Atlas 800T A2 (32G, x86)
- Atlas 800T A3 (64G, x86)
We expect to publish validation results on additional hardware platforms in future updates.
Integration with Training Frameworks
Once native NPU adaptation of flash-linear-attention reaches a sufficient level of maturity, we need to demonstrate real-world usability by running end-to-end SFT or RL workflows in production training frameworks. We plan to validate integration through the following projects:
tilelang-ascend Support
flash-linear-attention also provides a tilelang DSL backend. Ascend offers tilelang-ascend, and native support may be feasible in the future. Whether we start this effort will depend on community feedback. For now, the primary focus remains on triton-ascend.
Activity
sunyi0505 commentedon Jul 15, 2026
FLA Module Benchmark — NVIDIA H100
Benchmark results for Flash Linear Attention (FLA) fused operators on NVIDIA H100.
Activation Function
Details
Causal Conv1D
Details
Cross Entropy
Details
L2 Norm
Details
LayerNorm / GroupNorm
Details
Token Shift
Details
GDN
Details
KDA
Details
Fused_attnres
Details
sunyi0505 commentedon Jul 15, 2026
FLA Module Benchmark — Atlas 800T A3(X86)
Benchmark results for Flash Linear Attention (FLA) fused operators on Atlas 800T A3(X86).
Activation Functions
Details
Causal Conv1D
Details
Cross Entropy
Details
L2 Norm
Details
LayerNorm / GroupNorm
Details
Token Shift
Details
GDN
Details
KDA
Details
Fused_attnres
Details
zheliuyu commentedon Jul 18, 2026
News
[2026.07.18] Since
flash-linear-attentionnatively providestriton-ascendbackend support for theconv1dandgated_delta_rulekernels,ms-swifthas officially started usingflash-linear-attentionon NPUs, maintaining the same user experience as on cuda: modelscope/ms-swift#9746At the same time, this also marks that the work related to
flash-linear-attention+triton-ascendhas officially entered the high-performance optimization phase. We'll share more news soon — stay with us.sunyi0505 commentedon Jul 20, 2026
ascend-npu-profiling skills
https://github.com/sunyi0505/flash-linear-attention/tree/sync/ascend-npu-profiling-skills/.agents/skills/ascend-npu-profiling
zhiyuan1i commentedon Jul 25, 2026
@sunyi0505 Thanks for sharing the ascend-npu-profiling skill — this looks really useful. Would you be interested in contributing it to the repo's
.agents/skills/directory (alongside fla-kda, fla-dispatch-backends, etc.) so more people (and agents) can pick it up? Happy to help turn it into a PR if you'd like.sunyi0505 commentedon Jul 26, 2026
Thank you for acknowledging the practical value of this skill component. As this component is still in the iterative development phase, multiple granular details remain to be optimized and supplemented. I am prepared to submit it for repository merge work immediately after all relevant refinements are fully accomplished.
zheliuyu commentedon Aug 25, 2026
2026.09-2026.12 Roadmap
This block is the September–December 2026 plan: close the remaining production gaps on the kernels training and serving already call, keep the companion stack (CANN / torch_npu / triton-ascend) from breaking us, make short-sequence training and prefill graph-capturable, make Transformers actually bind native FLA on NPU (Qwen3.5 / Next / Olmo Hybrid), deepen ms-swift so real packing / SFT / RL stays on that path, show end-to-end evidence in other trainers, and land a native
tilelang-ascendbackend. It is not a second pass over every unported research kernel.Feedback and discussion are welcome.
Remaining Adaptation
Priority is production demand.
fla/layers/andfla/models/stay backend-agnostic — September–December “layers / models” work is e2e tests, cache / generation, and training-framework integration, not new NPU files.Paths that training and decode already call
fused_recurrentGDN (decode / short prefill)fla/ops/common/fused_recurrent.pyis still a CUDA-style kernel with NPU compile pins on backward.fused_recurrentKDA backward (fwd only today)fla/ops/gated_delta_product/dedicatedchunk_deltaproduct_h/chunk_deltaproduct_ochunk_delta_h.chunk_gated_delta_rule_bwdwhere GDP already doesfla/ops/gdn2/(chunk_delta_h)fla/ops/delta_rule/(chunk_delta_h+chunk_o+kkt)fla/modules/token_shift.pyNPU backend (RWKV / token-mix layers; still generic Triton, already comments on the 65535 grid cap)Demand-gated (not the default September–December queue)
fla/ops/based/(native/parallel/fused_chunk) — port if a training stack asksfla/ops/rwkv6/,fla/ops/rwkv7/native backends —token_shift+fused_recurrentcover a large part of the gap firstprecond_gated_delta_rule/precond_kdaretention,gsa,nsa,path_attn,mesa_net, …) — community request onlyHigh-performance Optimization
June–August already entered this phase. Frozen pytest (fwd and bwd, under NaN poisoning) stays the gate; do not loosen tolerances.
extract_slice; hostReduceSumof per-chunkdw/dbchunk_delta_hbwddhuis still AIC-scalar dominated after tiling worknum_warps/num_stagesfrom any shared kernel that NPU still launches (commonfused_recurrent, GDP, leftover utils)Compiler and Companion-stack Compatibility
triton-ascend 3.2.2 changes defaults under us (AutoBlockify on, auto-multi-buffer /
num_stages=2,extra.cannvsextra.ascend). This is a standing September–December track, not a one-off hotfix.Supported stack at the start of September–December: CANN 9.1.0,
torch==2.9.0,torch_npu==2.9.0.post6,triton-ascend==3.2.2. Plaintorch_npu==2.9.0(no.post) is not sufficient. SeeINSTALL.md.gelu/sqrelu, GRPOold_logps) stay “compat shims + skip compile”, not FLA math rewrites. New inductor numeric bugs go back totorch_npuGraph Capture (Prefill and Training)
Backend-neutral RFC. CUDA Graphs and Ascend ACL Graph /
torch.npu.NPUGraphshare the same contract:Today’s varlen GDN/KDA + conv path is capture-illegal on NPU for the same reasons as CUDA: host
prepare_chunk_indices, data-dependent grids,.item()/ D2H, host launch chunking overNT.prepare_chunk_indices/ offsets) underNPUGraph— static[NT_max, 2]+ sentinel, device-sidesearchsorted, paddedcu_seqlenstask_num/num_core) instead of host-splitting overNT(a Python loop is frozen at capture time)(T_max, N_max)graph_task_updatefused_recurrent, conv update-with-cache) stays out of scope for this RFC — serving stacks already own that pathfla/ops/cp/) is a later wave; [RFC] Graph capture support for prefill and training: GDN/KDA chunk and convolution paths #1155 already records what CP needs so the single-rank contract does not block it. HCCL warmup is the NPU analogue of the NCCL side-stream warmupDecode and Inference
Chunk kernels cover training. Serving and short-prefill need the recurrent / cache path to be first-class on NPU.
fused_recurrentfwd ([GDN] feat(triton_ascend): add fused_recurrent GDN fwd kernel and dispatch #1078) + bwd if training-from-recurrent is requiredfused_recurrentbwdcompute_dh0— already have NPU kernels; keep them correct on short chunks (see [Fix] Correct Ascend causal_conv1d short-chunk cache backward #1146, [Fix] Correct the final-state gradient for chunks shorter thanW - 1#1141, [Fix] Honor the real layouts ofyanddyincompute_dh0_kernel#1139)FLACachee2e on NPU for GatedDeltaNet, KDA, GLAgenerate) so we do not grow a second decode stackNPU CI
A2 correctness and benchmark workflows already exist. September–December extends coverage, still using
ascend-gha-runners.tests/ops/test_simple_gla.py,tests/ops/test_delta.py/test_delta_rule,tests/ops/test_gdn2.py(names as in-tree)Skills
.agents/skills/fla-ascend-performance/(cases.md,TRAPS.md) current when a generalizable trap is found (compile-flag pins, lhs clobber, constexpr DMA split, int64 pointer math). Do not bundle doc dumps into perf PRsHardware Coverage
compile_on_910_95/ 950 SIMT — not A2 with a different core count). Need at least a manual validation pass, then an A5 CI job if a runner is allocatedmake_block_ptrassumptions; if compile or numerics fail, A/Bcompile_mode="simd"first_UB_BYTES = 196608). Size tiles fromget_soc_spec("UB_SIZE"); do not copy the A2 constantmultibuffer/ AutoBlockify pins per launch on A5; do not reuse the A2 table as-isnum_aicore/num_vectorcoreon A3 / A5We expect to publish validation results on additional hardware platforms in future updates.
FLA and Transformers
is_flash_linear_attention_available()also acceptsis_torch_npu_available()causal_conv1d/causal_conv1d_updatewhen Dao-AILabcausal_conv1dis absentrecurrent_gated_delta_ruleas an alias offused_recurrent_gated_delta_ruleso Transformers’ decode resolve succeeds (pairs with [GDN] feat(triton_ascend): add fused_recurrent GDN fwd kernel and dispatch #1078)chunk_gated_delta_rule+ packingcu_seqlens,causal_conv1d/causal_conv1d_updateIntegration with Training Frameworks
max_length/ packing, with a public reciperepatch(): no stalemcore-bridgecache. The CUDA-only Transformers availability check is owned by the section above; do not re-patch it only inside ms-swift long-termFusedRMSNormGatedon the NPU packing path now thattorch.cuda.current_device()is gone; if anything else still blocks it, fix it in FLA#9746did not validate (TP / CP > 1)old_logpscompile is safe (already skipped inTritonAscendBackend)tilelang-ascend Support
September–December will land native
tilelang-ascendsupport.triton-ascendstays the default production path; tilelang is a second backend on the same@dispatch/BaseBackendregistry already used by the in-tree NVIDIAtilelangbackends (common, KDA, DPLR, RWKV6).tilelang_ascendbackend (IS_NPU+tilelang-ascend, lazy import). Do not reuse the NVIDIAtilelangbackend’shas_usable_nvcc()gatetriton_ascendpath, so the two NPU DSLs can be A/B’dfla/ops/common/tilelang chunk / parallel-attnfla/ops/kda/triton_ascendGDN surface)triton-ascend(fwd and bwd, NaN poisoning). No Torch fallback on a claimed pathtilelang-ascendversion inINSTALL.md/ extras once the first wave passes A2tilelang-ascendvstriton-ascend(perf, compile time, coverage). September–December does not switch the default away fromtriton-ascendzhudada0120 commentedon Sep 21, 2026
Ascend Adaptation Plan for fla/ops Operators
The goal is to adapt fla operators to multiple triton-ascend versions. The work will proceed layer by layer: ops first, then layers, then models. This plan is the first step. It covers the fla/ops operators (the kernel level); fla/layers and fla/models will be covered in follow-up plans.
Work within the ops layer is split into two phases. Phase 1 completes the adaptation under triton-ascend 3.2.2 and is this list. Phase 2 performs full-version testing on top of Phase 1 and will be detailed after Phase 1 completes.
This list contains 23 items. They come from a batch run of all tests under tests/ops with triton-ascend 3.2.2: the 23 test files that had failing cases (snapshot from 2026-09-18).
Acceptance Criteria
With the version stack above, run
pytest tests/ops/test_<op>.pyon each of the A2/A3/A5 hardware platforms. All test cases must pass (0 failed, 0 error). Do not modify any assertion or tolerance in the test cases.TODO
tests/ops/test_attn_sink.py)tests/ops/test_attnres.py)tests/ops/test_delta.py) - @TecJesh [Fix] Avoid unit-scale constexpr folding in Ascend chunk kernels #1298tests/ops/test_precond_kda.py) - @zhudada0120 [Ops] Add triton-ascend backends for ATK and Precond KDA kernels #1278tests/ops/test_gdp.py)tests/ops/test_momentum_delta.py) - @TecJesh [Ops] Add Triton-Ascend support for momentum delta rule #1343tests/ops/test_oja.py) - @zhudada0120 [Ops] Add Triton-Ascend backend for gated Oja rule fused recurrent #1372tests/ops/test_parallax.py) - @zhudada0120 [Ops] Add Triton-Ascend backend for Parallax single-token decode #1377tests/ops/test_path_attn.py)tests/ops/test_precond_gated_delta.py)tests/ops/test_rwkv6.py)tests/ops/test_simple_gla.py)tests/ops/test_ttt.py)----- List of Pending Community Tasks -----
tests/ops/test_based.py)tests/ops/test_comba.py)tests/ops/test_delta_product.py)tests/ops/test_deltaformer.py)tests/ops/test_dplr_delta.py)tests/ops/test_hgrn.py)tests/ops/test_iplr_delta.py)tests/ops/test_log_linear_attn.py)tests/ops/test_mesa.py)tests/ops/test_nsa.py)Notes
During adaptation, reusable lessons that can help other operators will be recorded in
.agents/skills/fla-ascend-performance/(cases.md, TRAPS.md).zhudada0120 commentedon Sep 21, 2026
cc @zheliuyu @TecJesh
zheliuyu commentedon Sep 21, 2026
@zhudada0120 Welcome your team’s contribution. I remember you were involved in building
triton-ascenditself, and looking forward to more performance optimizations from you.Two quick notes:
AttnRes,Precond Gated Delta Rule, andSimple GLAkernels have already been migrated or are about to have PRs opened. The remaining kernels are still pending migration and are available to pick up anytime.Delta RuleandPrecond KDAfirst, then moving on to the rest.zhudada0120 commentedon Sep 21, 2026
Hi @zheliuyu, thanks for the suggestion. We will prioritize Delta Rule and Precond KDA kernels and will not duplicate claims for AttnRes, Precond Gated Delta Rule, and Simple GLA kernels. Feel free to share any further suggestions anytime.
zheliuyu commentedon Oct 10, 2026
Just a reminder:
cc @qianjinqiu @Ginray @hazelduan @FightingZhen @OsirisDuan @sunyi0505 @zhudada0120 @TecJesh
zheliuyu commentedon Oct 26, 2026
Notes, 2026.10.26:
FLA has been upgraded to triton-ascend v3.6.0. Some kernels show performance regressions, and we're actively working on them.
Some good news: triton-ascend is considering adding FLA to their daily ci pipeline. That would mean we no longer have to manually upgrade FLA after each triton-ascend release, which should also be an effective boost to the software health of FLA's NPU side. This also explains why there have been many new triton-ascend kernel PRs recently.
Validation for 950 has started. However, we haven't found any usable 950 CI resources yet. The kernel code hasn't been open-sourced yet either — I'll keep you posted as soon as there's progress. Stay tuned.