---
title: 'Porting and Tuning FastH3 on TPU v6e: a 148 GB Video Model at 1.55x the Performance per Dollar of 4x B200'
author: Forrest Xi
date: '2026-10-28'
url: https://blog.maxwell-x.dev/en/fasth3-on-tpu-v6e/
lang: en
tags:
- TPU
- v6e
- FastVideo
- Video Generation
- Performance Tuning
- B200
---

# Porting and Tuning FastH3 on TPU v6e: a 148 GB Video Model at 1.55x the Performance per Dollar of 4x B200

> FastH3 is FastVideo's few-step audio-video model distilled from MiniMax H3. Its weights total about 148 GB, while a TPU v6e chip has 32 GB of HBM. We first got it running on 4 v6e chips (72.4 s per 5-second clip), then moved to 8 chips and brought it down to 18.9 s. At GCP DWS Calendar prices that is 1.55x the performance per dollar of FastVideo's fastest official 4x B200 setup. This is our first post on optimizing the MiniMax H3 family on TPU; the second half covers how the same approach carried over to 15-second clips and a resident service, and where we go next.

::: tldr
**TL;DR**

- **5-second clips**: audio-video generation at 1344×768, 124 frames (about 5 s), 8 steps takes 18.9 s end to end on 8 TPU v6e chips. At DWS Calendar prices that is 1.55x the performance per dollar of 4 B200 GPUs running FastVideo's fastest official configuration (9.843 s).
- **Fitting it in**: one copy of the DiT is 70 GB and does not fit on a v6e chip, so the DiT, the text encoder and the VAE all have to be sharded. The hard part was not total capacity but the fact that a TPU needs a contiguous block of HBM to load a program. It ran reliably only after every FSDP all-gather program was kept under a few hundred MB.
- **4 chips hit a ceiling**: tuning 5-second clips on 4 v6e chips went from 72.4 s to 52.0 s (1.13x per dollar). Adding up the paper upper bounds of the candidates we had at the time still did not reach 1.5x, so we moved to 8 chips.
- **8-chip tuning**: 5-second clips went from 31.5 s to 18.9 s. The biggest items were keeping the whole text encoder resident, keeping the whole VAE resident and compiling the full decoder, fixing thread contention on 180 vCPUs, replacing the row max in the block-sparse attention kernel with a fixed bound, and splitting FSDP units by the model's real module names.
- **15-second clips**: with the 4-step checkpoint on the same 8 v6e chips, 41.2 s came down to 25.8 s, mostly from moving the VAE out of HBM during denoising, selecting a fixed 64 blocks per row (lossy), and four changes to decoding (two byte-identical, two near-lossless).
- **Resident service**: 4 requests arriving at once at one resident process exposed 3 problems that single-prompt tests never show; after fixing them, for prompts in the 128 bucket whose text fits in one tile, the first request at a new length went from 110–125 s to 25.7–27.0 s.
- **Next**: most of the remaining time is in denoising, so the next work is structural changes there (compilation granularity, attention implementation), plus streaming encoding at the end of decoding.
:::

## Background

### The model

[MiniMax H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) is MiniMax's joint audio-video generation model; it produces video with stereo sound in one pass. [FastH3](https://haoailab.com/blogs/fasth3-preview/) is a few-step version distilled from it by the FastVideo team. This post uses two checkpoints:

