FBTriton: How Meta Rewrote Table-Batched Embedding Kernels in Triton and Beat Legacy CUDA

Meta's Triton rewrite of TorchRec's Table-Batched Embedding kernels runs a median 1.28x faster than the CUDA version across 307 GB200 shard configurations, in less code, with Blackwell features added as flags.

FBTriton: How Meta Rewrote Table-Batched Embedding Kernels in Triton and Beat Legacy CUDA

Table-Batched Embedding (TBE) kernels sit at the heart of large recommendation systems. They retrieve rows from multiple embedding tables, combine the retrieved vectors into pooled representations, and do so within a single GPU launch. In production recommendation and ranking workloads, this operation is repeated across large collections of tables and distributed GPU shards. Its performance therefore affects more than one isolated GPU operation: it influences the efficiency of a major part of the model’s sparse computation path.

Meta has rewritten TorchRec’s TBE forward and backward kernels using FBTriton, its Triton fork, and reports that the new implementation outperforms the legacy CUDA templates across a broad set of production-shaped configurations [1]. The reported median forward speedup is 1.28x across 307 GB200 shard configurations, covering 283 distinct shapes.

The performance result is important, but the engineering approach is arguably more interesting. Embedding operations are irregular and memory-bound, characteristics that have traditionally made hand-written CUDA an attractive choice. Meta’s implementation demonstrates that a Triton-based approach can compete with, and in these tests outperform, an established CUDA implementation without retaining the same level of template complexity.

The rewrite also changes how the sparse execution path can be maintained. Rather than relying on a collection of template-generated CUDA kernels whose structure changes as new optimizations are introduced, the implementation expresses the kernel logic in Python using Triton. Hardware-specific capabilities can then be enabled through configuration flags, allowing the core kernel bodies to remain consistent across Blackwell, Hopper and AMD targets [1:1].

Why it matters

Embedding lookups are not conventional dense matrix operations. A dense operation can often work through regular blocks of data, while an embedding workload retrieves rows according to indices supplied by the input batch. Those indices determine which parts of the embedding tables must be accessed, and the number of samples that refer to an individual row can vary dramatically.

That irregularity makes performance difficult to optimize. The GPU must retrieve data from locations that are not necessarily adjacent, combine values belonging to the same bag, and handle workloads in which different rows receive very different amounts of work. The operation can be constrained by memory traffic, memory latency, the distribution of row accesses and the way work is divided among GPU programs.

For a long time, these characteristics have made hand-written CUDA a natural implementation choice. CUDA provides direct control over execution structure and hardware behavior, but that control can come with a maintenance cost. Template-generated kernels may need different implementations for different workload shapes, and adding a new optimization can require changing the structure of the generated kernels rather than simply adjusting a parameter.

Meta’s argument is that Triton can offer a better balance. The FBTriton implementation retains the ability to specialize execution for different workload characteristics, but exposes those decisions through a more compact programming model. According to Meta, optimizations that would require restructuring the CUDA template implementation can instead be represented as configuration changes in Triton [1:2].

That distinction matters to teams maintaining recommendation, ranking and retrieval infrastructure. Performance engineering does not end when a kernel reaches a particular throughput target. Workloads evolve, hardware changes, and new optimization opportunities appear. A kernel implementation that is easier to adapt can reduce the engineering effort required to keep pace with those changes.

The result is not that CUDA has become irrelevant or that Triton automatically wins for every irregular workload. Meta’s measurements show a more specific outcome: for the tested TBE configurations, the Triton implementation achieved a higher median forward performance, with particularly large gains in a workload range where the CUDA implementation changes to a more complex execution strategy.

What happened

Meta evaluated the FBTriton implementation across 307 shard configurations on NVIDIA GB200 GPUs, representing 283 distinct shapes. The comparison used FP16 embedding weights and exact row-wise Adagrad [1:3].

Across this test set, the Triton kernels delivered a median forward speedup of 1.28x over the legacy CUDA TBE implementation. This is a median across the tested shard configurations, not a claim that every individual configuration became 28% faster. The distribution of workload shapes matters: some configurations showed substantial improvements, some were approximately at parity, and a small group performed below parity.

