AI Infra · TPU v7
Hy4 Weight Loading on TPU v7: From 857 Seconds to 68
The official Hy4-preview weights are 757.88 GiB. Deployed across two TPU v7 hosts, loading straight from the original checkpoint took 857 seconds. We analyzed why it was slow: every rank reads the full checkpoint, vLLM skips prefetch for large models, and with multiple hosts prefetch covers only half the files. After switching to a per-rank pre-sharded weight cache and closing two gaps in the upstream loader, load time dropped to 68.5 seconds. This post covers the analysis, the approach and the gains, as well as where this kind of cache fits and what it costs.
TL;DR
- Problem: The Hy4-preview checkpoint is 757.88 GiB. In a deployment with two hosts and 16 ranks, the default loading path has every rank read the full checkpoint, and vLLM's prefetch for network file systems has a memory threshold that large models easily miss. On the same software stack, one load straight from the original checkpoint took 857 seconds.
- Approach: Write the weights to disk after quantization conversion, already split per rank, so that each rank reads only its own ~47 GiB (vLLM's
sharded_stateformat). Add prefetch to the upstream ShardedStateLoader and fix 8 read-back issues it has on MXFP8-quantized models. - Gains: Load time dropped from 857 seconds to 68.5 seconds, about 12.5×, and later measurements ranged over 65–71 seconds. Accuracy evaluations with the cache were normal.
- When to use it: multi-host tensor parallelism, checkpoints close to or larger than a single host's memory, and deployments that restart often. The cost is that the cache is tied to the parallel configuration and the code version, and has to be rebuilt when the configuration changes.
Background#
Hy4-preview is an MoE model released by Tencent Hunyuan, with 770B total parameters. The official checkpoint is quantized with modelopt MXFP8 and consists of 130 shards totaling 757.88 GiB.
Our deployment on TPU v7 is two tpu7x-standard-4t hosts, 8 chips and 16 devices in total, running TP16 plus expert parallelism. Each device maps to one rank, so each host runs 8 ranks. The weights sit on Google Cloud Managed Lustre, and both hosts read them from there.
The service loads its weights on every start, and version switches, configuration changes and failure recovery all trigger one. During tuning we restarted several times a day, so load time directly limits iteration speed. On the vLLM 0.29 stack, one load straight from the original checkpoint took 857 seconds (this measurement did not record whether prefetch was enabled).
All load times in this post are the Loading weights took value from the vLLM log, taken from the slowest rank. It covers only model.load_weights itself, not the post-processing that follows.
Problem analysis: where the time goes#
Every rank reads the full checkpoint#
vLLM's default loading path has every rank read the full checkpoint and then cut out its own slice online according to tensor parallelism. Hy4 has 16 ranks, each reading 757.88 GiB, for a combined logical read of about 11.8 TiB across the 16 ranks. Ranks on the same host can share the OS page cache, so the actual physical reads are somewhat lower, but each host still has to read the full 757.88 GiB into memory.
Prefetch has a memory threshold#
On network file systems such as Lustre and NFS, vLLM pre-reads the checkpoint files into the page cache before loading (prefetch), turning many small random reads into large sequential ones. This step is gated by a condition:
fits_in_ram = total_bytes <= 0.9 * avail
# avail = min(host_available, cgroup_limit - cgroup_usage)
When the condition fails, vLLM prints a Skipping auto-prefetch line and falls back to on-demand reads (mmap page faults). Two points are easy to miss here. The numerator is the size of the whole checkpoint and is not divided by the number of ranks. The denominator is the available memory as seen by the container (cgroup), which is bounded by the pod's memory limit rather than the node's physical memory.
The Hy4 checkpoint sits right around this line, and we ran into it twice:
- The pod memory limit was initially set to 400Gi, leaving only 382.78 GiB available, and prefetch was skipped. The loading progress bar showed 25.97 seconds per shard, which projects to about 56 minutes for the full load. After we raised the memory limit to 880Gi, available memory was 862.90 GiB, prefetch turned on, and each shard dropped to 4.84 seconds (the two rates were taken at different points in the load).
- Another time, available memory was only 781.44 GiB, giving a threshold of 703 GiB, which is below the checkpoint size. Prefetch was skipped again, and loading took 913–1018 seconds. In the same hour, on the same Lustre, GLM-5.3 Flash (305.79 GiB, within the threshold, single-host deployment) loaded in only 52 seconds. The two differ in both model and deployment, so the gap does not come entirely from the threshold, but it shows how much prefetch affects load speed.
Passing the threshold needs at least 842 GiB of available memory, while the available memory we measured fluctuated within 781–869 GiB. Raising the pod memory limit alone therefore cannot guarantee that prefetch takes effect reliably.
With multiple hosts, prefetch covers only half the files#
Even with prefetch on, vLLM assigns the files to prefetch by global rank (sorted_files[rank::world_size]). Hy4's 16 ranks span two hosts, so the 8 ranks on each host prefetch only half the files. The other half goes into the peer host's page cache, which does nothing for the local host. With prefetch on, the default loader still took 497 seconds (host A) and 634 seconds (host B).
Quantization conversion is not the bottleneck#
We first assumed the slowness came from dequantizing and requantizing the MXFP8 weights after loading. Measurements ruled this out: the quantization conversion log and Loading weights took finished within the same second, and the conversion itself takes only 2–3 seconds. Most of the time goes to reading the full checkpoint and slicing it tensor by tensor (we did not measure how the time splits between the two).
Approach: a per-rank pre-sharded weight cache#
Idea#
vLLM supports the sharded_state load format: load the model fully once and write each rank's sliced weights to disk separately; on later starts, each rank reads only its own files. What we write to disk is the state after post-processing: MXFP8 has been converted to the runtime format, MLA's kv_b_proj has been folded into W_UK_T / W_UV, and the quantization scales are already floating point.
| Default loading | Pre-sharded cache | |
|---|---|---|
| Read per rank | 757.88 GiB, sliced online | about 47 GiB |
| Read per host | 757.88 GiB, above the prefetch threshold | about 379 GiB |
| Quantization conversion | Done on every start | Done before writing to disk |
The cache for each configuration only has to be built once, and the output totals 757.2 GiB. On vLLM 0.27 the build took about 36 minutes. On vLLM 0.29, offline saving also runs the whole compilation again, so it takes about 45–85 minutes.
Closing two gaps in the upstream loader#
Using the upstream ShardedStateLoader as is runs into two problems.
First, it has no prefetch. The upstream implementation is just safe_open plus get_tensor() and relies entirely on mmap page faults; vLLM's prefetch logic exists only in the default loader. On the first read-back from the cache, each rank's physical read rate was only about 30 MB/s, about 480 MB/s across all 16 ranks. We added a background thread pool (8 threads by default) that reads each rank's own files sequentially in 16 MiB blocks. We deliberately did not reuse vLLM's _prefetch_all_checkpoints, because it splits the files by rank once more, and each rank would end up prefetching only 1/16 of them.
Second, it assumes that saving and loading see the same set of tensors. On load, upstream does only param.copy_(tensor). But the cache holds the post-processed model, while model initialization (create_weights) allocates the checkpoint layout, and the two disagree in four respects: key set, shapes and dtypes, quantization state, and device. We fixed 8 places in total, mainly:
kv_b_proj, which MLA folds away, does not exist in the cache, so a missing key is now downgraded to a warning;- MXFP8 weights that are already in the runtime format skip repeated quantization;
- after a parameter is renamed, the old attribute is cleaned up by setting it to None rather than deleting it, so the alias of the shared expert is not removed by mistake;
- newly created parameters are placed on the model's device instead of being left on the CPU;
- the step in which MLA rebuilds
W_UK_T / W_UVfromkv_b_projis skipped.
Of these, 3 are design gaps in upstream: any quantization scheme that changes the structure of the state_dict during post-processing will run into them.
Two side issues#
- MTP draft model. The cache holds only the main model's weights. By default the draft model inherits the main model's load format and path, so it looks for the MTP weights in the cache directory and fails. We force the draft model to use the default loading path and point it back at the original checkpoint. Loading the draft model on its own takes 11–15 seconds.
- Compile cache. The vllm-torchtpu compile cache key includes
spec.modelfrom the speculative decoding config, which under MTP defaults to the main model path. So the first time the model path points at the cache directory, it triggers a full recompile (about 25 minutes on vLLM 0.27); after that the cache hits normally.
Gains#
Loading weights took in the vLLM log.On the vLLM 0.29 stack, load time dropped from 857 seconds to 68.5 seconds, about 12.5×, and later measurements ranged over 65–71 seconds.
The measurements from each stage are summarized below:
| Configuration | Software stack | Load time |
|---|---|---|
| Default loading, prefetch skipped by the memory threshold | vLLM 0.27 | 913–1018 s |
| Default loading, prefetch on | vLLM 0.27 | 497 / 634 s (two hosts) |
| Pre-sharded cache + prefetch | vLLM 0.27 | 124.79 s |
| Default loading | vLLM 0.29 | 857 s |
| Pre-sharded cache + prefetch | vLLM 0.29 | 68.5 s |
A few notes:
- The 124.79 seconds on vLLM 0.27 was measured with a fairly warm page cache (the cache had been written just an hour earlier), and only 2 of the 16 ranks printed a time, so it should be read as an optimistic figure; the real time may be longer. The vLLM 0.29 measurement did not record the page cache state. A cold start with the page cache cleared was not measured.
- On vLLM 0.27, single-stream inference throughput did not change after switching to the cache (111.99 vs 112.29 tok/s, within the ±5% noise range). On vLLM 0.29, accuracy evaluations with the cache gave a three-round GSM8K average of 94.89 and MMLU 90.40, both above the release bar.
- The 857-second measurement did not record whether prefetch was enabled, so the baseline behind the 12.5× figure is not fully certain.
Addendum: Lustre striping#
Managed Lustre throughput is purchased as capacity × throughput per TiB. This is a guaranteed floor, and measured throughput can exceed it by about 22%. Stripes are allocated when a file is created, and expanding capacity does not redistribute existing files: after we expanded Lustre from 8 OSTs to 16, all 1742 of Hy4's objects still sat on the original 8 OSTs.
To let existing files use the new OSTs, you have to redistribute them with lfs migrate, and you must pass the full PFL layout template: running it without arguments has no effect on existing PFL files, while specifying only -c 16 flattens the PFL layout. In a controlled comparison on DeepSeek-V3.2 (642 GiB, cold cache, 8-way parallel reads from a single client), read speed was 3.00 GiB/s with 8 stripes and 5.63 GiB/s with 16, a 1.88× improvement. Hy4 load time before and after redistribution was not compared separately.
When to use it and what it costs#
When to use it. The pre-sharded cache suits these deployments:
- multi-host tensor parallelism, where each rank needs only a small part of the checkpoint;
- checkpoints close to or larger than a single host's available memory, where the default prefetch is unreliable;
- frequent restarts, for example during tuning, canary switchovers and failure recovery;
- quantization formats that need heavy post-processing after loading, where the post-processed result can be cached along with the weights.
What it costs. The cache moves part of the load-time computation to before deployment, and in return brings a set of invalidation conditions:
- The cache is tied to TP, EP, max-model-len, the KV dtype, the speculative decoding config and the code version. Any change requires a rebuild, and the rebuild occupies all 16 devices. A manifest containing module hashes, environment variables and engine arguments is written alongside the cache, but apart from the layout field described below, it is not yet checked automatically at startup.
- Layout changes can cause silently wrong results. When moving to vLLM 0.29, vllm-torchtpu followed upstream in changing the runtime layout of FP8 linear layers to (k, n). Square matrices have the same shape under the old and new layouts, so an old cache would be treated as already processed and loaded directly. The new loader therefore requires the manifest to declare
runtime_linear_layout == "kn"explicitly, and errors out otherwise. - Forgetting to turn on the cache switch raises no error. Loading just falls back to the original checkpoint and startup takes more than ten minutes longer (over 900 seconds on vLLM 0.27, about 790 seconds on 0.29). We therefore made it the default in the deployment script.
Series#
Overview: Beating B200 from Scratch: Porting and Optimizing Hy4 Inference on TPU v7
- From 2 tok/s to Beating B200: Optimizing Hy4 Inference on TPU v7
- Hy4 Weight Loading on TPU v7: From 857 Seconds to 68
- 95 Minutes to 14: Cold Compile Optimization for Hy4 on TPU v7
- Cold Compile Optimization, Part 2: Cross-DP Compile Reuse for Data-Parallel Deployments on TPU
- Cold Compile Optimization, Part 3: Cross-Rank Reuse for Sequence-Parallel Buckets, 48 Minutes to 17.7
Data comes from deployment records between 2026-08-28 and 10-08.