- [FastVideo-FastH3-8-Step-V2](https://huggingface.co/FastVideo/FastVideo-FastH3-8-Step-V2): 8 DiT forwards, used for 5-second clips (Steps 1–3 below).
- [FastVideo-Minimax-FastH3-Preview-v0.2](https://huggingface.co/FastVideo/FastVideo-Minimax-FastH3-Preview-v0.2): 4 DiT forwards, used in the 15-second and resident-service sections.

The size and structure of four components drive the deployment:

| Component | Weights | Structure |
|---|---:|---|
| DiT | 70.1 GB | 50 layers, hidden 5376, 56 attention heads; VSA-H3 block-sparse attention (64-token tiles, about 80% sparse in the 8-step checkpoint) |
| Text encoder | 66.7 GB | Full Qwen3-VL-32B weights, hidden states taken from layer 50 |
| Video VAE | 10.4 GB | Decodes by spatial tiles |
| Audio VAE | 0.6 GB | |

That is about 148 GB in total. A 5-second clip is 42,752 tokens in the DiT; a 15-second clip is about 109,000.

### Hardware and pricing

A TPU v6e (Trillium) chip has a bf16 peak of 918 TFLOPs, 32 GB of HBM (about 33.5 GB allocatable at runtime), 1638 GB/s of HBM bandwidth and one TensorCore. We used `ct6e-standard-8t`: 8 chips per machine, 2x4 topology, 180 vCPUs.

Both sides are priced at GCP DWS Calendar rates (read from the official pricing pages on 2026-10-05): B200 at $11.2775 per GPU-hour (`a4-highgpu-8g` at $90.22 ÷ 8) and v6e at $1.89 per chip-hour, a ratio of 5.967. Performance per dollar counts the accelerators actually occupied:

```text
perf per dollar (vs B200) = B200 time × B200 GPUs × 11.2775 ÷ (TPU time × TPU chips × 1.89)
```

The B200 side is 4 GPUs running FastVideo's fastest official configuration, which we measured at 9.843 s (3 prompts × 3 runs). On that basis the break-even point for 8 v6e chips is 29.37 s, and the 1.5x target is 19.57 s. This baseline is the latency-optimal 4-GPU setup; B200 may do better per dollar with fewer GPUs, which we did not measure for 5-second clips, so the ratios in this post hold only against 4x B200.

### Measurement and accuracy

- **Timing**: one process per prompt, one untimed warm-up, then 3 timed runs; 3 prompts give 9 samples, and we report the mean. The clock runs from request entry to the MP4 being written, covering text encoding, denoising, video and audio decoding, and saving.
- **Accuracy gate**: video generation has no GSM8K-style accuracy score. We generated a full-fp32 reference on B200 and compare 12 intermediate tensors (the step-0 velocities, the final latents and so on). For each tensor, the TPU's relative L2 error against the reference, divided by the error of B200's official configuration against the same reference, must be ≤ 1.5. In other words, the TPU error may be at most 1.5x B200's own error. The gate only covers the DiT; for changes to VAE decoding we also compare the PSNR of decoded frames and watch the output.
- **Software**: torch 2.13.0 (CPU build) + torch_tpu 0.1.1.dev20260912 + FastVideo, deployed on GKE.

## Results for 5-second clips

<figure>
  <div class="chart" role="img" aria-label="End-to-end time for a 5-second clip: 72.4, 52.0, 31.5, 18.9 s">
    <div class="row"><div class="lab">4 chips · running<small>0.81x per $</small></div><div class="track"><span class="fill base" style="width:calc((100% - 5.5em) * 1.0000)"></span><span class="val">72.4</span></div></div>
    <div class="row"><div class="lab">4 chips · tuned<small>1.13x per $</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.7189)"></span><span class="val">52.0</span></div></div>
    <div class="row"><div class="lab">8 chips · start<small>0.93x per $</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.4353)"></span><span class="val">31.5</span></div></div>
    <div class="row"><div class="lab">8 chips · tuned<small>1.55x per $</small></div><div class="track"><span class="fill" style="width:calc((100% - 5.5em) * 0.2613)"></span><span class="val">18.9</span></div></div>
  </div>
  <figcaption>End-to-end time (seconds) at 1344×768 / 124 frames / 8 steps, n=9 per row. Per-dollar ratios are priced by chips actually occupied, against 9.843 s on 4 B200 GPUs. The two 4-chip rows were measured using 4 chips of an 8-chip machine and priced as 4 chips. "8 chips · start" is the tuned 4-chip configuration run with 8 processes.</figcaption>
</figure>

| Stage | 4 chips tuned | 8 chips tuned |
|---|---:|---:|
| Text encoding | 3.16 s | 0.24 s |
| Denoising (8 steps) | 33.57 s | 14.99 s |
| Video decoding | 13.54 s | 2.83 s |
| End to end | 52.01 s | 18.91 s |

