Change
64ae17d
64ae17dd56a367dfaef5a8cc88f9cd0e1b9398c8 · commit on GitHub
pytorch-blog-feed: changed (185693 bytes, HTTP 200)
raw/pytorch-blog-feed/response.xml modified
- Source
- pytorch-blog-feed
- Lines added
- +255
- Lines removed
- -248
- Stored bytes at this commit
- 185,693
- Timestamp
- origin
- Raw artifact at this commit
- raw/pytorch-blog-feed/response.xml
Recorded headers
| observed_at | 2026-12-01T16:04:34.812Z |
|---|---|
| origin_date | 2026-12-01T15:55:14.000Z |
| status | 200 |
| final URL | https://pytorch.org/blog/feed/ |
| etag | "38c5f889ed7700619bbf48a91d7e1e38" |
| last-modified | Tue, 01 Dec 2026 13:45:53 GMT |
| date | Tue, 01 Dec 2026 16:04:34 GMT |
| age | 560 |
| cache-control | public, max-age=60, s-maxage=43200, stale-while-revalidate=86400, stale-if-error=604800 |
| cf-cache-status | null |
| content-encoding | null |
| content-length | 185693 |
@
@@ -12,7 +12,7 @@ <atom:link href="https://pytorch.org/blog/feed/" rel="self" type="application/rss+xml" /> <link>https://pytorch.org/blog/</link> <description></description>-
<lastBuildDate>Thu, 26 Nov 2026 02:44:16 +0000</lastBuildDate>+
<lastBuildDate>Tue, 01 Dec 2026 09:38:41 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod> hourly </sy:updatePeriod>@
@@ -28,6 +28,256 @@ <height>32</height></image> <item>+
<title>TLX.ops: Bridging Kernel Research and Real-World Performance</title>+
<link>https://pytorch.org/blog/tlx-ops-bridging-kernel-research-and-real-world-performance/</link>+
+
<dc:creator><![CDATA[Meta Contributors: Daohang Shi, Hongtao Yu, Lei Wang, Peng Chen, Nicholas Riasanovsky, Oleksandr Stashuk, Puyan Lotfi, Corbin Robeck, Wenyuan Chi, Alexey Loginov; AMD Contributors: Ivan Butygin, Bangtian Liu, Zhewen Yu, Aditya Kankariya, Nithin Meganathan, Stanley Winata, Shuc…+
<pubDate>Tue, 01 Dec 2026 13:45:53 +0000</pubDate>+
<category><![CDATA[Blog]]></category>+
<guid isPermaLink="false">https://pytorch.org/?p=215695</guid>+
+
<description><![CDATA[<p>High-performance GPU kernels are rarely one-size-fits-all. Their optimization strategies are impacted by GPU architectures, tensor shapes and evolving real-world workload demand. Even SOTA kernels optimized for specific cases can be...</p>+
<p>The post <a href="https://pytorch.org/blog/tlx-ops-bridging-kernel-research-and-real-world-performance/">TLX.ops: Bridging Kernel Research and Real-World Performance</a> appeared first on <a href="https://pytorch.org">PyTorch</a>.</p>+
]]></description>+
<content:encoded><![CDATA[<p>High-performance GPU kernels are rarely one-size-fits-all. Their optimization strategies are impacted by GPU architectures, tensor shapes and evolving real-world workload demand. Even SOTA kernels optimized for specific cases can be difficult to generalize and …+
<p>TLX.ops bridges this gap by turning SOTA, architecture-specific <a href="https://engineering.fb.com/2026/11/10/open-source/tlx-a-hardware-native-gpu-compiler-for-production-ml/">TLX kernels</a> into reusable implementations. Its catalog spans GEMM (including low-precision and grouped variants), a…+
<p>TLX.ops serves the following targeted users:</p>+
<ol>+
<li>For kernel engineers, the <a href="https://github.com/facebookexperimental/triton/tree/main/third_party/tlx/ops/kernels">organized code base</a> makes it easy to fork an existing kernel, build a variant, or contribute new implementations.</li>+
<li>For ML engineers, usage is as simple as <code>from triton.tlx.ops import mm as tlx_mm; out = tlx_mm(a, b)</code></li>+
<li>For kernel-authoring agents, we will keep the source code symbolic and structurally consistent, making it easier for agents to understand, modify, and generate kernels. We also provide TLX-agents (to be covered in a future post) to enable co-evolution between the kernel library and kernel-author…+
</ol>+
<h2>Workload-Driven Performance Contract</h2>+
<p>Rather than treating benchmark shapes as a static showcase of performance, TLX.ops maintains them as evolving optimization targets. This established an ongoing commitment to correctness, performance, and compile-time quality, guiding kernel optimization, validation, and regression detection.</p>+
<h2>Kernel Deep Dives: Architecture-Specific Optimizations</h2>+
<p>In this section, we walk through five kernels, four GEMMs and one LayerNorm, targeted at NVIDIA (Hopper/Blackwell) and AMD (MI300x/MI350x) GPUs. More examples are available in the <a href="https://github.com/facebookexperimental/triton/tree/main/third_party/tlx/ops/kernels">fbtriton repo</a>. Eac…+
<h3>Example 1. NVIDIA Blackwell GEMM</h3>+
<p>On NVIDIA Blackwell, <code>tcgen05</code> MMAs execute asynchronously, with accumulators residing in TMEM (256 KB per SM) rather than registers. Separate warps handle operand loading, MMA issuance and accumulator epilogues, creating opportunities for overlap but also synchronization challenges.</…+
<h4>Architectural Overview</h4>+
<p>In a simple case (1-CTA, SPLIT_K=1, power-of-two BN), each CTA computes one <code>BMxBN</code> output tile. TMA copies A/B tiles from GMEM to an SMEM buffer ring. Tile A is split into <code>MMA_GROUPS</code> row slices and each slice runs an async <code>tcgen05</code> MMA against the shared B til…+
<p><!-- IMAGE PLACEHOLDER: image1 - Figure-1 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig01_blackwell_gemm_overview.svg"><img decoding="async" class="alignnone size-full wp-image-215696" src="https://pytorch.org/wp-content/uploads/2026/11/fig01_blackwell_gemm_overview.svg" alt="" /></a></em></p>+
<p><em>Figure-1: Architectural overview before the optimizations (1-CTA, split-K-free configuration)</em></p>+
<h4>Asynchronous TMEM Hand-off and CLC scheduling</h4>+
<p>The key challenge is to avoid Tensor Core idle time at tile boundaries. Waiting for the final <code>tcgen05</code> MMAs to complete before notifying the epilogue would drain the MMA pipeline, even though the next tile can accumulate into a different TMEM buffer. Instead, <code>tlx.tcgen05_commit<…+
<p><!-- IMAGE PLACEHOLDER: image2 - Figure-2 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig02_blackwell_tmem_clc.svg"><img decoding="async" class="alignnone size-full wp-image-215697" src="https://pytorch.org/wp-content/uploads/2026/11/fig02_blackwell_tmem_clc.svg" alt="" /></a>Figure-2: Asynchronous TMEM hand-off and CLC s…+
<h4>Multi-CTA cooperation</h4>+
<p>With <code>NUM_CTAS=2</code>, each CTA holds its own A rows, <strong>half</strong> of B, and its own accumulator, reducing B’s per-CTA SMEM footprint and TMA traffic. <code>tlx.async_descriptor_load(..., two_ctas=True)</code> routes both CTAs’ TMA completion to leader-side barriers. Only CT…+
<p><!-- IMAGE PLACEHOLDER: image3 - Figure-3 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig03_blackwell_multi_cta.svg"><img decoding="async" class="alignnone size-full wp-image-215698" src="https://pytorch.org/wp-content/uploads/2026/11/fig03_blackwell_multi_cta.svg" alt="" /></a>Figure-3: Multi-CTA cooperation</em></p>+
<h4>Deterministic Split-K for Under-Filled, Long-K Outputs</h4>+
<p>In our workload, 38% of shapes have fewer 128×128 output tiles than SMs, most with K ≥ 100,000, leaving much of the GPU underutilized. Split-K partitions the K dimension into S ranges, creating S × num_mn_tiles independent work items that CLC schedules like ordinary output tiles. Each split write…+
<pre><code class="language-python"># Simplified from _process_tile_epilogue_inner and _reduce_k_kernel
+
+
split_id = tile_id // num_mn_tiles
+
row_base = split_id * num_pid_m * BLOCK_SIZE_M
+
# Store FP32 partial to the split's workspace slab
+
+
# Reduction kernel: fixed accumulation order
+
for s in range(SPLIT_K):
+
acc += tl.load(workspace_ptr + base_offs + s * ROWS_PER_SPLIT * N, ...)
+
tl.store(c_ptr + base_offs, acc.to(OUTPUT_DTYPE), ...)
+
</code></pre>+
<p>Configurations are heuristic picks from <code>get_heuristic_config</code>, computed on the CPU without launching kernels; the default <code>space="full"</code> autotunes each shape, so its measured winners may differ. Split-K increases parallelism for small outputs with long reduction dimensions,…+
<p><!-- IMAGE PLACEHOLDER: image4 - Figure-4 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig04_blackwell_config_selection.svg"><img decoding="async" class="alignnone size-full wp-image-215699" src="https://pytorch.org/wp-content/uploads/2026/11/fig04_blackwell_config_selection.svg" alt="" /></a></em></p>+
<p><em>Figure-4: Workload-driven configuration selection across 422 BF16 GEMM shapes</em></p>+
<h4>Examples of Other Shape-Specific Optimizations</h4>+
<ul>+
<li>Very tall outputs (M>>N): For example 32768×1024×1152. For 2-CTA clusters, pruning retains GROUP_SIZE_M=NUM_CTAS=2, so consecutive CTA pairs traverse the few N blocks while retaining the same two M blocks. This favors A reuse across nearby tiles while the small B remains L2-resident. (<a h…+
<li>Col-major operands: A is col-major in 200 out of 422 shapes, the TMA descriptor uses the transposed view and <code>tlx.local_trans</code> feeds the MMA without a copy (<a href="https://github.com/facebookexperimental/triton/pull/1116">#1116</a>).</li>+
<li>Tiny split-K outputs: (256×256×2433024) The reduction kernel uses a smaller 32×32 (instead of 128×128) block, so a 256×256 output launches 64 reduction CTAs instead of 4. (<a href="https://github.com/facebookexperimental/triton/pull/1118">#1118</a>)</li>+
<li>Tall, memory-bound outputs: For example 589824×2048×512. For GPU-saturated shapes with M/N > 4 and K ≤ 1.5·min(M,N), the heuristic favors narrower 256×128 tiles. Their smaller accumulators permit two TMEM buffers instead of one, overlapping the next tile’s MMAs with the current epilogue…+
<li>One MMA group: With NUM_MMA_GROUPS=1, each MMA step consumes exactly one A tile and one B tile, so A and B share a single transaction-byte-counted full barrier per SMEM slot by having the producer set the combined byte count. (<a href="https://github.com/facebookexperimental/triton/pull/2275">#2…+
<li>Non-power-of-two N: Split a NPOT tile into POT pieces (for example, 208=128+64+16), each with its own B ring, accumulator and MMA. Adjacent piece MMAs also share operand A in the TensorCore collector buffer. (<a href="https://github.com/facebookexperimental/triton/pull/4161">#4161</a>)</li>+
</ul>+
<h3>Example 2. AMD MI350x GEMM MXFP8</h3>+
<ul>+
<li>Unlike Blackwell’s TMA-based warp specialization, MI350x schedules global-to-LDS copies, LDS reads, and MFMAs within each wave’s instruction stream. Efficient GEMM must therefore keep future K-step copies in flight while overlapping LDS reads with computation.</li>+
<li>MXFP8 adds one E8M0 scale byte per 32 E4M3 values along K. MI350x’s 16×16×128 scaled MFMA consumes scales from 32-bit registers, selecting one of four packed bytes through opSel. Bytewise LDS scale loads and subsequent permutations therefore add instruction overhead despite the small scale…+
<li>Register pressure is another constraint: a 256×256 output tile across eight waves requires 128 FP32 accumulator registers per lane, leaving limited capacity for operands, scales, and addresses.</li>+
</ul>+
<p><!-- IMAGE PLACEHOLDER: image5 - Figure-5 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig05_mi350_gemm_overview.svg"><img decoding="async" class="alignnone size-full wp-image-215700" src="https://pytorch.org/wp-content/uploads/2026/11/fig05_mi350_gemm_overview.svg" alt="" /></a></em></p>+
<p><em>Figure-5: Architectural overview of MI350x GEMMs: (a) FP16/BF16 and (b) MXFP8 quadrant kernel</em></p>+
<h4>Inter-wave pipelining</h4>+
<p>The kernel uses eight waves, divided into two groups of four. Rather than assigning dedicated producer and consumer roles, both groups execute alternating <code>mfma</code> and <code>mem</code> stages. <code>tlx.warp_pipeline_stage</code> introduces conditional barriers that keep the groups one s…+
<h4>Quadrant pipeline with direct-to-LDS copies</h4>+
<p>The 256×256 output tile executes four 128×128 <code>tl.dot_scaled</code> quadrants in top-left → bottom-left → top-right → bottom-right order. Each operand half-tile has its own two-slot LDS ring, filled directly from global memory using <code>tlx.buffer_load_to_local</code> without register stag…+
<p>The quadrant ordering maximizes operand reuse: each B half-tile feeds two consecutive quadrants, while each A half-tile remains in registers across an intervening quadrant. In the steady state, each sub-step combines one quadrant’s computation with an LDS read and a future global-to-LDS ref…+
<pre><code class="language-python"># From _quad_tile, hot-loop sub-step 0
+
tlx.async_load_wait_group(5)
+
+
with tlx.warp_pipeline_stage("mfma", priority=0):
+
acc_tl = tl.dot_scaled(
+
a_top, sa_t, "e4m3", b_left, sb_l, "e4m3", acc_tl
+
)
+
+
with tlx.warp_pipeline_stage("mem", priority=1):
+
a_bot = tlx.local_load(smem_a_bot[0], relaxed=True)
+
sa_b = _load_scale(smem_sa_bot[0], _SA_MFMA_LAYOUT, K_MAJOR)
+
tlx.amd_sched_barrier(0)
+
tlx.buffer_load_to_local(smem_b_left[0], b_left_base, b_left_off + ka)
+
tlx.buffer_load_to_local(smem_sb_left[0], sb_left_base, sb_left_off + ks)
+
tlx.async_load_commit_group()
+
</code></pre>+
<p><!-- IMAGE PLACEHOLDER: image6 - Figure-6 --></p>+
<p> </p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig06_mi350_quadrant_pipeline.svg"><img decoding="async" class="alignnone size-full wp-image-215701" src="https://pytorch.org/wp-content/uploads/2026/11/fig06_mi350_quadrant_pipeline.svg" alt="" /></a>Figure-6: Quadrant pipeline and LDS …+
<h4>Scale Bytes in MFMA Consumption Order</h4>+
<p>Each lane’s 32-bit scale register holds four E8M0 bytes for rows 32 apart, one per 16-row MFMA repeat. For example, (1) lane 37 reads scales for rows 5, 37, 69, and 101 at the same K-group and <code>op_sel</code> selects the appropriate byte for each repeat. (2) With <code>sf_layout="cublas…+
<pre><code class="language-python"># Simplified from _kmajor_scale_view / _load_scale
+
view = _kmajor_scale_view(sa_buf) # 128×4 K-major atom
+
sa = tlx.local_load(
+
view, layout=_SA_MFMA_LAYOUT, relaxed=True
+
)
+
</code></pre>+
<p><!-- IMAGE PLACEHOLDER: image7 - Figure-7 --></p>+
<p><em><a href="https://pytorch.org/wp-content/uploads/2026/11/fig07_mi350_scale_packing.svg"><img decoding="async" class="alignnone size-full wp-image-215704" src="https://pytorch.org/wp-content/uploads/2026/11/fig07_mi350_scale_packing.svg" alt="" /></a>Figure-7: Scale packing for efficient LDS re…+
<h4>Examples of Other Shape-Specific Optimizations</h4>+
<ul>+
<li>Ragged M and N: For example, 129×257×256. On MI350x the public op accepts M and N that are not multiples of 128 (Blackwell requires 128-aligned rows); the generic tile wraps out-of-range rows and columns to valid ones and masks the store (<a href="https://github.com/facebookexperimental/triton/p…+
<li>Short or odd K: For example, 4096×4096×384. In the quadrant kernel, the pipelined loop covers an even number of 128-wide K-steps (here 2 of 3); the odd leftover step, or all of K when K = 128, runs as a cold tail with plain loads and no LDS ring (<a href="https://github.com/facebookexperimental/…+
<li>Large aligned problems: For example, 8192×8192×8192. The quadrant kernel is used only when whole 256×256 tiles (M, N multiples of 256), at least one tile per CU (M·N ≥ 4096²), 32-bit buffer offsets (128·K < 2³¹), and 16-byte-aligned pointers; any other shape uses a generic 128×128 tile (<a hr…+
</ul>+
<h3>Example 3. NVIDIA Hopper GEMM</h3>+
<p>Hopper supports TMA, warp specialization and async WGMMA, but has no TMEM. Compared with Blackwell, this introduces three important differences.</p>+
<ul>+
<li>First, register capacity constrains tile ownership. Due to the absence of TMEM, a single 4-warp group accumulating a 128×256 FP32 tile would require 256 registers per thread, exceeding Hopper’s 255-register limit. Therefore, we split the tile between two 4-warp consumer groups. Each g…+
<li>Second, WGMMA completion is managed through <code>tlx.async_dot_wait</code>, which waits until at most N WGMMA groups remain outstanding, rather than Blackwell’s <code>tcgen05_commit</code> and completion mbarriers.</li>+
<li>Third, the kernel uses a static persistent grid without CLC or two-CTA cooperation.</li>+
</ul>+
<h4>Cooperative consumers within a register budget</h4>+
<p>To address the register-pressure constraint described above (#1), each CTA runs one TMA producer warp group and two consumer warp groups (replicate=2), each of which owns half the output tile’s rows. Unlike Blackwell GEMM, Hopper GEMM has no dedicated epilogue warp group. Each consumer has …+
<pre><code class="language-python">with tlx.async_task(num_warps=4, replicate=2, registers=232): # consumers
+
acc = tlx.async_dot(a_stage, b_stage, acc)
+
acc = tlx.async_dot_wait(1, acc) # k-1 complete; k may remain outstanding
+
tlx.barrier_arrive(empty_a_prev) # private A slot: one arrival
+
tlx.barrier_arrive(empty_b_prev) # shared B slot: frees on the second arrival
+
</code></pre>+
<h4>Examples of Other Shape-Specific Optimizations</h4>+
<ul>+
<li>Skinny M: swap-AB. For M ≤ 64, two consumer groups would otherwise compute mostly padded rows. For example, M = 7 requires a 128-row tile, leaving the second consumer entirely on padding. Instead, the kernel computes Cᵀ = Bᵀ Aᵀ, mapping skinny M onto WGMMA’s N dimension. On 7×16384×4096, l…+
<li>Deterministic split-K and smaller tiles: For shapes such as 706×256×20992, the kernel uses smaller output tiles and divides K across CTAs to fill more SMs. FP32 partials are reduced in a fixed order, as in Blackwell GEMM. Split-K is limited to one wave of CTAs (tiles × splits ≤ SMs). Together, t…+
<li>Narrow N: L2 reuse and tile ordering. When N ≤ 1024, A loads use <code>evict_last</code> to preserve panels reused by neighboring N tiles. When N ≤ 512, the autotuner retains only row-major tile ordering to avoid unstable grouped-order performance. On 2000000×512×512, these refinements contribut…+
<li>Partial waves: NPOT N tiles. Hopper WGMMA requires power-of-two N widths, but the kernel can compose widths such as 192 = 128 + 64 using separate WGMMA operations. On 706×8192×2560, a 128×192 tile reduces occupancy from 2.91 to 1.95 tile waves, improving per-configuration latency from 46.3 to 44…+
</ul>+
<h3>Example 4. AMD MI300x GEMM</h3>+
<p>Unlike MI350x kernels, the MI300x GEMM uses direct register loads and compiler-managed scheduling rather than explicit inter-wave pipelining. Two key distinctions shape its design:</p>+
<ul>+
<li>Narrower direct-to-LDS copies and much smaller LDS. MI300x supports up to 32-bit-per-lane direct-to-LDS loads (vs. 128 on MI350x) and provides 64 KiB of LDS per CU (vs. 160 KiB). Our tuned GEMM kernel therefore loads operands directly into registers without LDS staging. (<a href="https://github.…+
<li>Compiler-managed memory/computation overlap. The direct-load kernel uses Triton’s two-stage software pipeline and MI300x ‘s BlockPingpong pass to overlap memory instructions with MFMAs across waves. Although <code>tlx.warp_pipeline_stage</code> has a MI300x lowering path, it has not …+
</ul>+
<h4>Occupancy-aware Planning</h4>+
<p>For underfilled GEMMs, <code>_fill_plan</code> chooses among direct, split-K, and Stream-K execution. It uses measured per-tile throughput and a wave-quantized cost model to compare direct and split-K configurations across 304 CUs:</p>+
<pre><code class="language-python">def wave_time(tile, tiles, k, rates):
+
bm, bn, bk, _ = tile
+
slots = 2 if bm * bn <= 8192 else 1
+
rounds = cdiv(tiles, 304 * slots)
+
work = bm * bn * cdiv(k, bk) * bk
+
return rounds * work / (rates[tile] * 1.23e12)
+
+
# Direct GEMM: one workgroup per output tile
+
direct_time = wave_time(tile, tiles, K, FILL_TILE_RATES)
+
+
# Split-K: more workgroups, plus FP32 partials and reduction
+
slice_k = cdiv(cdiv(K, bk), split) * bk
+
split_time = (
+
wave_time(tile, tiles * split, slice_k, rates)
+
+ (split + 1) * M * N * 4 / 3e12
+
+ 6e-6
+
)
+
</code></pre>+
<p>Smaller tiles can schedule two workgroups per CU, reducing wave quantization at the cost of lower per-tile throughput. The planner compares eligible configurations using this model. For severely underfilled, long-K workloads, Stream-K instead distributes (tile, K-step) iterations evenly across 30…+
<h4>Examples of Other Shape-Specific Optimizations</h4>+
<ul>+
<li>M = 7: intra-workgroup K splitting (LocalSplitU). For 7×8192×2048, only one output tile exists along M, limiting available workgroups. LocalSplitU uses smaller output tiles (BM=16, BN=32) and splits K across 16 waves within each workgroup. Each wave processes two of the 32 K tiles, writes its FP…+
<li>Ragged-K addmm: accumulator bias seeding. When K is not divisible by BLOCK_K and the bias is broadcast across rows, the kernel initializes the FP32 accumulator with the bias instead of adding it in the epilogue. This avoids an expensive epilogue layout conversion through LDS (<a href="https://gi…+
<li>XCD-Aware Tile Scheduling: MI300x distributes workgroups across eight XCDs, each with its own L2 cache slices. To improve operand locality, the kernel remaps complete groups of 64 workgroups so that each XCD receives eight consecutive logical tile IDs. The remapping preserves a bijection, while …+
<li>Stream-K: For example, 2032×2560×18688 produces only 160 output tiles with 256×128 tiling, leaving 144 of 304 CUs idle. Stream-K instead distributes 46,720 (tile, K-step) iterations across 304 programs, balancing the reduction work while preserving deterministic partial accumulation (<a href="ht…+
<li>Non-power-of-two M tiles: shared-B row panels. For FP16 MLP shapes such as 4662×2560×2560, a 160-row output tile is composed of 128-row and 32-row panels. Both panels reuse the same B operands while maintaining separate FP32 accumulators, reducing padding compared with 256-row tiles. The TorchTL…+
</ul>+
<h3>Example 5. NVIDIA Blackwell Layer Norm</h3>+
<p>LayerNorm performs only a few arithmetic operations per element while moving at least four bytes per element for BF16 input and output. Each output also depends on its row’s mean and variance, so the kernel must retain the row on chip or read it again. Features in related models are often narrow:…+
<h4>Architectural Overview</h4>+
<p>On the general path, each CTA owns <code>BM</code> rows and a <code>BN = next_power_of_2(N)</code> feature tile. Coalesced loads bring the input into registers, where FP32 reductions compute the mean, centered variance and reciprocal standard deviation. The same row values then feed normalization…+
<p><!-- IMAGE PLACEHOLDER: image8 - Figure-8 --></p>+
<p><em><img fetchpriority="high" decoding="async" class="alignnone wp-image-215705 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/fig08_blackwell_layernorm_overview.png" alt="" width="1800" height="650" srcset="https://pytorch.org/wp-content/uploads/2026/11/fig08_blackwell_layernorm_…+
<p><em>Figure-8: Architectural overview of the general register path and the N = 384 TMA path</em></p>+
<h4>Row Ownership and Deterministic Backward Reduction</h4>+
<p>The <code>_geometry</code> heuristic chooses how many threads share a row (<code>TPR</code>), how many warps run in a CTA (<code>NW</code>) and how many contiguous elements each thread loads (<code>V</code>, at most four). The <code>pin</code> helper anchors each load to a <code>tlx.layout</code>…+
<pre><code class="language-python"># Simplified from _common._stage_load, direct path
+
layout: tl.constexpr = tlx.layout(
+
shape=((TPR, NW * 32 // TPR),
+
(V, BN // (TPR * V), BM // (NW * 32 // TPR))),
+
stride=((V, BN), (1, TPR * V, NW * 32 // TPR * BN)))
+
x = pin(tl.load(X + offsets, mask=mask, other=0), layout)
+
</code></pre>+
<p>Backward reuses this row layout to compute <code>dX</code> while accumulating FP32 partial <code>dW</code> and <code>dB</code> vectors across the rows assigned to each persistent CTA. A separate <code>_param_reduce</code> kernel reduces those vectors in a fixed order, giving run-to-run determinis…+
<h4>Three Exact Chunks and a Persistent TMA Ring</h4>+
<p>For contiguous, 16-byte-aligned BF16 input with <code>N = 384</code> and <code>M ≥ 4096</code>, <code>_norm_fwd_384</code> represents each row as three 128-column chunks, avoiding the 128 padded columns of a 512-wide tile. This route requires contiguous output and no residual, post-normalization …+
<p>The TMA route holds two stages, each containing three 32×128 BF16 boxes (24 KiB per stage). Their combined transaction byte count is tracked by one completion mbarrier. A CTA issues the next block’s three copies before waiting for the current block. After reading all current chunks into registers…+
<pre><code class="language-python"># Simplified from _norm_fwd_384, USE_TMA path
+
if next_row < end_row:
+
next_id = buffer_id ^ 1
+
tlx.barrier_expect_bytes(producer_bars[next_id], expected_bytes)
+
for j in tl.static_range(CHUNKS):
+
tlx.async_descriptor_load(
+
x_desc, x_buffer[next_id * CHUNKS + j],
+
[next_row, j * CHUNK_N], producer_bars[next_id])
+
tlx.barrier_wait(producer_bars[buffer_id], producer_phase)
+
</code></pre>+
<p><!-- IMAGE PLACEHOLDER: image9 - Figure-9 --></p>+
<p> </p>+
<p><em><img decoding="async" class="alignnone wp-image-215706 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/fig09_blackwell_layernorm_tma_ring.png" alt="" width="1800" height="690" srcset="https://pytorch.org/wp-content/uploads/2026/11/fig09_blackwell_layernorm_tma_ring.png 1800w, h…+
<p><em>Figure-9: Two-stage TMA ring for N = 384 LayerNorm</em></p>+
<h4>Fused Normalization and Block-Scaled Quantization</h4>+
<p>The Blackwell MXFP8 APIs fuse normalization and quantization for compatible BF16 <code>N = 384</code> inputs with default options, and on the general fused route for <code>N ≤ 256</code> or <code>N ≤ 512</code> with <code>M ≥ 4096</code>. Other shapes normalize first and quantize in a second kern…+
<p>For dual scale output, one E8M0 scale is computed from each 32×32 block’s maximum absolute value. The square block supports both feature-reduction and row-reduction GEMMs: the same scale is repeated over rows in the MMA scale tensor and over columns in the cuBLAS blocked scale tensor. Both scale …+
<p><!-- IMAGE PLACEHOLDER: image10 - Figure-10 --></p>+
<p><em><img decoding="async" class="alignnone wp-image-215707 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/fig10_blackwell_layernorm_mxfp8_scales.png" alt="" width="1800" height="650" srcset="https://pytorch.org/wp-content/uploads/2026/11/fig10_blackwell_layernorm_mxfp8_scales.png …+
<p><em>Figure-10: One 32×32 amax block supplies both scale orientations for the same FP8 payload</em></p>+
<h2>Benchmarking Results</h2>+
<p>We benchmark TLX.ops across NVIDIA (Hopper/Blackwell) and AMD (MI300x/MI350x) GPUs, using continuously evolving shape sets selected from real workloads. In the demonstrated GEMM kernels, TLX.ops achieve up to 1.15x on Blackwell, 1.22x on Hopper, 1.4x on MI350x, and 1.24x on MI300x over cuBLAS/hip…+
<h2>Stock Triton Compatibility with uTLX</h2>+
<p>TLX is developed in <a href="https://pytorch.org/blog/fbtriton-infra-upstream-ingestion-hierarchical-validation-ideals-vs-realities/">fbtriton</a> while <a href="https://github.com/triton-lang/triton-ext/tree/main/extensions/utlx">µTLX</a> bridges TLX functionality to stock Triton using Triton’s …+
<pre><code class="language-bash">pip install torch # torch 2.15 pulls triton ~=3.9.0
+
pip install triton-utlx # or triton-utlx-rocm
+
git clone https://github.com/facebookexperimental/triton fbtriton
+
export UTLX_TLX_OPS_ROOT=$PWD/fbtriton/third_party/tlx
+
</code></pre>+
<pre><code class="language-python">import torch
+
import utlx_plugin # registers TLX with stock Triton
+
from triton.tlx.ops import mm as tlx_mm # served from the fbtriton checkout
+
a = torch.randn(4096, 4096, device="cuda", dtype=torch.bfloat16)
+
b = torch.randn(4096, 4096, device="cuda", dtype=torch.bfloat16)
+
out = tlx_mm(a, b)
+
</code></pre>+
<h2>Appendix 1: GPU Architecture Primer</h2>+
<ul>+
<li>NVIDIA Hopper features fourth-generation Tensor Cores with asynchronous warp-group matrix multiply-accumulate (WGMMA), alongside the Tensor Memory Accelerator (TMA) for efficient global-to-shared memory transfers. These capabilities enable pipelined GEMM implementations that overlap data movemen…+
<li>NVIDIA Blackwell features fifth-generation Tensor Cores (tcgen05.mma) and Tensor Memory (TMEM), a dedicated on-chip storage space for matrix accumulators. Together with TMA and asynchronous execution mechanisms, these features enable deeper compute-memory pipelining, reduced register pressure, a…+
<li>AMD MI300x features wavefront-based execution with Matrix Fused Multiply-Add (MFMA) instructions for high-throughput matrix computation and Local Data Share (LDS) for on-chip data exchange. Efficient kernels rely on carefully orchestrating global memory loads, LDS staging, MFMA execution, and so…+
<li>AMD MI350x extends MI300x with enhanced Matrix Cores supporting microscaling formats such as MXFP8, MXFP6, and MXFP4, along with increased LDS capacity and bandwidth. These improvements create new opportunities for low-precision GEMM and attention kernels through optimized data movement, operand…+
</ul>+
<h2>Appendix 2: Performance Disclosure</h2>+
<p>Performance results were collected at various stages of TLX.ops development. Representative benchmarking configurations as of November 30, 2026, are as follows:</p>+
<ul>+
<li><strong>NVIDIA B200:</strong> CUDA 13.0, PyTorch 2.14.0, cuBLAS/cuBLASLt 13.1.1.3, 750 W power limit, maximum GPU core clock.</li>+
<li><strong>NVIDIA H100:</strong> CUDA 13.0, PyTorch 2.14.0, cuBLAS/cuBLASLt 13.1.1.3, 700 W power limit, maximum GPU core clock.</li>+
<li><strong>AMD Instinct MI350X:</strong> ROCm 7.2, PyTorch 2.14.0, hipBLASLt 1.2.2, 1000 W power limit, 2100 MHz GPU core clock.</li>+
<li><strong>AMD Instinct MI300X:</strong> ROCm 7.2, PyTorch 2.14.0, hipBLASLt 1.2.2, 750 W power limit, 2100 MHz GPU core clock.</li>+
</ul>+
<p>The benchmark harness targets the above clock and power settings where supported and permitted. Benchmark scripts, workload shapes, reference implementations, and measurement methodology are available in the <a href="https://github.com/facebookexperimental/triton/tree/main">TLX repository</a>. Fo…+
<p>Unless otherwise specified, aggregate speedups represent the geometric mean of per-shape speedups, and “up to” speedups represent the maximum observed single-shape speedup. Performance may vary with hardware configurations, software versions, and workload characteristics.</p>+
<p>The post <a href="https://pytorch.org/blog/tlx-ops-bridging-kernel-research-and-real-world-performance/">TLX.ops: Bridging Kernel Research and Real-World Performance</a> appeared first on <a href="https://pytorch.org">PyTorch</a>.</p>+
]]></content:encoded>+
+
+
+
</item>+
<item> <title>Explore the PyTorch Day China 2026 Schedule</title> <link>https://pytorch.org/blog/explore-the-pytorch-day-china-2026-schedule/</link> @
@@ -40,7 +290,7 @@ <description><![CDATA[<p>The next wave of AI innovation is happening now. Join the developers, researchers, engineers, and industry leaders driving that progress at PyTorch Day China 2026, taking place December 12 in...</p><p>The post <a href="https://pytorch.org/blog/explore-the-pytorch-day-china-2026-schedule/">Explore the PyTorch Day China 2026 Schedule</a> appeared first on <a href="https://pytorch.org">PyTorch</a>.</p>]]></description>-
<content:encoded><![CDATA[<p><span style="font-weight: 400;"><img fetchpriority="high" decoding="async" class="alignnone size-large wp-image-214091" src="https://pytorch.org/wp-content/uploads/2026/11/PyTorch-Day-China-Schedule-1024x536.jpeg" alt="PyTorch Day China Schedule" width="1024" h…+
<content:encoded><![CDATA[<p><span style="font-weight: 400;"><img decoding="async" class="alignnone size-large wp-image-214091" src="https://pytorch.org/wp-content/uploads/2026/11/PyTorch-Day-China-Schedule-1024x536.jpeg" alt="PyTorch Day China Schedule" width="1024" height="536" srcset="h…<p><span style="font-weight: 400;">Whether you’re building AI applications, optimizing models, advancing hardware acceleration, or contributing to open source projects, PyTorch Day China offers valuable opportunities to gain new insights, exchange ideas, and connect with the community. </span>…<h2><b>Featured Sessions</b></h2><p><span style="font-weight: 400;">Get inspired by technical presentations from leading experts and innovators. A few featured sessions include:</span></p>@
@@ -588,10 +838,10 @@ void run_policy(Module& policy, cudaStream_t stream) { <category><![CDATA[Blog]]></category> <guid isPermaLink="false">https://pytorch.org/?p=211755</guid>-
<description><![CDATA[<p>PyTorch Foundation Ambassadors bring people together to learn, share technical knowledge and contribute to PyTorch Foundation projects and the wider open-source AI ecosystem. In this November roundup, we highlight some...</p>+
<description><![CDATA[<p>PyTorch Foundation Ambassadors bring people together to learn, share technical knowledge and contribute to PyTorch Foundation projects and the wider open source AI ecosystem. In this November roundup, we highlight...</p><p>The post <a href="https://pytorch.org/blog/pytorch-ambassador-community-highlights-november-2026/">PyTorch Foundation Ambassador Community Highlights November 2026</a> appeared first on <a href="https://pytorch.org">PyTorch</a>.</p>]]></description>-
<content:encoded><![CDATA[<p data-pm-slice="1 1 []"><a href="https://pytorch.org/programs/ambassadors/">PyTorch Foundation Ambassadors</a> bring people together to learn, share technical knowledge and contribute to PyTorch Foundation projects and the wider open-source AI ecosystem.</p>+
<content:encoded><![CDATA[<p data-pm-slice="1 1 []"><a href="https://pytorch.org/programs/ambassadors/">PyTorch Foundation Ambassadors</a> bring people together to learn, share technical knowledge and contribute to PyTorch Foundation projects and the wider open source AI ecosystem.</p><p>In this November roundup, we highlight some of our ambassadors’ activities, including local meetups, university sessions, technical articles and practical learning resources.</p><h2 style="font-size: 23px; font-weight: 600; line-height: 1.35; margin: 24px 0 10px; padding: 0;">PyTorch Community Meetup in Kampala</h2><p style="margin: 0 0 14px; padding: 0; line-height: 1.65;"><span style="font-weight: 400;">On September 19, </span><b>Pacifique Mugisho</b><span style="font-weight: 400;"> organized an in-person PyTorch East Africa community meetup at Makerere University in Kampala, Uganda, in collaboration with th…@
@@ -1066,251 +1316,8 @@ for model in models: -
</item>-
<item>-
<title>Optimizing Muse Spark Open on TPU v7 with SGLang-TorchTPU</title>-
<link>https://pytorch.org/blog/optimizing-muse-spark-open-on-tpu-v7-with-sglang-torchtpu/</link>-
-
<dc:creator><![CDATA[Haolin Fu, Xiaoyu Zhang, Junyan Xu, Wangyuan Zhang, Haoguang Cai, RadixArk Team]]></dc:creator>-
<pubDate>Tue, 10 Nov 2026 16:45:24 +0000</pubDate>-
<category><![CDATA[Blog]]></category>-
<guid isPermaLink="false">https://pytorch.org/?p=210192</guid>-
-
<description><![CDATA[<p>TL;DR We serve Meta’s Muse Spark Open, an 816B-parameter mixture-of-experts model, on a single TPU v7 host of four chips, with SGLang running on the TorchTPU PyTorch backend. At the...</p>-
<p>The post <a href="https://pytorch.org/blog/optimizing-muse-spark-open-on-tpu-v7-with-sglang-torchtpu/">Optimizing Muse Spark Open on TPU v7 with SGLang-TorchTPU</a> appeared first on <a href="https://pytorch.org">PyTorch</a>.</p>-
]]></description>-
<content:encoded><![CDATA[<h2>TL;DR</h2>-
<p>We serve Meta’s Muse Spark Open, an 816B-parameter mixture-of-experts model, on a single TPU v7 host of four chips, with SGLang running on the TorchTPU PyTorch backend. At the center is a megakernel: all 62 layers of a decode or verify step run as one Pallas program, and every weight load, …-
<ul>-
<li><strong>Decode speed.</strong> The megakernel halves the time per output token for one or two concurrent requests, where it helps the most; the gain narrows as concurrency grows. Its verify step runs within 1.5–1.7× of the time it takes just to stream its weights from HBM.</li>-
<li><strong>AgentX.</strong> On the 1M-context version of SemiAnalysis’s agentic-coding benchmark, our curve runs from 433 output tokens/s per request at 6,101 tokens/s per chip to 25,906 tokens/s per chip at 95 tokens/s per request (Figure 1).</li>-
</ul>-
<h2>Results</h2>-
<p><!-- IMAGE PLACEHOLDER: Figure 1 (image1) - InferenceX AgentX chart, tokens per dollar vs p90 interactivity. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210193 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-1.png" alt="" width="1400" height="1009" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-1.png 1400w, https://pytorch.org/wp-content/uploads…-
<p><em><strong>Figure 1.</strong> InferenceX AgentX, 1M-context trace set: tokens per dollar against p90 interactivity. TPU v7: one host, four chips, FP8 compute with NVFP4 expert weights. GB200 (FP4) is shown as a baseline from InferenceX’s published results as of 2026-11-02. Costs are Infere…-
<p><a href="https://inferencex.semianalysis.com/blog/agentic-benchmark-agent-benchmark-guide">AgentX</a> is built from 393 opt-in Claude Code sessions. It replays their request lengths, prefix sharing between turns, tool pauses and subagent structure, with synthetic tokens in place of the original c…-
<h2>Background</h2>-
<h3>The model</h3>-
<p>Muse Spark Open is Meta’s open-weights mixture-of-experts (MoE) [1] model, with 816B parameters in total and about 42B active per token.</p>-
<ul>-
<li><strong>62 decoder layers, all of them MoE.</strong> Each layer routes every token to 8 of 256 experts.</li>-
<li><strong>Hybrid attention.</strong> 46 layers use sliding-window attention [2] over the last 2,048 tokens; the other 16 attend over the full context, up to 1M tokens. Attention has 128 query heads and 16 KV heads, each 64 wide.</li>-
<li><strong>NVFP4 experts.</strong> Expert weights are 4-bit, with one scale per 16 values, a microscaling format [3].</li>-
</ul>-
<h3>The hardware</h3>-
<p>One <a href="https://docs.cloud.google.com/tpu/docs/tpu7x">TPU v7 (Ironwood)</a> host has four chips. Each chip packs two chiplets, each with one TensorCore and its own HBM, and frameworks expose each chiplet as a device, so a host has 8 devices. We shard the model 8 ways with tensor parallelism …-
<p><!-- IMAGE PLACEHOLDER: Figure 2 (image2) - TPU v7 chip diagram. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210194 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-2.png" alt="" width="1400" height="1046" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-2.png 1400w, https://pytorch.org/wp-content/uploads…-
<p><em><strong>Figure 2.</strong> One TPU v7 chip, simplified from the architecture diagram in <a href="https://docs.cloud.google.com/tpu/docs/tpu7x">Google Cloud’s TPU7x documentation</a>. The numbers are Google’s published figures.</em></p>-
<p>Each device is a single-threaded processor: one program runs at a time, so speed comes from keeping the matrix units fed and overlapping memory transfers with compute inside that program. These are the units that matter in this post, as described in <a href="https://docs.cloud.google.com/tpu/docs…-
<ul>-
<li><strong>Scalar unit.</strong> One per device, with its own small scalar memory (SMEM). It runs the control flow: loops, branches and address math.</li>-
<li><strong>MXU, the matrix unit.</strong> Two per device. They do the matmuls; the chip’s peak is 2,307 TFLOPs in bf16 and 4,614 in fp8. At small batch they mostly wait for weights to arrive from HBM.</li>-
<li><strong>Vector unit (VPU).</strong> Elementwise work such as norms, softmax exponentials and format conversions. On recent TPUs it computes on 2D vector registers of 8 × 128 32-bit values, 8 sublanes by 128 lanes, so a data layout that leaves lanes empty wastes both vector work and memory (secti…-
<li><strong>VMEM.</strong> On-chip SRAM next to the MXUs and the vector unit, with much higher bandwidth than HBM. Kernels stage their tiles here, so its size bounds how much a kernel can keep in flight.</li>-
<li><strong>DMA engines.</strong> They move data between HBM, VMEM and other devices in the background: a kernel starts a copy and waits for it later, while it computes. The megakernel’s pipelining (section 2) is built on them.</li>-
<li><strong>HBM.</strong> 192 GiB per chip at 7.37 TB/s, 96 GiB of it on each device.</li>-
<li><strong>Die-to-die link.</strong> It joins the two devices of a chip; Google documents it as six times faster than a 1D ICI link. Section 8’s pair exchange leans on it.</li>-
<li><strong>ICI.</strong> Six links per chip at 200 GB/s each, counting both directions, for 1,200 GB/s per chip. The four chips of a host talk to each other over it; slices of 64 chips or more form 3D tori.</li>-
<li><strong>Host.</strong> Each chip connects to the host’s CPUs over PCIe Gen5 ×16. A 4-chip host has 960 GB of DRAM, which L2 HiCache uses as a second cache tier (section 7).</li>-
<li><strong>SparseCores.</strong> Four per chip. This work does not use them.</li>-
</ul>-
<p>The <a href="https://pytorch.org/blog/introducing-torchtpu/">TorchTPU post</a> has a longer primer.</p>-
<h3>The software</h3>-
<p>The server is <a href="https://github.com/sgl-project/sglang-torchtpu">SGLang-TorchTPU</a>: SGLang’s [5] scheduler, KV cache and model code in PyTorch, with <a href="https://docs.jax.dev/en/latest/pallas/index.html">Pallas</a> kernels on the hot paths. We decode with speculative decoding [6…-
<h2>1. A megakernel</h2>-
<p>At small batch, generating a token does little math per weight, so the step is as fast as HBM can stream the weights, as long as nothing interrupts the stream. A decode or verify step should therefore be one uninterrupted stream of weights from HBM into the MXU. Our previous path (“native&#…-
<p>The native path was already built from fused Pallas blocks, yet its verify step took 2.9× the time needed to stream its weights. Profiling our first one-kernel prototype showed why: at batch 1 the matmuls and attention cost almost nothing, while collectives cost about 45 µs per layer. Nothing ove…-
<p><!-- IMAGE PLACEHOLDER: Figure 3 (image3) - one step through the megakernel. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210195 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-3.png" alt="" width="1400" height="772" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-3.png 1400w, https://pytorch.org/wp-content/uploads/…-
<p><em><strong>Figure 3.</strong> One step. Inside the megakernel every layer runs the same flow (white); the shaded boxes are data movement the kernel issues itself.</em></p>-
<p>For each step, every device runs one <code>pallas_call</code> that covers all 62 layers and the final norm. SGLang still runs the embedding, the draft model, a small KV-write kernel, the LM head and sampling around it.</p>-
<p><!-- IMAGE PLACEHOLDER: Figure 4 (image4) - time per verify step, native vs megakernel. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210196 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-4.png" alt="" width="1400" height="694" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-4.png 1400w, https://pytorch.org/wp-content/uploads/…-
<p><em><strong>Figure 4.</strong> Time per verify step, both paths with DFlash2 speculative decoding (GSM8K, measured on an earlier Muse Spark checkpoint). The floor is the time to stream that step’s distinct experts and dense weights from HBM.</em></p>-
<p>Per output token, the megakernel is 1.94× faster than the native path for a single request (1.95 ms against 3.78 ms) and 1.85× for two concurrent requests. The next sections show what made one program this fast.</p>-
<h2>2. Pipelining everything inside the megakernel</h2>-
<p>A step is mostly data movement: weights, KV cache and partial sums between devices. Once the whole step is one program, the kernel can schedule every transfer so that it lands just before the compute that needs it [11], including across layer boundaries [10]. Figure 5 sketches one layer.</p>-
<p><!-- IMAGE PLACEHOLDER: Figure 5 (image5) - one layer of a step, DMA streams vs compute. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210197 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-5.png" alt="" width="1400" height="932" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-5.png 1400w, https://pytorch.org/wp-content/uploads/…-
<p><em><strong>Figure 5.</strong> One layer of a step, schematic. Each DMA stream runs ahead of, or alongside, the compute that consumes it.</em></p>-
<h3>Weights arrive before they are needed</h3>-
<ul>-
<li><strong>A ring for dense weights.</strong> Attention, o-proj and router weights stream through a ring of tiles that prefetches across layer boundaries. About ten tiles in flight sustain 3.34 TB/s per device, while a single DMA stream reaches only 1.13 TB/s.</li>-
<li><strong>Experts as soon as routing finishes.</strong> The router’s choice is known only mid-layer, so the kernel requests each chosen expert’s weights the moment routing ends, with three experts in flight.</li>-
<li><strong>The next layer during the expert loop.</strong> Refills for the next layer’s attention weights are held until the expert loop runs, so they never compete with the expert weights the current layer is waiting for.</li>-
</ul>-
<h3>Collectives leave as soon as their data exists</h3>-
<p>Tensor parallelism exchanges partial sums between the 8 devices several times per layer. Instead of a separate collective after each matmul, the kernel writes partial results straight into the owning device’s memory with remote DMAs issued from inside the kernel; a small round costs about 3…-
<ul>-
<li><strong>Streamed o-proj.</strong> Each o-proj output tile leaves for its owner as soon as it is computed, while the next tile is still being multiplied.</li>-
</ul>-
<h3>Pipelined KV writes</h3>-
<p>Each step writes its new K and V rows into the cache. In our fp8 sequence-on-lane cache (section 7), a token is one lane column of a 256-token page, so writing a token means reading the whole page block into VMEM, merging the new columns, and writing the page back.</p>-
<p>This runs as a small kernel right after the megakernel, because XLA copies the aliased operands of any kernel that issues remote DMA. It used to do every page in turn: read, wait, merge, write, wait, for each request and each of 62 layers.</p>-
<p><!-- IMAGE PLACEHOLDER: Figure 6 (image6) - pipelined KV-write kernel with two VMEM banks. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210198 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-6.png" alt="" width="1400" height="1034" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-6.png 1400w, https://pytorch.org/wp-content/uploads…-
<p><em><strong>Figure 6.</strong> Schematic. The pipelined kernel issues all of a layer’s page reads at once, merges each page as it lands, and starts its write; the next layer’s reads start immediately on a second VMEM bank.</em></p>-
<p>The new kernel loads all layers’ new rows once, then keeps two VMEM banks: layer l reads into one while layer l−1’s writes drain from the other, and a bank is reused only after the writes of two layers earlier have landed. The write cost per step fell from 810 to 155 µs at 16 rows and…-
<h2>3. Collective folding</h2>-
<p>Because each layer is split across 8 devices, a device often has to collect the others’ results before it can continue. After the MoE and after attention, each device holds one slice of the layer’s output along the hidden dimension, and must all-gather the other seven slices before th…-
<p><!-- IMAGE PLACEHOLDER: Figure 7 (image7) - folded matvec consuming gathered slices. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210199 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-7.png" alt="" width="1400" height="924" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-7.png 1400w, https://pytorch.org/wp-content/uploads/…-
<p><em><strong>Figure 7.</strong> Schematic. The folded matvec multiplies each gathered slice as soon as it lands, starting with the device’s own, and applies the per-row normalization at the end.</em></p>-
<p>What makes this possible is where Muse Spark normalizes. The next layer’s attention input is an RMS norm [13] of the residual stream α·x + β·s·f, where x is the residual this device already holds, f is the gathered MoE output and s is f’s own norm factor. The two norm factors, s and t…-
<p><!-- IMAGE PLACEHOLDER: image8 - EQUATION for the collective-folding projection split (not a figure; the following paragraph depends on it). Download from the Doc and re-upload via WP Media Library. --></p>-
<p>Here g is the norm’s gain vector, f_d is the slice from device d, and W_d is the matching block of weight rows. The kernel stacks the local part and the arriving slice into one product per block, consumes the slices in a fixed peer order, and reorders the weight ring so that W’s block…-
<p>The kernel folds two all-gathers per layer this way: the MoE output into the next layer’s qkv projection, and the attention output into the pooler and router. The residual stream itself is unchanged; only the point where the matmul input is rounded to bf16 moves, so results are not bit-iden…-
<h2>4. Enabling better pipelining in attention</h2>-
<p>At long context, attention is the largest part of a step. The kernel walks the KV cache chunk by chunk, and the key bottleneck was the running max of online softmax [14]: it chained every chunk to the one before, so chunks could not be pipelined.</p>-
<h3>The running max chains every chunk</h3>-
<p>Online softmax, as used by FlashAttention [15], keeps the maximum score seen so far. Each new chunk computes its scores, updates that maximum, exponentiates against it, and rescales everything accumulated so far whenever the maximum grows. So each chunk is a serial chain (wait for its DMA, QK, ma…-
<h3>Muse Spark makes the max unnecessary</h3>-
<p>Muse Spark normalizes q and k (QK-norm [16, 17]) with an RMS norm that has no learned weight, and gives q a fixed gain. No attention score can exceed 43.8 in magnitude, far from where exp overflows in f32. The running max exists only to prevent that overflow, so the kernel drops it, along with th…-
<p><!-- IMAGE PLACEHOLDER: Figure 8 (image9) - chunk chains with vs without running max. Download from the Doc and re-upload via WP Media Library. --></p>-
<p><strong><img decoding="async" class="alignnone wp-image-210202 size-full" src="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-8.png" alt="" width="1400" height="854" srcset="https://pytorch.org/wp-content/uploads/2026/11/Muse-Figure-8.png 1400w, https://pytorch.org/wp-content/uploads/…-
<p><em><strong>Figure 8.</strong> Schematic. With a running max, each chunk’s chain waits on the previous chunk. Without it, chunks are independent and their stages overlap.</em></p>-
<h3>Independent chunks pipeline</h3>-
<p>Without the max, chunks no longer depend on each other. The kernel issues all DMA waits at the top of each loop iteration, splits the chunks across several independent softmax streams that merge at the end, as Flash-Decoding does across the KV sequence [19], and software-pipelines the loop [11]: …-
<p>Three smaller changes shorten each chain further:</p>Diff display stops at 400 lines. The line counts above are from the whole diff. 87 lines shown here cut at 300 characters. The raw artifact at this commit is linked above.