The most significant gains came from the way the two implementations handled rows with different numbers of samples.

In the CUDA implementation, execution switches to a cooperative, thread-block-per-row kernel once a row is touched by 32 samples. Triton retains a simpler streaming execution path until the number of samples reaches 256. That difference changes how the workload is processed in the range between those thresholds.

For rows touched by between 32 and 256 samples, Meta reports that Triton ran 4.3x faster while moving approximately the same number of bytes from DRAM [1:4]. Nsight Compute measurements showed the CUDA kernel achieving 678 GB/s, compared with 3,948 GB/s for Triton, at identical occupancy.

The bandwidth figures highlight the size of the gap. The Triton implementation reached roughly 5.8 times the measured DRAM bandwidth of the CUDA kernel on these shapes. Because the amount of DRAM traffic was approximately the same, the difference was not simply the result of Triton moving less data. It reflected a more effective use of available memory bandwidth under this particular execution strategy.

This is the central performance observation in Meta’s results. The CUDA implementation changes its execution approach at a relatively low sample count, while Triton continues streaming through a wider range of workloads. The simpler path performs particularly well for the intermediate range tested.

However, the results also establish an important boundary. Triton does not outperform CUDA uniformly across all shapes.

When each row is touched by fewer than four samples, Triton falls below parity. These workloads are affected by dependent-load latency, and the affected group contains 11 of the 307 shards. Each of those cases takes less than approximately one millisecond. At the other end of the distribution, shapes above 256 samples per row reach parity [1:5].

The overall result is therefore more nuanced than a simple claim that Triton is faster than CUDA. The median improves because Triton handles a meaningful range of production-shaped workloads more efficiently, while its weakest cases are concentrated in a relatively small group of very short runs.

How it works

The FBTriton implementation covers both sides of the embedding operation: the forward pass that gathers and pools embedding rows, and the backward pass that combines gradients and applies optimizer updates.

These phases have different execution requirements. Forward processing gathers data based on indices and produces pooled outputs. Backward processing must account for every occurrence of a row, combine the corresponding gradients and ensure that the optimizer update is applied correctly.

The implementation uses different paths to handle the range of workload shapes rather than forcing every configuration through one execution strategy.

Forward: gathering and pooling embedding rows

For each table and bag, the forward kernel gathers the indexed embedding rows and combines them into a pooled output. If per-sample weights are supplied, those weights are applied during accumulation.

The accumulation is performed in FP32, or FP64 when the weights are FP32, before the pooled result is written. This gives the kernel a defined accumulation path while working with the input representation used by the tested configuration.

Most shapes use a generic execution path. This is important because the implementation does not require a separate specialized kernel for every possible table or batch configuration. A general path can handle the majority of workloads, while selected cases use a more specialized strategy when their characteristics justify it.

For small tables, the implementation has a specialized path that builds a histogram of indices and uses tensor cores through tl.dot [1:6]. The histogram provides a different way to organize the work around the indices being accessed. Rather than treating every lookup as an entirely independent operation, the specialized path can use the index distribution to structure the computation.

The distinction between the generic and specialized paths is an example of the broader design philosophy. The implementation retains a general-purpose route, then introduces specialized behavior for workload categories where a different execution strategy can be beneficial.

The most consequential forward optimization, however, is the decision to keep using the streaming path up to 256 samples per row. The CUDA implementation changes to a cooperative thread-block-per-row strategy at 32 samples. Meta’s measurements suggest that the Triton streaming approach remains effective well beyond that threshold.

This is not a universal rule for every embedding kernel. It is a result tied to the tested TBE workload and its access patterns. The practical lesson is that the point at which an implementation changes execution strategy should be determined by measured workload behavior, not assumed from a fixed threshold.

Backward: combining gradients before the optimizer update

The backward pass introduces a different challenge. A row may be referenced by multiple positions in the batch, and all of those contributions must be combined before the optimizer update is applied.

For every unique row touched in a batch, the kernel sums the upstream gradients from every position that referenced that row. It then performs exactly one optimizer update for that row.

The number of samples touching a row can vary from one to millions within a single batch. A single execution strategy would therefore have to handle workloads with very different amounts of work per row. Meta routes these runs to one of three kernels based on their length [1:7].

