Inference Latency Analysis of H3 Ref2VA on PPU

Date: November 27, 2026 | Model: Vanilla MiniMax H3 Ref2VA | Hardware: PPU-ZW810E (96 GiB) | Precision: BF16 Forward

In this post, we investigate the inference bottlenecks of MiniMax H3 Ref2VA on PPU-ZW810E accelerators, tracing performance disparities from low-level hardware ISA and Triton kernel scheduling up to end-to-end 50-step video generation. While high-level PyTorch execution remains consistent across machines, subtle differences in external FlashAttention-2 (FA2) builds, register pressure, and memory access patterns introduce up to a 5.10× latency gap in long-sequence attention—which directly translates into a 3.27× end-to-end speedup once resolved.


Executive Summary & Key Takeaways

Before diving into the kernel disassemblies and profiling traces, the table below summarizes our core findings and their practical implications for deployment and kernel engineering:

Key Finding Practical Takeaway for Future Work
1. Environment-Specific FA2 Discrepancies: Identical H3 long-sequence attention exhibits stark backend gaps across two ZW810E nodes. On the original deployment node, external FA2 vs. PyTorch Flash SDPA measures 209.694 ms vs. 41.151 ms, whereas on the Nebula Notebook node it measures 43.342 ms vs. 41.010 ms. PyTorch Flash latency is nearly identical across machines; the variance stems entirely from the external FA2 build. Always benchmark backends using exact target shapes on the target container image and inspect the loaded device binary.
2. Conditional Gains from Direct [D, N] Key Addressing: Addressing KK directly as [D, N] in Triton yields massive gains under high register pressure—dropping latency from 232.95 ms to 103.23 ms at 4 warps—but converges with standard [N, D] + tl.trans at ~60.27 ms under 8 warps and 2 stages. Evaluate KK memory layouts jointly with warp count, pipeline stages, and register pressure. Isolate a single variable per ablation round.
3. Remaining Triton-to-Torch Gap: Our fastest custom Triton kernel reaches 57.11 ms against 41.13 ms for Torch Flash in the same run, leaving a 15.99 ms (28.0%) gap. Audit shared-memory-to-MMA operand loading paths first while maintaining FP32 numerical checks. Static instruction counts alone cannot attribute cycle-level stalls.
4. End-to-End Video Generation Speedup: On an 8-GPU node (50 steps), swapping only the DiT attention backend reduces warm-up-excluded denoise-to-MP4 latency from 606.962 s to 185.796 s (3.27× speedup). Prioritize the empirically faster Torch Flash backend on the deployment node. On the Notebook node, where single-call attention differs by only 2.332 ms, full-video gains should be measured independently.
5. Compilation, Parallelism & Caching Trade-offs: Per-block torch.compile on external FA2 saves only 0.67%. Increasing Tensor Parallelism (TP) substantially reduces peak VRAM, yet TP=1, CP=8 achieves the lowest end-to-end request latency among tested topologies. Favor TP=1, CP=8 when optimizing for latency on current hardware, trading off higher TP only when memory-bound. Isolate AdaLN caching in single-variable ablations.
6. Non-Transferable Backend Rankings Across Shapes: Across 162 dense shapes, Torch Flash wins 100% of cases on the deployment node, whereas external FA2 wins 99 of 162 shapes on the Notebook node. Re-sweep shape matrices whenever migrating images or hardware, recording absolute latencies for both backends rather than relying solely on relative speedups.

1. Same 4 Warps, Different Machine Code: Cross-Node FA2 Latency Divergence

Same-Shape Reproduction Across Two PPU Nodes

To isolate kernel-level behavior, we benchmarked a single-GPU attention forward pass matching H3's exact per-rank tensor geometry under TP=1, Ulysses CP=8: input shape [B, L, H, D] = [1, 33304, 7, 128], BF16, non-causal, dropout=0, preserving H3's interleaved QKV strides (89628672, 2688, 384, 1). Both nodes are equipped with 96 GiB PPU-ZW810E GPUs running PyTorch 2.8.0. Each backend was warmed up for 3 iterations, followed by 7 interleaved device-event measurements (reporting the median). PyTorch was forced onto SDPBackend.FLASH_ATTENTION. (Note: Custom Triton kernels in Sections 2 and 3 use a separate baseline run).

Environment External FA2 Build External FA2 (ms) Torch Flash (ms) FA2 / Torch Per-Call Delta (ms)
Original H3 Deployment Node 2.7.4.post1 209.694 41.151 5.10× +168.543
Nebula Notebook Node 2.7.2 43.342 41.010 1.06× +2.332