The final configuration passes the accuracy gate: all 12 items in 3 rounds, maximum ratio 1.119, identical across rounds. Two caveats: decoded frames were compared only against the previous TPU configuration (PSNR ≥ 68 dB), not frame by frame against B200 or the fp32 reference, and image quality was judged by watching the output. All numbers come from a single node.

## Step 1: fitting 148 GB into 32 GB chips

### Problem

On v5p (95 GB per chip), FastVideo keeps a full DiT on every chip and shards the text encoder across 4. A v6e chip has 32 GB, so a single DiT copy already overflows it: **the DiT must be sharded no matter how many chips we use**. The arithmetic first:

| Layout (4 v6e chips) | Resident per chip | Verdict |
|---|---:|---|
| DiT sharded 4 ways + text encoder sharded and resident + one VAE per chip | 44.6 GB | does not fit |
| DiT sharded 4 ways + text encoder loaded on demand + one VAE per chip | 27.9 GB + activations | might fit |
| Everything sharded and resident on 8 chips | 27.5 GB | fits, at twice the cost |

We started with the second layout: the DiT sharded 4 ways with FSDP and kept resident, the text encoder sharded with FSDP plus CPU offload, streamed onto the chips layer by layer.

### Approach

<b>Build the text encoder on the meta device.</b> Building it on CPU and then calling `fully_shard` with offload made all 4 ranks fail with an incompatible tensor type in `set_data`. Building the model on the meta device and loading shards straight to host memory made CPU offload work.

<b>E0101 is about contiguity, not a leak.</b> After the DiT loaded, the first request kept failing with E0101, "reserve at the bottom of memory". Our first three attempts looked for whatever was holding 15 GB (reshard not freeing memory, large parameter units), and none of them was it. The XLA documentation for this error code explains it: loading a program needs a **contiguous** block of HBM, and with enough fragmentation it fails even when total free memory is sufficient. In one measurement, 15.95 GB was free but only 0.63 GB could be reserved contiguously. The same code also passed on some runs and failed on others, so the memory layout cannot be relied on.

In torch_tpu, each FSDP2 all-gather is itself a program, and its input plus output count toward the program reservation (inferred from matching sizes). The fix was therefore to **keep each all-gather program small**: split FSDP units down to the attention block and each projection, keeping every unit's full parameters around 0.33 GB, and look up the large embedding on the host. After that both requests passed reliably.

### Gain

The model ran on 4 v6e chips at 72.4 s per 5-second clip, passing all 12 items of the accuracy gate (maximum 1.093). Priced as 4 chips, that is 0.81x B200's performance per dollar.

### Where it applies

When running large models on TPUs with tight HBM, first tell E0100 from E0101: E0100 means buffers really do not fit, E0101 means a program load could not find contiguous space. For E0101, make individual programs smaller instead of hunting for whoever is using memory.

## Step 2: 5-second clips at 52 s on 4 chips, then a move to 8

This step and the next are both about 5-second clips (8-step checkpoint). Four main changes went into the 4-chip tuning:

- <b>Cache the AdaLN modulation table by timestep.</b> The DiT's AdaLN projection only takes the timestep embedding as input, and the 8-step distilled model uses the same timesteps for every request, so the output is identical every time. These weights are 26.0 GB, 37% of the DiT. Moving them to host memory and caching the modulation table per timestep frees those 26 GB of HBM and removes their all-gather from every step; a cache hit reuses the same tensor, so results are bit-identical.
- <b>Split FSDP units down to linear layers</b>, so each all-gather program is smaller and starts earlier.
- <b>Compile the DiT and VAE per block</b>, leaving collectives and the Pallas kernel outside the compiled graph (putting them inside either hung or ran slower).
- <b>Keep the first 24 text-encoder layers resident</b> and stream the rest; keep the audio VAE resident.