Short runs: under 256 lookups.

For short runs, one program performs the complete operation. It gathers the relevant gradient contributions, combines them and applies the update without using atomics.

Keeping the work inside one program avoids the need to coordinate partial results across multiple programs. This is suitable when the number of lookups is small enough for one program to handle the complete run.

Long runs: split work into chunks.

A row with a large number of lookups can require too much work for a single program. The implementation divides these runs into chunks of 256 lookups. Each chunk produces a partial sum, and those partial sums are combined before the optimizer update is applied.

This makes it possible to distribute a large amount of work across multiple programs while preserving the requirement that the row receives one optimizer update.

The scale of the split becomes clear in Meta’s example of a row with two million lookups. Dividing that work into chunks of 256 produces roughly 8,000 sub-programs. Instead of asking one program to process the entire row, the kernel can parallelize the partial accumulation and combine the results before updating the embedding.

The key is the separation between gradient accumulation and the optimizer step. Parallel programs can contribute partial sums, but the update must happen only after the contributions have been combined.

Fused execution: very large batches on Blackwell.

For very large batches on Blackwell, Meta introduces a fused path. A device-scope fence allows the last sub-program to apply the optimizer update within the same launch [1:8].

This changes where the final update happens. Rather than requiring a separate stage to perform the optimizer operation after all partial work has completed, the implementation uses coordination at device scope to let the final contributing program perform the update.

The fused path is a hardware-enabled optimization for a specific class of workloads. It should not be interpreted as the default execution strategy for every backward operation. The implementation retains the short-run and long-run approaches, with the fused path available for very large batches on Blackwell.

Together, these three strategies address the wide variation in the number of lookups associated with individual rows. Short runs remain simple and self-contained; long runs are divided into manageable chunks; and very large Blackwell workloads can use the fused update path.

Blackwell features as flags

One of the more interesting architectural decisions is how the implementation incorporates newer GPU capabilities.

Through Meta’s TLX extensions, FBTriton uses several hardware-oriented features:

  • Cluster launch control for hardware load balancing.
  • Device-scope fences for coordination across programs.
  • TMA bulk reductions instead of element-wise atomics.

These capabilities extend the implementation’s execution options without requiring a separate kernel body for every hardware generation. Meta describes them as additive flags: the same kernel bodies remain usable across Blackwell, Hopper and AMD, while supported features can be enabled through configuration [1:9].

This is a meaningful difference from an implementation strategy that creates separate kernel structures for each hardware target. When hardware-specific functionality is expressed as an optional capability, the general implementation can remain easier to maintain. The code does not need to be reorganized around every new optimization.

There is an important qualification: the portability described here is part of Meta’s FBTriton and TLX implementation. It does not mean that every feature is available in upstream Triton or that all hardware targets execute identical instructions. The point is that the kernel bodies can remain consistent while hardware-specific behavior is selected through flags.

For infrastructure teams, this approach offers a useful model. Hardware specialization and code maintainability do not necessarily have to be opposing goals. A kernel can expose specialized capabilities without duplicating its entire implementation for each supported architecture.

Avoiding host synchronization

Another important part of the design is how the implementation classifies work.

The number of lookups in a run determines whether it should be handled by the short-run or long-run path. But that classification information is known only on the GPU. Bringing it back to the CPU to decide which kernel should execute would introduce host synchronization into the process.

The implementation avoids that dependency.

A GPU kernel performs the classification using atomic counters. Later kernels read the resulting counts directly from device memory rather than synchronizing with the CPU [1:10].

This keeps the decision-making process on the device. The CPU does not need to wait for the GPU to finish classification, inspect the result and then dispatch the next operation based on that result.

That matters because synchronization can become an unnecessary dependency in a pipeline that is otherwise designed to keep work on the GPU. The implementation uses device-resident counters to communicate the classification results between stages, allowing subsequent kernels to select the appropriate work without a CPU round trip.

The broader engineering principle is that execution decisions should remain close to the data when the information required to make those decisions is already available on the accelerator. In this case, avoiding host synchronization supports the same goal as the adaptive kernel paths: reduce overhead while handling irregular workloads.

