使用 PyTorch 和 TorchTitan 在欧盟公共基础设施上训练 1T 参数的 MoE 模型
原题Training a 1T-Parameter MoE on EU public infrastructure with PyTorch and TorchTitan
读前速览
本文介绍 EUROPA 联盟如何使用 PyTorch 和 TorchTitan,在 JUPITER 超级计算机上扩展预训练一个约 1T 参数的混合专家模型,并通过 FlexShard、激活卸载和 FSDP 流管理等优化,实现每 GPU 约 1,300 tokens/s 的吞吐量。
在公共基础设施上扩展 MoE 训练
EUROPA 联盟在 JUPITER 这台欧盟共享超级计算机上训练了一个拥有 951.9B 参数的 MoE 模型,证明通过精心优化,公共基础设施也能支撑前沿规模的 AI 训练。
使用 FlexShard 减少 Muon 优化器的通信
FlexShard 放置策略可按完整专家对专家矩阵进行分片,使 Newton-Schulz 迭代无需通信;同时,稠密矩阵的计算可与通信重叠,从而将优化器步进时间从 41.7s 降至 2.2s。
将激活卸载到 Grace CPU 内存
前向传播期间,边界激活会被卸载到 Grace CPU 内存,并在反向重计算前传回 HBM。这使序列长度得以增加到 65,536 tokens,并将每 GPU 吞吐量从 370 提升至 508 tokens/s。
使用 unshard_async_op 管理 FSDP 流
启用 FSDP 的 unshard_async_op 标志后,all-gather 会在计算流上运行,避免内存碎片化和分配器重试,将峰值内存从 88.1 降至 74.6 GiB,并将每 GPU 吞吐量从 996 提升至 1,210 tokens/s。
向 PyTorch 和 TorchTitan 回馈成果
团队将 FlexShard、激活卸载钩子、共享 RoPE 缓存、跳过嵌入层重新聚合以及 RNG 修复等成果贡献回上游,让更广泛的社区能够使用这些优化并复现相关结果。
完整摘要
EUROPA 联盟利用 PyTorch 和 TorchTitan,克服了独特的基础设施限制,成功在欧盟公共超级计算机 JUPITER 上训练了一个拥有 951.9B 参数的混合专家模型。关键优化包括为 Muon 优化器采用 FlexShard 放置策略以减少通信、将激活检查点卸载到 Grace CPU 内存,以及让 FSDP 的 all-gather 在计算流上运行以释放 HBM。这些技术使 384 个 NVIDIA GH200 GPU 的吞吐量从每 GPU 90 tokens/s 提升至约 1,300 tokens/s。这项工作表明,借助共享公共资源,主权开源 AI 也能达到前沿规模;同时,团队向 PyTorch 和 TorchTitan 回馈了相关成果,助力复现。
目录 · 5 节
Scaling pretraining for a ~1-trillion-parameter Mixture-of-Experts (MoE) model on shared, public infrastructure was previously considered unfeasible due to unique architectural and interconnect bottlenecks. However, by leveraging the fine-grained flexibility of PyTorch and TorchTitan, the EUROPA consortium successfully unlocked frontier-scale training on JUPITER, boosting throughput from 90 to ~1,300 tokens/sec per GPU across 384 NVIDIA GH200 GPUs per DP replica (96 nodes) as part of the EuroHPC Frontier AI Grand Challenge.
The EuroHPC Frontier AI Grand Challenge was designed to prove that sovereign, open-source AI could compete at frontier levels using shared public resources. As part of that process, we – as the EUROPA consortium, formed by Domyn and Fraunhofer IAIS and IIS – were selected to an open European Mixture-of-Experts (MoE) model of at least 400B parameters, support for all 24 official EU languages, and strict compliance with the EU AI Act.
In this post, we describe how we scaled pretraining to 1T MoE on JUPITER, the EuroHPC exascale supercomputer hosted at Forschungszentrum Jülich, proving that public infrastructure can indeed sustain frontier scale.
| Total parameters | 951.9B (32.8B active per token) |
| Layers | 74 |
| Hidden size | 6,144 |
| Experts | 384 routed, top-8 |
| Expert hidden size | 1,792 |
| Vocabulary | 256,000 |
| Pretrain Sequence length | 65,536 tokens |
| Optimizer | Muon + AdamW |
The table lists the configuration used for the experiments in the post.
Models of this size are usually trained on clusters that their developers operate or rent for exclusive use. JUPITER is instead publicly funded research infrastructure shared by hundreds of projects. It was also designed to support scientific research at large, which led to architectural choices that are somewhat atypical in the AI space, as we’ll describe in detail later in the post. As such, reaching the 1T parameter scale while maintaining viable throughput requires careful optimizations that go beyond standard distributed techniques.
In order to have access to the necessary level of flexibility to perform fine-grained optimizations to the pre-training setup, we chose to go with PyTorch and TorchTitan. Under these conditions, we raised throughput from 90 to ~1,300 tokens/s per GPU on 384 GH200 GPUs (96 nodes). We want to share the main milestones that get us there, each of which builds on TorchTitan’s design and led to contributions back to TorchTitan and PyTorch:
- FlexShard placement for the Muon optimizer, which removes most of the optimizer’s communication.
- Activation-checkpoint offloading to the Grace CPU.
- Running FSDP’s all-gather setup on the compute stream (
unshard_async_op), which frees ~14 GiB of HBM per GPU.
The full write-up covers the remaining changes in detail, with interactive figures and profiler traces.