That took 72.4 s down to 52.0 s (-28%), or 1.13x per dollar, still 1.33x short of the 1.5x target. At this point we stopped and did the arithmetic. With 4 chips, Ulysses can only split 4 ways, and the block-sparse kernel took 26.5 ms per layer (14.3 ms on 4 v5p chips). Adding up the paper upper bounds of the candidates registered at the time gave about 45–47 s (an estimate), short of 39.15 s, so we decided to move to 8 chips instead of running more small experiments on 4. How much of the later 8-chip gains (thread count, single-parameter FSDP gathers, the fixed-bound kernel) would carry back to 4 chips, we did not measure.

On 8 v6e chips the cost doubles and the target becomes 19.57 s. Running the tuned 4-chip configuration with 8 processes gave 31.5 s, 0.93x per dollar; that was the 8-chip starting point.

## Step 3: 5-second clips from 31.5 s to 18.9 s on 8 chips

### Where the time goes

At the starting point one DiT step took 2.36 s (rank 0, 8-way Ulysses). Broken down from the profile:

<figure>
  <div class="chart" role="img" aria-label="Breakdown of a 2363 ms DiT step">
    <div class="stack"><span class="seg c1" style="flex:700" title="Block-sparse attention kernel: 700 ms">700</span><span class="seg c2" style="flex:526" title="Data movement: 526 ms">526</span><span class="seg c3" style="flex:452" title="Collectives and block selection: 452 ms">452</span><span class="seg c4" style="flex:280" title="Linear-layer GEMM: 280 ms">280</span><span class="seg c5" style="flex:405" title="Elementwise, idle and other: 405 ms">405</span></div>
    <div class="legend"><span><i class="c1"></i>Block-sparse kernel 29.6%</span><span><i class="c2"></i>Data movement 22.3%</span><span><i class="c3"></i>Collectives + block selection 19.1%</span><span><i class="c4"></i>GEMM 11.8%</span><span><i class="c5"></i>Elementwise, idle and other 17.1%</span></div>
  </div>
  <figcaption>Device time (ms) of the DiT forward at denoising step 3, 8 v6e chips, starting configuration; the categories sum to about 2363 ms. Data movement covers copy / as_strided / pad and tile reordering; collectives are FSDP all-gather and Ulysses all-to-all; the last segment is 214 ms of elementwise ops, 180 ms idle between programs and 12 ms other.</figcaption>
</figure>

The linear-layer GEMMs were already at 78% of peak, leaving little room. Most of the time went to the block-sparse kernel, data movement and collectives. Outside the DiT, text encoding (3.0 s) and video decoding (6.4 s) were also well over budget.

### Change by change

<figure>
  <div class="chart" role="img" aria-label="End-to-end time after each 8-chip change">
    <div class="row"><div class="lab">Start</div><div class="track"><span class="fill base" style="width:calc((100% - 5.5em) * 1.0000)"></span><span class="val">31.50</span></div></div>
    <div class="row"><div class="lab">Text encoder resident<small>+ VAE kept gathered</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.8539)"></span><span class="val">26.89</span></div></div>
    <div class="row"><div class="lab">ffmpeg / single-thread layout</div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.8247)"></span><span class="val">25.97</span></div></div>
    <div class="row"><div class="lab">Threads + full VAE compile<small>+ RoPE / a2a sync</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.7006)"></span><span class="val">22.07</span></div></div>
    <div class="row"><div class="lab">FSDP gather into param buffer</div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.6821)"></span><span class="val">21.48</span></div></div>
    <div class="row"><div class="lab">Kernel fixed bound<small>+ text encoder TP8</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.6321)"></span><span class="val">19.91</span></div></div>
    <div class="row"><div class="lab">FSDP split by real names</div><div class="track"><span class="fill" style="width:calc((100% - 5.5em) * 0.6003)"></span><span class="val">18.91</span></div></div>
  </div>
  <figcaption>5-second clips (124 frames / 8 steps). Each row is a re-measurement on a fresh pod built exactly from the recipe (n=9, seconds), stacked on the row above. Some items were below the noise threshold on their own and could only be validated bundled with others, hence several items per row.</figcaption>
</figure>

Five of these carry over to other models.