What data and AI engineers should do

Meta’s results are relevant beyond teams directly using TorchRec. They offer several practical lessons for engineers working on recommendation systems, retrieval models and custom GPU kernels.

  • Watch for the Triton TBE path in TorchRec if you train recommendation models on Blackwell. Meta’s results cover 307 GB200 shard configurations and use production-shaped workloads. The reported median improvement is a useful signal, but teams should validate performance against their own table sizes, batch distributions and shard shapes rather than assuming the same speedup will apply to every deployment.

  • Understand where your rows fall in the access distribution. The largest gains concentrate in the range where rows are touched by 32 to 256 samples. Very short runs, particularly those with fewer than four samples per row, may not benefit. Looking only at total batch size can hide this distinction. The number of samples touching an individual row is an important characteristic of the workload.

  • Treat execution thresholds as tuning decisions. The comparison illustrates how much the threshold for switching kernel strategies can matter. CUDA moves to a cooperative thread-block-per-row kernel at 32 samples, while Triton continues streaming up to 256. The performance difference in that interval suggests that a strategy that appears sensible for one implementation may not be optimal for another. Teams building their own kernels should measure the transition points against actual workload distributions.

  • Evaluate the forward and backward paths separately. The headline 1.28x result is a median forward speedup. The backward implementation includes several optimizations, but the reported results describe them by technique rather than presenting one aggregate backward-pass speedup. Engineers should avoid treating the forward result as an end-to-end training improvement without measuring the complete workload.

  • Try optional paths carefully. Meta exposes a fused bounds check in TorchRec, with an improvement of up to 1.24x on that component on B200, but it is off by default. Moving index sorting into the forward pass reduced combined latency by 16.8% on one large B200 configuration, but that optimization is not yet exposed in TorchRec [1:11]. These are useful signals, but they should be evaluated as specific optimizations rather than assumed to be general improvements.

  • Consider Triton for memory-bound kernels. The results challenge the assumption that irregular memory access automatically requires hand-written CUDA. Triton may provide sufficient control to optimize these workloads while keeping the implementation smaller and easier to modify. That does not guarantee a win for every kernel, but it makes Triton worth evaluating before committing to a large collection of specialized CUDA templates.

  • Measure the actual bottleneck rather than relying on a single throughput number. Meta’s Nsight Compute measurements help explain why the streaming path wins in the intermediate range: the implementations move approximately the same DRAM bytes, but achieve very different bandwidth. Looking at memory traffic, achieved bandwidth and occupancy together provides a stronger explanation than comparing elapsed time alone.

The broader takeaway is to approach GPU optimization as a workload-distribution problem. A kernel that performs well for a typical row may behave differently when a row receives only a handful of lookups or several million. The implementation needs to account for that range without adding so much specialization that the code becomes difficult to maintain.

Limitations and open questions

The results are encouraging, but they need to be interpreted within the scope of Meta’s evaluation.

First, all reported measurements come from Meta’s workloads and shard shapes. The 307 configurations provide a substantial test set, but they do not establish that the same performance distribution will appear in every recommendation system. Embedding table sizes, index distributions and batch characteristics can differ across deployments.

Second, the headline result is a median forward speedup. It is not an aggregate training-throughput measurement or a single end-to-end model speedup. The backward optimizations are described through individual techniques, including chunked accumulation and the Blackwell fused path, rather than through one consolidated backward performance number. Teams evaluating the implementation should benchmark both directions and the complete training workload.

Third, the weakest forward cases deserve attention even though they represent a small part of the tested set. Eleven of the 307 shards, each with fewer than four samples per row, fall below parity because of dependent-load latency. Meta notes that each of these cases takes less than approximately one millisecond. That limits their contribution to the overall result in the tested workload, but it does not make the underlying behavior irrelevant for deployments with a different distribution of very short runs.

The other boundary is the high-sample range. Shapes above 256 samples per row reach parity rather than showing the same large gains seen in the intermediate range. This reinforces the point that the 4.3x result is specific to the range where the CUDA and Triton implementations use different execution strategies.