While PyTorch Flash differs by just 0.141 ms between the two machines, external FA2 exhibits a 4.84× latency discrepancy. On the Notebook node, FA2 is only 5.7% slower than Torch Flash, with an output relative RMS difference of ≈9.7×10−5\approx 9.7 \times 10^{-5}. Independent profiler traces confirm that both environments launch a 128×64 tile with 4 warps as their primary kernel.

Key Observation on Binary Codegen: Inspecting the loaded flash_attn_2_cuda extension via profiler signatures reveals that the Notebook node's binary (across both ppu001 and ppu0015 targets) emits 16×16×16 FP32-accumulate MMA instructions paired with tsm.ld.swzl swizzled shared-memory loads, with zero v.shuffle.idx.b32 or v.mov.w.msk instructions. Conversely, the deployment node's FA2 binary relies on 8×16×16 MMA and executes heavy register shuffling inside the main K/VK/V loop. Disentangling the exact contributions of upstream FA2 versions, PPU vendor patches, and compiler toolchains will require controlled package swaps within a single environment.

Dissecting the 5.10× Slowdown on the Deployment Node

In production traces (B=1, Q=K=33304, H=7, D=128), both external FA2 and PyTorch Flash launch identical grids of [261, 1, 7] with 128 threads/block (4 warps), 128×64 Q/KQ/K tiles, 254 registers/thread, 64 KiB shared memory, and an estimated 25% occupancy. Yet their disassembled inner loops look fundamentally different:

Loaded PPU Binary Metric (Main K/VK/V Loop) External FA2 (2.7.4.post1) PyTorch Flash SDPA (2.8.0)
Primary BF16-input, FP32-accumulate MMA shape 8×16×16 16×16×16
Static MMA instruction count 256 128
Cross-thread v.shuffle.idx.b32 / masked v.mov.w.msk 640 / 960 0 / 0
Identifiable swizzled shared-memory loads (tsm.ld.swzl) 0 80
Static exp2.f32 instruction count 68 68
Total static instruction slots in loop region 3,776 970
Compiler-reported per-thread local storage (spill) 284 B 28 B

In the external FA2 intermediate representation (IR), every MMA operation is bracketed by explicit accumulator layout conversions (CUDA layout →\rightarrow PPU layout →\rightarrow matrix fragment transpose →\rightarrow CUDA layout). By contrast, PyTorch Flash leverages swizzled shared-memory reads and 16×16×16 MMAs that double the output elements computed per instruction. Because these layout conversions sit inside the inner K/VK/V loop, their overhead scales linearly with sequence length. (Caveat: Static disassembly counts include predicated/conditional paths and cannot be directly converted into dynamic cycle counts or memory bandwidth).

Scaling K/VK/V Sequence Length to Verify Loop Overhead

To verify that the bottleneck scales with K/VK/V iteration count, we held Q=33304,H=7,D=128Q = 33304, H = 7, D = 128 and tensor strides fixed while sweeping K/VK/V token length (3 warm-up runs, 7 interleaved median-timed runs):

K/VK/V Tokens External FA2 (ms) Torch Flash (ms) FA2 / Torch
536 3.567 0.858 4.16×
2,072 13.229 2.772 4.77×
8,216 51.927 10.378 5.00×
16,664 105.035 20.737 5.07×
33,304 209.694 41.151 5.10×

Adding the final 16,640 K/VK/V tokens increases external FA2 latency by 104.66 ms versus 20.41 ms for Torch Flash—a 5.13× marginal cost ratio. Independent checks also show Torch Efficient Attention at 92.952 ms, and making QKV contiguous (including copy overhead) leaves FA2 virtually unchanged at 210.361 ms.

How Warp Count Is Selected

In upstream FA2, num_warps is a compile-time C++ template parameter rather than a Python runtime argument; for D=128 without dropout in v2.7.4.post1, the dispatcher defaults to 4 warps (kernel_traits.h, flash_fwd_launch_template.h). Similarly, PyTorch 2.8 dispatches precompiled kernels statically based on dtype, head dimension, causality, and split-KV heuristics rather than auto-tuning warp counts at runtime (flash_api.cpp). Always verify actual kernel selection via device traces.


2. Custom Triton Kernels: Key Addressing, Register Pressure & Pipelining

To explore whether we could match or surpass PyTorch Flash directly in Triton (triton 3.1.0+ppu1.7.0), we implemented custom forward kernels matching H3's exact shape and strides with pre-allocated outputs, interleaved against Torch Flash. All variants below fix BLOCK_M = 128 and BLOCK_N = 64. We compared two KK-loading strategies that read the exact same global memory addresses without materializing a transposed KK tensor in HBM: loading a logical [N, D] tile followed by tl.trans, versus constructing a logical [D, N] pointer grid directly.

KK Addressing Strategy Warps Stages K/VK/V Bounds Check Local Stack (B) Vector Regs Triton (ms)
[N, D] + tl.trans 4 1 Every block 1,132 256 232.95
Direct [D, N] indexing 4 1 Every block 768 256 103.23
[N, D] + tl.trans 8 1 Every block 0 238 67.08
[N, D] + tl.trans 8 2 Every block 0 248 60.27
Direct [D, N] indexing 8 2 Every block 0 248 60.27
[N, D] + tl.trans (tail-split codebase) 8 2 Every block 0 248 60.84
Same tail-split codebase 8 2 Last block only 0 250 57.11

3. Bridging the Final 15.99 ms Gap: Triton vs. Torch Flash

In the same benchmark session, Torch Flash runs in 41.1285 ms versus 57.1146 ms for our fastest Triton kernel—a 1.39× advantage requiring Triton to shed another 28.0% of its runtime to reach parity. At this point, Triton already emits 16×16×16 BF16 MMAs, incurs zero local stack spilling, and avoids the cross-thread shuffles seen in external FA2. Explaining the remaining 15.99 ms requires looking deeper into shared memory layouts:

Open Question Discriminating Experiment Evaluation Criteria
Do KK and VV enter MMA in optimal layouts? Fix 128×64 / 8 warps / 2 stages / tail-split, and separately perturb shared-memory loads and register layouts for K→QK⊤K \rightarrow QK^\top and V→PVV \rightarrow PV (one change at a time). Torch Flash exhibits 80 swizzled shared-memory loads in its inner loop versus 0 in our fastest Triton binary. Compare inner-loop ISA, latency, and FP32 error before and after layout changes.
Do block pointers (tl.make_block_ptr) help directly? Compare against existing runs under identical tile and pipeline settings. With tail-splitting enabled, standard tl.trans achieves 57.11 ms vs. 58.24 ms for transposed block pointers—indicating pointer abstraction alone is insufficient.
Do these optimizations transfer to NVIDIA H20? Compile both KK-addressing variants on H20 with identical dtype, shape, stride, tile, warps, and stages against H20's Torch Flash. On PPU, the same KK-addressing rewrite shifted from a 2.26× gain to ~1.00× depending on warp count; transferability cannot be assumed without measurement.

(Note: Because static counts of 80 vs. 0 swizzled loads come from distinct compiler pipelines without dynamic bank-conflict or cycle counters, verifying how much of the 15.99 ms stems from shared-memory bank conflicts requires inspecting final machine loads rather than relying on Triton IR layout annotations).


4. End-to-End Impact on 50-Step Video Generation

To evaluate how kernel-level speedups translate to full-model inference, we benchmarked end-to-end generation on an 8×96 GiB PPU-ZW810E node (ppu170_py310_cu126_torch280_v1.1 image).

Experimental Setup

DiT Attention / Execution Mode Denoise (s) Decode & MP4 (s) Denoise-to-MP4 (s) Speedup vs. FA2 Eager
External FA2 / Eager 603.407 3.551 606.962 1.00×
External FA2 / Per-Block Compile 599.548 3.332 602.884 1.007×
Torch Flash / Eager 182.212 3.581 185.796 3.27×

In Rank 0 Step-6 traces, each denoising step invokes primary attention 50 times, with median kernel latency dropping from 209.577 ms to 40.968 ms. Across 50 steps, the theoretical savings of (209.577−40.968)×50×50/1000=421.52 s(209.577 - 40.968) \times 50 \times 50 / 1000 = \mathbf{421.52\text{ s}} closely matches the measured 421.166 s reduction. Both outputs pass full audio-video decoding with an inter-backend SSIM of 0.9501 and PSNR of 26.77 dB at the same seed.

Per-Step Operator Breakdown (Step 8, 8-Rank Mean)

To avoid trace-export artifacts observed in Steps 6–7, we extracted per-operator event means from Step 8 of a dedicated profiling run:

Per-Step Stage External FA2 Eager External FA2 Per-Block Compile Torch Flash Eager
Total Step Time 12,071.6 ms 11,995.0 ms 3,645.1 ms
Attention 10,465.0 ms (86.69%) 10,466.2 ms (87.26%) 2,052.1 ms (56.30%)
MLP GEMM 725.7 ms (6.01%) 725.4 ms (6.05%) 725.6 ms (19.91%)
QKV GEMM 358.8 ms (2.97%) 359.0 ms (2.99%) 358.8 ms (9.84%)
Ulysses All-to-All 162.7 ms (1.35%) 161.1 ms (1.34%) 149.9 ms (4.11%)

Even after a 5× attention speedup, attention still accounts for 56.30% of total step latency, while MLP and QKV GEMMs together represent 29.75% (~1,084 ms/step, virtually unchanged across backends). Future SGLang optimization efforts should target both attention and dense GEMM throughput. (Note: Earlier informal observations of ~255.4 s in match mode came from mismatched hardware/timing boundaries and are excluded from direct delta calculations).


5. Evaluating Compilation, Parallelism Topology & Caching Separately

Topology (TP / CP) Full Request (s) Denoise Loop (s) Cold Start (s, Separate) Rank 0 Peak Allocated / Reserved (GiB)
1 / 8 629.20 586 130.67 78.66 / 79.46
2 / 4 631.30 596 96.60 47.98 / 48.66
4 / 2 635.29 599 95.62 31.77 / 32.02

In the TP=2 and TP=4 runs, TP all-reduce uses PyTorch PCCL while Ulysses IPC either falls back to standard collectives or is explicitly disabled. Standalone micro-probes show that driver-allocated and non-expandable PyTorch allocations succeed on stream write/wait, whereas expandable allocations return error 1 on write and IPC sync JIT compilation fails due to a missing sailify dependency—indicating that the full IPC fast path remains unverified.


6. Shape Sweep Across 162 Dense Configurations: Why Relative Speedups Mislead

To map backend behavior beyond H3's exact geometry, we swept 162 dense configurations (batch=1, BF16, non-causal, interleaved QKV) spanning 9 sequence lengths, 3 head counts (16, 24, 32), and 6 head dimensions (48, 64, 80, 96, 112, 128). Each shape used identical inputs, 3 warm-up runs, and 7 interleaved timed blocks, passing FP32 reference checks on both nodes.

Deployment Node Dense Sweep (Torch Flash Wins 162 / 162)

On the original deployment node, Torch Flash outperforms external FA2 across every tested shape by 1.23× to 5.15× (with both extremes occurring at H=16, D=128 for L=256 and L=33344, respectively):

Sequence Length (LL) H=16, D=48: Torch / FA2 (ms) H=32, D=128: Torch / FA2 (ms) Median FA2 / Torch (18 Shapes)
256 0.014 / 0.030 0.024 / 0.067 2.11×
512 0.022 / 0.058 0.071 / 0.265 3.02×
1,024 0.089 / 0.214 0.234 / 1.056 2.92×
2,048 0.275 / 0.786 0.795 / 3.729 3.13×
4,096 0.935 / 2.776 2.919 / 13.957 3.11×
8,192 3.460 / 10.451 11.292 / 55.840 3.14×
16,384 13.604 / 41.132 44.106 / 221.292 3.13×
32,768 54.228 / 163.187 174.863 / 883.769 3.15×
33,344 56.216 / 168.857 185.820 / 951.494 3.02×

Notebook Node Dense Sweep (External FA2 Wins 99 / 162)

On the Nebula Notebook node, external FA2 wins 99 of 162 shapes, with a median FA2 / Torch latency ratio of 0.974 (range 0.838–2.172). Across the 36 long-sequence shapes (L = 32768, 33344), Torch Flash latencies remain within <1% across both machines, whereas Notebook FA2 is 2.84× to 4.84× faster than deployment-node FA2—winning all 24 configurations with D ∈ {48, 64, 80, 96} and losing all 12 configurations with D ∈ {112, 128}:

Head Dim (DD, at L=33344,H=32L=33344, H=32) Deploy Torch (ms) Notebook Torch (ms) Deploy FA2 (ms) Notebook FA2 (ms)
48 112.008 111.949 337.589 105.330
80 156.402 156.736 467.207 131.361
128 185.820 185.976 951.494 196.730

Packed Variable-Length (varlen) Control

Finally, we benchmarked packed variable-length attention on the deployment node (comparing private torch.ops.aten._flash_attention_forward.default against flash_attn_varlen_func across two mutually masked segments; 1 warm-up, 3 timed runs):

Segment Lengths Heads × DD Torch Packed (ms) External FA2 Packed (ms) FA2 / Torch
256 + 128 16 × 48 0.0141 0.0320 2.28×
256 + 128 32 × 128 0.0334 0.0987 2.95×
33,344 + 16,672 16 × 48 72.118 215.047 2.98×
33,344 + 16,672 32 × 128 232.893 1,192.999 5.12×

A separate question is whether packing a short conditioning segment with a long sequence saves time over two separate calls within the same backend. Informal conversation measurements on Torch Flash for H3's [33304, 40] split show ~41.35 ms (packed) vs. ~41.16 ms (two separate calls), whereas packing two short sequences yields ~0.0297 ms vs. ~0.0814 ms. When a long sequence dominates compute, fusing a tiny auxiliary segment yields negligible savings.