<b>1. When the chip count doubles, re-decide what stays resident.</b> On 4 chips the text encoder shard was about 12.4 GB per chip; keeping it next to the DiT slowed each denoising step by 1.25 s, so it had to be streamed. On 8 chips the shard halves and there is room: the text encoder became fully resident, later 8-way tensor parallel, and text encoding dropped from 3.0 s to 0.24 s. The VAE is similar. On 4 chips it was sharded, and every decode tile re-gathered all 36 blocks; carried over to the 8-chip starting point, that layout measured 1036 all-gathers per decode, 1.29 s in total. On 8 chips we first kept it gathered for the whole decode, then made it fully resident and compiled the entire decoder; video decoding went from 6.4 s to 2.9 s. The cost is about 27 s of extra compilation on the first request, and decoded frames are no longer bit-identical (PSNR 68–70 dB). When changing chip count or chip generation, every component that the old layout offloaded only because HBM was short should be re-evaluated against the new headroom.

<b>2. Thread contention on 180 vCPUs.</b> Each of the 8 worker processes defaulted to 180 intra-op threads, and host-side torch ops fought over cores. The first symptom was a layout function taking 509 ms, versus 1 ms single-threaded (-0.92 s together with an ffmpeg pipe, re-measured from the recipe). Setting `OMP_NUM_THREADS=22` globally (180 ÷ 8, rounded down) then took another spot, row_plan, from 610 ms to 2 ms, and that step saved a further 1.21 s end to end. When several processes share one large machine, this default almost always needs changing.

<b>3. Block-sparse attention kernel: a fixed bound instead of the row max.</b> On v6e each iteration of this Pallas kernel takes about 1 µs; softmax elementwise work is about 37% of it, matmul only about 28%. The most expensive part of the softmax is the row-max reduction over 2048 lanes and the rescaling that follows. Following maxdiffusion, we use the Cauchy–Schwarz inequality to give a fixed upper bound on the logits (‖q‖·max‖k‖) instead of tracking the row max online, switch exp to exp2, and fold the scale into q. Program blocks where the bound is not safe enough fall back to the original path via a flag. Block-sparse attention only computes the selected subset, so maxdiffusion's guarantee that the row max is ≥ 0 does not hold here; the check is per program block rather than per head. A single layer got 23% faster, and together with text-encoder tensor parallelism the gain was -1.57 s. The change only alters rounding, and the accuracy gate still passes.

<b>4. Partial RoPE as a signed permutation matmul.</b> H3's RoPE rotates 96 of the 128 channels, and the cut point is not aligned to the 128-lane width. The slicing version became about 16 small ops on TPU, each reading and writing q / k once. Multiplying by a signed permutation matrix, with cos / sin padded with 1 and 0 for the unrotated channels, gives bit-identical results for bf16 inputs, and the RoPE program went from 131.6 ms to 86.7 ms per step. It is not bit-identical for f32 inputs: the same trick applied to the f32 VAE gave frames at 67.86 dB PSNR.

<b>5. Write FSDP split rules against the model's real module names.</b> Each FSDP2 unshard does two copies: shards into a flat buffer, and after the all-gather, back out into the individual parameters. If a unit holds only one parameter, the flat input is the shard itself and the flat output is the full parameter, so both copies can be skipped with bit-identical results (-0.55 s). But our first split rules followed diffusers naming (`to_out.0` / `net.0.proj` / `net.2`), while the H3 DiT calls them `attn.to_out` / `ff.fc_in` / `ff.fc_out`. The three largest matrices were never split out, and **a name mismatch raises no error**. Fixing it saved another 0.98 s, of which about 0.2–0.5 s exceeds what the skipped copies can account for; that part has not been broken down (presumably related to all-gather granularity). After enabling any optimization that only applies to single-parameter units, count the modules that actually became single-parameter units.

### What is left

In the final 5-second configuration a DiT step takes 1.84 s. A serial floor from compute plus ICI traffic is about 0.48 s (in this stack, all-gather and matmul inside the same graph were measured not to overlap), so 3.8x remains. Video decoding takes 2.83 s against a floor of about 0.84 s. After the fixed-bound change we also tried a two-pass variant and register tiling for the block-sparse kernel; neither beat the noise threshold.

## 15-second clips: from 41.2 s to 25.8 s