There are also reproducibility considerations. Several of the hardware-oriented capabilities rely on Meta’s FBTriton fork and TLX extensions rather than upstream Triton. That affects how easily another team can reproduce the complete implementation and use the same features without adopting Meta’s software stack.

Finally, the post identifies further optimization opportunities. Meta lists additional fusion as future work, including treating the optimizer as a backward epilogue [1:12]. That suggests the current implementation is not necessarily the final form of the sparse execution path. Further fusion could change how much work is performed within each stage and where intermediate results are materialized, but the reported results do not establish what performance improvement such changes would deliver.

The practical question for other engineering teams is therefore not simply whether Triton is faster. It is whether the implementation model, hardware support and workload distribution match their own environment. The results make a strong case for evaluating Triton, but the measured gains should remain tied to the configurations in which they were observed.

Key takeaways

  • Meta’s FBTriton TBE kernels achieved a median 1.28x forward speedup over legacy CUDA across 307 GB200 shard configurations, covering 283 distinct shapes. [1:13]
  • A major performance advantage comes from retaining the streaming execution path up to 256 samples per row instead of switching strategies at 32. In the 32-to-256 range, Triton ran 4.3x faster while moving approximately the same DRAM bytes. [1:14]
  • Nsight Compute measured 678 GB/s for CUDA and 3,948 GB/s for Triton on the highlighted shapes, an approximately 5.8x bandwidth difference at identical occupancy. [1:15]
  • The backward path adapts to workload size: short runs are handled by one program, long runs are divided into 256-lookup chunks, and very large Blackwell batches can use a fused update path. [1:16]
  • Blackwell capabilities, including cluster launch control, device-scope fences and TMA bulk reductions, are exposed as flags through Meta’s TLX extensions, keeping the kernel bodies consistent across supported GPU targets. [1:17]
  • GPU-side classification and device-resident counters avoid bringing execution decisions back to the CPU for host synchronization. [1:18]
  • The broader engineering lesson is that Triton can be a serious alternative to hand-written CUDA for irregular, memory-bound workloads, but performance still depends on the distribution of actual workload shapes and the hardware features available.

FBTriton is an example of a shift in GPU kernel engineering: performance does not have to come from increasingly complex, hardware-specific template code. A carefully designed Triton implementation can combine workload-aware execution paths, device-side coordination and optional hardware capabilities while remaining easier to adapt. Meta’s measurements do not establish that Triton wins every embedding workload, but they make a compelling case that the boundary between high-level GPU programming and high-performance sparse kernels is moving.

Sources


  1. PyTorch Blog, “Modernizing Table Batched Embeddings with FBTriton”, 2026-10-07. https://pytorch.org/blog/modernizing-table-batched-embeddings-with-fbtriton/ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

Discussion

Join the discussion: create a free account or sign in to comment.

No comments yet.

Keep reading

Helion and NVIDIA CompileIQ: Autotuning GPU Kernels Down to the Compiler
AI Engineering

Helion and NVIDIA CompileIQ: Autotuning GPU Kernels Down to the Compiler

Kernel autotuners stop at tile sizes and warp counts. Helion can now search ptxas compiler controls in the same loop, using CompileIQ's Advanced Control Files, for 2 to 7% more speed on kernels already tuned.

Nov 19, 2026 · 4 min read
TorchTitan Update: New Frontier Models, Faster MoE Training and TitanRL for Reinforcement Learning
AI Engineering

TorchTitan Update: New Frontier Models, Faster MoE Training and TitanRL for Reinforcement Learning

PyTorch's TorchTitan adds Qwen3.5, Kimi K3 and DeepSeek-V4, an RL stack whose trainer and generator can produce bitwise-identical log-probabilities, and FlexShard, which cut Muon optimizer time by up to 79%.

Nov 18, 2026 · 4 min read
TorchTPU: PyTorch Runs Natively on Google TPUs, and Hugging Face Models Come Along
AI Engineering

TorchTPU: PyTorch Runs Natively on Google TPUs, and Hugging Face Models Come Along

Google and Meta built TorchTPU, a native PyTorch backend for TPUs with eager execution and torch.compile. Hugging Face Transformers, Diffusers and Kernels now treat "tpu" as just another device.

Nov 15, 2026 · 5 min read