The machine and its constraints
Each JUPITER Booster node has four NVIDIA GH200 Grace Hopper Superchips. Each superchip pairs a Hopper GPU (96 GB HBM3) with a 72-core Grace CPU (120 GB LPDDR5X), connected by a 900 GB/s NVLink-C2C link. GPUs in a node are connected by NVLink 4 at 150 GB/s per direction, and each node has four InfiniBand NDR200 adapters, about 25 GB/s per GPU.

Figure 2. Bandwidths within a JUPITER node, drawn to scale. All inter-node traffic leaves through the thin InfiniBand links.
In addition to the accelerators, two key parts of the system are also relevant for the design:
- Inter-node bandwidth. InfiniBand is 36 times slower than the link between a GPU and its own CPU, and distributing a 1T parameter model over hundreds of accelerators requires crossing that boundary continuously during training. Traffic over InfiniBand must therefore aggressively overlap with computation.
- Host memory capacity. GH200 is available with up to 480 GB of LPDDR5X per Grace, but JUPITER’s compute nodes actually use the 120 GB configuration (as opposed to login nodes which sport 480GB), which favors bandwidth over capacity. After the kernel’s share, about 108 GiB per GPU is usable, and we found that in practice some nodes start jobs with much less. This limits how much state can be moved out of the HBM.
These constraints dictate the parallelism layout: 384-way FSDP with 4-way expert parallelism inside each node and no pipeline parallelism. The MoE token all-to-all is hard to overlap, so we kept it on NVLink. Without pipeline parallelism steps tend to be shorter, which has the advantage of providing fast feedback at scale, and fixed costs are amortized via a large batch of 384 sequences of 65,536 tokens (~25M tokens per step). FSDP already provides us with the overlap of the gather of layer n+1 with the compute of layer n, so most of the remaining work goes into making the overlap effective. We achieve this across three dimensions: moving to longer sequences to compute for longer, reducing the bytes transmitted over InfiniBand, and leveraging Grace memory to provide enough total capacity to hold the model, the gradients and the optimizer state.
FlexShard: Muon without the communication
We use Muon for every weight matrix except the router and embeddings (about 99.5% of the parameters) and AdamW for the rest. Muon requires one fp32 state per parameter, while Adam requires two. Removing the second state is instrumental in making a 65,536-token sequence fit in memory.
Muon orthogonalizes each update with a few Newton-Schulz iterations, which operate on the whole matrix. Because FSDP splits every matrix into 384 shards, a simple implementation gathers each matrix on one rank, runs Newton-Schulz there and scatters the result back. On our interconnect, this communication is too expensive.
FlexShard, now part of TorchTitan, lets us control which rank owns which parameters. We shard the experts by whole expert, so every rank owns complete expert matrices and runs their Newton-Schulz iterations with no communication at all. The dense matrices, such as the attention projections, are still collected on an owning rank, and each rank processes its own experts while the dense matrices are in transit, so that communication is overlapped.
With FSDP’s CPU offload, the optimizer runs on Grace, where the parameters are stored, and Newton-Schulz on 72 Arm cores takes ~35 s per step. We contributed support to TorchTitan for running Newton-Schulz on the GPU while parameters stay offloaded. The optimizer step went from 41.7 s to 2.2 s, and throughput rose from 441 to 597 tokens/s per GPU (+35%).

