PyTorch / Meta · GPU kernel engineering · 2026-10-01
Original: Optimizing Jagged Flash Attention with TLX: The Road Toward SOTA FA4 on Blackwell · Implementation and supported configurations
Why read this report
The report addresses two problems together: using Blackwell efficiently and keeping the attention kernel practical to modify. Meta’s recommendation workloads contain user sequences of very different lengths and evolve through new windowing, precision, and sparsity choices. A fast kernel maintainable only by a few low-level specialists can slow the next modeling experiment.
TLX stands for Triton Low-level Extensions. The important change is explicit control over asynchronous movement, warp roles, shared memory, and tensor memory in Triton-style code. More control also means responsibility for scheduling and synchronization. It is not a compiler switch that automatically produces peak performance.
Follow how a measured bottleneck changes the schedule. Speedups demonstrate that this implementation works on its target shapes. The more transferable lesson is identifying where execution waits and choosing buffering and parallelism accordingly.
Why variable lengths change the problem
Padding an entire batch to its longest sequence spends computation on absent tokens. A jagged representation packs valid tokens and records sequence boundaries with offsets. This removes padding work but introduces uneven tile counts and costs.
Reading the diagram: the padded layout on the left contains unused gray regions; the right packs valid tokens and stores offsets. Removing padding does not itself balance GPU execution.
The main production case also uses broadcast-Q: one shared query sequence attends to different K/V sequences. During backward execution, contributions to the shared query gradient must be accumulated across the batch. Forward tile scheduling and backward dQ accumulation therefore have different bottlenecks and need different treatment.
Architecture: overlap movement, computation, and stores
Reading the diagram: follow dependencies between specialized execution roles. Loads, matrix multiplication, softmax, and stores overlap, while buffers and synchronization determine when data may be read or reused.
The implementation assigns separate warps to loading data, issuing tensor-core matrix operations, softmax and correction, and storing results. Backward execution also has a dedicated dQ-reduction role. Explicit producer–consumer synchronization transfers ownership of buffers; multiple K/V buffers let loads run ahead.
The objective is not simply to create more roles. It is to reduce waiting on the critical compute path. Serialized loading and computation approximately add their durations; a stable pipeline can hide part of one behind the other. Extra buffering consumes on-chip capacity, while premature buffer reuse can break correctness. Performance, resources, and synchronization must therefore be analyzed together.
Why both static and dynamic balancing help
Reading the diagram: contiguous placement can concentrate heavy tiles on a few SMs. The zigzag assignment mixes larger and smaller tasks, reducing early idleness and long tails.
In forward execution, a tile’s cost varies with its K/V sequence length. The authors sort work and distribute it in alternating directions across SMs. Backward tiles have more uniform costs but different counts per sequence, so precomputing valid tiles and assigning them round-robin is more appropriate.
Blackwell’s Cluster Launch Control adds dynamic work assignment: an SM that finishes can obtain further work. The official TLX CLC article explains the mechanism. Static and dynamic approaches are complementary. Precomputation removes empty tiles and improves initial distribution; dynamic scheduling handles variation visible only during execution.
The engineering lesson is to identify whether imbalance comes from task cost or task count before choosing a scheduler. Mean sequence length alone can hide a tail that delays the entire batch.
How small changes affect the whole pipeline
The report’s dQ contention, TMEM-release timing, and loop-tail optimizations show that the bottleneck is not necessarily the largest matrix multiplication. Shared-query gradient accumulation can contend, and a store stage holding a buffer can prevent the next compute stage from starting.
The authors use staged stores and earlier buffer release to reduce such waits. They also separate last-tile masking from the bulk loop. A rarely executed branch can still affect static register allocation and cause spills on the hot path. Profiling, compiler output, and controlled before/after measurements matter more than intuitive judgments about short code.
Our engineering interpretation is to evaluate optimizations along the dependency chain. A faster stage matters when it removes a critical wait. Conversely, an apparently minor release point can affect every subsequent computation.
Interpreting performance and feature scope
The authors compare B200 BF16 execution against the May 2026 FA4 version. Reported average throughput improvements on jagged workloads are approximately 13% forward and 50% backward. On dense shapes, forward reaches about 87% of FA4 throughput while backward is approximately 17% higher. These are kernel results for specific shapes and implementations, not universal Blackwell attention wins or end-to-end training speedups.
The current official README adds concrete constraints: SM100+ hardware, head dimension at most 128, GQA in forward, and a single query group in backward. The collaborative two-CTA backward path is limited to broadcast-Q, head_dim=128, one query group, no sliding window, and enabled load balancing. Other supported cases use the one-CTA path. These are the README conditions checked for this note; pin a commit when reproducing them.
The article explores low-precision and block-sparse variants, but mentioning a variant does not establish complete support in the public package. A smaller line count is likewise not an independent measurement of maintenance cost.
Reading and adoption priorities
For recommendation or jagged-attention workloads, first check length distributions, broadcast-Q semantics, forward/backward requirements, and precision against the implementation and tests. General LLM-serving readers can learn the scheduling and pipeline-analysis approach without transferring the reported speedups.
A meaningful evaluation would hold inputs, precision, and versions fixed, check correctness, and separate forward, backward, and end-to-end timing, including tail shapes. This is a technical reading note. No B200 performance reproduction was run, and no kernel was installed or executed on the website server.