Steps 1–3 were all about 5-second clips. This section moves to 15-second clips (362 frames) on the same 8 v6e chips, timed the same way, from request entry to MP4 written. Real-time 15-second generation already exists on GPUs: vLLM-Omni, for example, reports about 14.1 s client-side end to end on 8 B300 GPUs with 4 dense-attention steps (self-reported by the authors; hardware, step count and timing boundary all differ from ours). Real time is the long-term direction for this line of work too.

### 8 steps would not get there, so 4 steps

Running 15-second clips with the 5-second recipe took 76.6 s with the 8-step checkpoint. Extrapolating from compute, the lossless floor for 8 steps is about 12 s, and getting close to real time would need the whole pipeline above 80% of peak; that is not realistic. So we switched to the 4-step Preview-v0.2 checkpoint. Side-by-side clips showed the 8-step model clearly better in sharpness, detail and storytelling; the 4-step gap was expected, and we went after speed first.

### Changes and result

<figure>
  <div class="chart" role="img" aria-label="End-to-end time for 4-step 15-second clips">
    <div class="row"><div class="lab">4 steps + 5 s recipe</div><div class="track"><span class="fill base" style="width:calc((100% - 5.5em) * 1.0000)"></span><span class="val">41.17</span></div></div>
    <div class="row"><div class="lab">VAE out of HBM while denoising</div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.8778)"></span><span class="val">36.14</span></div></div>
    <div class="row"><div class="lab">Fixed 64 blocks per row<small>lossy</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.7741)"></span><span class="val">31.87</span></div></div>
    <div class="row"><div class="lab">Output rank writes MP4<small>+ three small DiT changes</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.7385)"></span><span class="val">30.40</span></div></div>
    <div class="row"><div class="lab">uint8 on device<small>+ last-round tile balance</small></div><div class="track"><span class="fill alt" style="width:calc((100% - 5.5em) * 0.6909)"></span><span class="val">28.45</span></div></div>
    <div class="row"><div class="lab">Whole decoder compiled<small>+ VAE RoPE matmul</small></div><div class="track"><span class="fill" style="width:calc((100% - 5.5em) * 0.6202)"></span><span class="val">25.53</span></div></div>
  </div>
  <figcaption>End-to-end time (seconds) at 1344×768 / 362 frames / 4 steps, development pod, n=9. Re-measured on a fresh pod built exactly from the final recipe: 25.77 s (slowest 26.21 s).</figcaption>
</figure>

Two of these deserve a closer look:

<b>Under HBM pressure the runtime evicts loaded programs.</b> Activations and attention tables are much larger for a 15-second clip. During denoising only about 10 GB of HBM was left, so every layer the runtime evicted and reloaded attention programs and defragmented memory, adding a 917 ms gap per step. Moving the video VAE back to the host during denoising freed about 9 GB, and the gap dropped to 0.1 ms. In a profile this overhead shows up as blank space between programs and looks like synchronization waits.

<b>Four changes in the second half of decoding.</b> Frames are quantized to uint8 on the TPU before the transfer to host (4.48 → 1.12 GB, -1.11 s); the last round of tiles is split evenly across the 8 chips (-1.14 s); the full decoder is gathered and compiled as one graph at the start of decoding (-1.96 s); the VAE RoPE becomes a matmul (-0.98 s). The first two leave the MP4 byte-identical; the last two are near-lossless, with frames at about 67.7 dB PSNR.

### Options we tried but did not adopt

The first two rows were measured on the configuration that used the taeh3 decoder at the time, not on the same baseline as the final 25.77 s above.

| Option | End to end | Verdict |
|---|---:|---|
| Lightweight VAE decoder taeh3 | 20.65 s | Frames at only 29.68 dB vs the full VAE; rejected after watching |
| Blocks selected per row cut from 64 to 32 | 19.52 s | A further -1.1 s on the taeh3 configuration, clearly worse image; rejected |
| int8 / fp8 weights and activations | — | int8 matmul 0.97–0.98x on v6e, no speedup from fp8 |
| int8 all-to-all | — | Inbound communication time down only 24%, below the preset 25% bar |

The final recipe runs at 25.77 s, 37% less time than the starting point. Denoising takes about 17.7 s of that and is the largest remaining piece. Small item-by-item changes to denoising had stopped paying off, so the next step is structural (a different attention implementation, a different compilation granularity).

## A resident service: 4 requests at once

This section is still 15-second clips with the 4-step checkpoint, now in a serving scenario: 4 different prompts arrive at the same time at one resident process. Keeping the model in a resident process and feeding it varied prompts exposed three problems that single-prompt tests never show:

- <b>Unreachable Python garbage holding device buffers.</b> By the third distinct prompt in one process, about 4.1 GB of extra memory was held after denoising, and video decoding then ran out of memory. With one `gc.collect()` per request, the scenarios that had reproduced the OOM no longer hit it; calling `gc.freeze()` first cut each collection from 530–785 ms to 18–45 ms. One resident process with gc still showed the same +4.6 GB once (not reproduced since, mechanism not found), and rank 0 has only about 0.1–0.3 GB of HBM headroom during decoding, so this needs watching.
- <b>A recompile limit that silently drops the DiT to eager.</b> FastVideo's LoRA layer sets dynamo's `recompile_limit` to 16, and each new sequence length triggers 4 recompiles. From the fifth length on, the DiT stops compiling and runs eagerly, and **its output differs visibly from the compiled path** (PSNR 17–19 dB) with no error raised. Raising the limit to 1024 fixed it.
- <b>About 90 extra seconds on the first request of a new length.</b> We first blamed DiT recompilation; per-step timing showed it was VSA-H3's tile-geometry metadata, computed on the TPU as a chain of small eager ops that compile once per shape. Computing it on the host cut that step from 91.8 s to 6–9 ms. Combined with padding text to four buckets (128 / 256 / 512 / 1024) so that prompts with the same number of text tiles within a bucket share one DiT compilation (4 buckets, 4 packed lengths), the first request at a new length went from 110–125 s to 25.7–27.0 s. That figure was measured only for prompts in the 128 bucket whose text fits in one tile; when the number of text tiles changes within a bucket, the first request is still about 1.26x the steady state (one measurement), and the first request to enter any other bucket is 1.4–2.7x, for reasons not yet found.

After these fixes (this configuration adds a few more changes on top of the 15-second section), the 4-way burst, 3 rounds of 4 requests, gave a P95 of 97.6 s, 24.2–24.6 s per request and 2.47 clips per minute. With one model copy processing 4 requests serially, P95 is essentially 4 times the single-request time, so lowering P95 mostly means lowering single-request time. Splitting into two 4-chip replicas does not help either: we measured roughly equal chip-seconds per request on 4 and 8 chips (about 206–211 for 4 steps), and v6e has no 6-chip machine type.

## Takeaways

| Lesson | Where it applies |
|---|---|
| E0101 means a program load needs contiguous HBM; keep each all-gather program to a few hundred MB | FSDP on TPUs with tight HBM |
| An AdaLN projection that depends only on the timestep can live on host and be cached | Few-step distilled DiTs |
| After doubling chip count, re-decide resident vs offloaded for each component | Any move to a new chip count or generation |
| Set `OMP_NUM_THREADS` explicitly when processes share a large machine | Multi-rank inference with host-side torch ops |
| Replace the row max with a fixed bound in block-sparse attention, falling back per program block | TPU kernels where softmax elementwise work dominates |
| Gather FSDP single-parameter units straight into the parameter buffer; write split rules by real module names and count the result | torch FSDP2 inference |
| In a resident process, check gc, dynamo's recompile limit and small ops compiled per shape | Turning an offline script into a resident service |

Next directions: a 5-second DiT step is still about 3.8x from its serial floor; denoising for 15-second clips needs structural changes; and resident-service P95 follows single-request time. The whole effort followed the [Curvature Drive](https://rsi.maxwell-x.dev) workflow: turn the target into an absolute number, account for time from profiles, judge each path by its upper bound, and re-measure every adopted change on a fresh pod built exactly from the recipe. The decision to move from 4 chips to 8 also came from an upper-bound estimate of this kind.