Figure 3. Rank 0’s profiled step from 80 s onward. Top: Newton-Schulz on Grace, with the GPU idle for ~34 s after the backward pass while the CPU computes. Bottom: Newton-Schulz on Hopper, where the optimizer takes a small fraction of the step.
Activation offloading to Grace
The volume of weights gathered per layer does not depend on the number of tokens in our setup, so a longer sequence increases compute time while not impacting communication. We first stored activations only at layer boundaries and recomputed everything inside a layer during the backward pass. In TorchTitan this is named FullAC. Since GPU was idle for most of the baseline step, the extra compute did not lengthen it. As a result, throughput went from 90 to 370 tokens/s per GPU at 32,768 tokens.
At 65,536 tokens, the boundary activations alone take 74 layers × 65,536 tokens × 6,144 × 2 bytes ≈ 55 GiB per GPU, which does not fit in HBM next to the weights. GH200 has a 900 GB/s link to 120 GB of CPU memory, so we decide to offload them. Each boundary activation is copied to Grace after the forward pass produces it, and copied back to Hopper one layer before the backward pass recomputes it. An offloading parameter sets the share of layers that offload, which trades HBM for Grace memory.
TorchTitan’s activation-checkpointing wrapper made this change convenient. We contributed the hooks for activation-checkpoint offloading to TorchTitan and built our offloading strategy on top of them. With offload, throughput rose from 370 to 508 tokens/s per GPU (+37%), and the sequence length grew to 49,152 tokens and then, with Muon, to 65,536.

Figure 4. Offload schedule, drawn with 16 layers in place of 74. During the forward pass, each boundary activation moves to Grace. During the backward pass, it returns to HBM one layer before its recomputation.
De-fragging FSDPs Streams
After an upgrade to our software stack, the CUDA caching allocator started retrying allocations on every rank at ~70% memory utilization. At the time of the retries, 25-30 GiB of HBM was free, but the allocator could not use it.
After investigating the root cause, we identified it in how FSDP overlaps communication with computation. FSDP uses one compute stream and four side streams, and the allocator keeps a separate pool per stream. Memory freed by a stream can only be reused by that stream. FSDP allocates each buffer on the stream that writes it, and some of our other communication optimizations allocated temporary buffers inside FSDP’s calls, so these buffers also landed on side streams. Replaying the allocator’s event log at peak memory showed the side streams holding 27.3 GiB, of which only 6.4 GiB was in use. The remaining 20.9 GiB was out of reach of the compute stream, which then could not find a 4 GiB block for a MoE buffer.

Figure 5. HBM held by each allocator stream’s cache at peak live memory, reconstructed from the allocator’s event trace on rank 0. Solid bars are live tensors, and dashed bars are cached memory that only the owning stream can reuse.
Luckily, FSDP2 has a private flag, unshard_async_op, that runs the all-gather setup on the compute stream and lets NCCL run on its internal stream. The gather buffers are then allocated from, and returned to, the compute stream’s pool. We adapted our custom gather to run asynchronously, so the compute stream waits for the network only when it needs the weights. This brought the number of ranks with allocator retries from 384 to zero. Peak reserved memory went from 88.1 to 74.6 GiB, and throughput rose from 996 to 1,210 tokens/s per GPU.
We proposed a TorchTitan option to enable the flag. Following the review, unshard_async_op is being moved into a public FSDP API (PyTorch #202343), so other FSDP users can rely on it.
Upstreaming contributions and closing remarks
The configuration we just described allows to scale pre-training runs to 1T parameters at a workable throughput on public European infrastructure. In order to make it possible for others to reproduce these results (more details are available in a companion post), we upstreamed all the fixes to PyTorch and TorchTitan.
In addition to the three contributions we already mentioned, we contributed a shared RoPE cache to TorchTitan (2.56 GiB per GPU at our sequence length), skipping the embedding re-gather in the backward pass, and configurable seed-offset mesh axes. In PyTorch, we fixed CPU initialization resetting the RNG state and trunc_normal_ all-gathering DTensors. We also reported unattributed host memory at job start to the Jülich Supercomputing Centre, since it affects every user of the machine.
Thanks to the level of control provided by PyTorch and TorchTitan, training now runs at a sustained throughput of ~1,300 tokens/s per GPU on 384 GH200s per DDP replica, for a total of 1536 GPUs for 4 DDP replicas, and fits in memory by fully leveraging the HBM and the Grace architecture. The companion post covers the rest of the path in Figure 1: data and expert load balancing, reducing the bytes sent over InfiniBand, node-local resharding, dynamic tile scheduling in SonicMoE and capping NCCL’s SM usage.
We are grateful to the European Commission for Frontier AI Grand Challenge award. We hope that this work will motivate further investments in public compute infrastructure and the continued growth of the European AI ecosystem.
Learn more: