Skip to content

[trainer throughput] Compile FLA linear-attention kernels once on Miles LoRA trainers - #373

Open
Micah Yong (micahtyong) wants to merge 1 commit into
mainfrom
micah/miles-fla-pin
Open

Micah Yong (micahtyong) wants to merge 1 commit into
mainfrom
micah/miles-fla-pin

Conversation

@micahtyong

@micahtyong Micah Yong (micahtyong) commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On the Miles LoRA trainers, FLA's Triton kernels for the short convolution, gated RMS norm and (on miles-v0.1.x) l2norm take an NB argument derived from the token count. The kernels never read it, but Triton compiles and FLA autotunes per value, so a step with new packed lengths paused 2.6–10 s per kernel. This pins NB to 1 on both Miles actors once the model is built, as #333 did for the Megatron backend. The helper moves to backends/fla_kernels.py so both backends share it, and now also covers the gated-norm kernels. Trainers that don't load FLA skip it. Losses are bit-identical.

Testing

Fresh qwen35-4b-lora-32k trainer on 4×B200 with a cold Triton cache, stock Tinker SDK, 20 steps of 8 rows with lengths from 1K–30K tokens. Times are trainer forward_backward per step, on main 730c853 plus this PR. The v0.1.1 columns run the same recipe on miles-v0.1.1-52a7a99, the actor qwen36-35b-a3b-lora-32k uses.

v0.2.0 before v0.2.0 after v0.1.1 before v0.1.1 after
Steps 1–19, median 2.5 s 2.4 s 2.0 s 1.8 s
Steps 1–19, max 26.1 s 2.7 s 68.5 s 2.2 s
Steps over 5 s 8 0 8 0
First 20 steps, total 206 s 106 s 446 s 140 s

v0.2.0 before · after · v0.1.1 before · after

Every loss matched the unpatched run on all 40 steps on both images. With a warm kernel cache, main still had 7 steps over 5 s and this PR had none. First-step time ranges 46–196 s on both sides depending on compile caches. Not run: qwen36-35b-a3b at its 8-GPU layout, multi-node, contexts above 32K.

Qwen3.5 and Qwen3.6 LoRA trainers on Miles run FLA's Triton short-conv
and gated-norm kernels. These take an NB argument derived from the
token count, which the kernels never read but Triton compiles and FLA
autotunes on. Every new packed micro-batch length compiled and retuned
them, at 2.7-6 s per kernel.

Both Miles actors now pin NB to 1 once the model is built, with the
helper the Megatron backend already uses (#333). The helper moves to
spindle.backends.fla_kernels and also covers the gated-norm kernels.
Models that don't load fla skip the pin and its import cost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant