5 Training Infrastructures

本文为论文《LongCat-Flash-Omni 全模态技术报告》「论文原文」板块的对应章节,按 arXiv 官方全文逐字保留,层级与「中文全文翻译」板块一一对应。

Our core design principles are largely inspired by the training infrastructure used in developing LongCat-Flash, with a particular emphasis on maximizing training efficiency while strictly ensuring numerical consistency. To guarantee numerical consistency, we enforce determinism, minimize errors, and maintain error interpretability, ensuring that every training run is both deterministic and reproducible. For efficiency, we decouple the components of the LLM, vision encoder, and audio encoder, enabling independent optimization of their performance and memory usage. Experimental results demonstrate the effectiveness of our approach: in multimodal settings, our system maintains over 90% of the throughput of text-only training.

5.1 Multimodal Decoupling Framework

Table 2: Computation distribution per micro-batch across different modalities during the SFT stage.

图

Figure 7: The distribution of sequence token lengths across different modalities during the SFT stage.

In multimodal scenarios, optimizing training performance is challenging due to the heterogeneity of both data and models. The challenge of data heterogeneity arises because the training data for LongCat-Flash-Omni includes speech, vision, and text, which show significant and dynamic differences in token distribution (Figure 7). Model heterogeneity is evident in the substantially different computational workloads across the three core components of LongCat-Flash-Omni: the vision encoder, the audio encoder, and the LLM decoder (Table 7). To address the aforementioned challenges, there are two primary optimization approaches. The first relies on Fully Sharded Data Parallelism (FSDP) (e.g., OrchMLLM (Zheng et al., 2025), veOmni (Ma et al., 2025)), which reduces static memory consumption through parameter sharding, avoids pipeline parallelism (PP) bubbles caused by model heterogeneity, and mitigates data heterogeneity via data-parallel (DP) group balancing. However, for LongCat-Flash-Omni, the total number of model parameters is too large for this approach to be practical.

The second approach is to decouple multimodal models across different parallel dimensions. For example, DistTrain (Zhang et al., 2025) mitigates model and data heterogeneity by separating model partitioning strategies and sorting data; PipeWeaver (Xue et al., 2025) reduces PP bubbles caused by heterogeneity through fine-grained data partitioning and dynamic pipeline scheduling; and Optimus (Feng et al., 2025) separates the parallelization strategies for encoders and LLMs, scheduling encoder computations into the LLM’s idle periods to eliminate bubbles caused by model heterogeneity. Building on the Optimus approach, we develop modality-decoupled parallelism (MDP), a simple yet effective multimodal training strategy. The core idea is to completely decouple the modality encoders and the LLM backbone at the distributed level, enabling independent scheduling and more efficient utilization of computational resources.

5.1.1 Modality-Decoupled Parallelism

图

Figure 8: Overview of modality-decoupled parallelism (MDP). The modality encoders and the LLM backbone are fully decoupled at the distributed level, enabling independent scheduling and improved computational efficiency.

In our implementation, we co-locate the modality encoders and the LLM decoder. The modality encoders utilize Hybrid Sharding Data Parallelism (HSDP)(Zhao et al., 2023) to reduce static memory, and full activation recomputation is employed to reduce activation memory usage. The LLM decoder adopts a combined distributed strategy including pipeline parallelism (PP), ZeRO-1 data parallelism (DP), context parallelism (CP), and expert parallelism (EP). To simplify data mapping between modality encoders and the LLM decoder, we introduce an InnerDP parallelism strategy, which further partitions modality data across all microbatches. The DP rank of modality encoders corresponds one-to-one with the DP rank of the LLM decoder, and the size of the InnerDP dimension is the product of the PP and CP of the LLM decoder (i.e., $d_{inner_dp}=d_{lm_cp}\times d_{lm_pp}$, $d_{world_size}=d_{dp}\times d_{inner_dp}$). As shown in Figure 8, the MDP execution timeline consists of four phases:

Data Loading: At the start of each training iteration, the rank with $inner_dp=0$ fetches all micro-batches. Then it broadcasts the metadata of the data to the other ranks within the DP group. This mitigates I/O overhead and memory pressure. In this phase, all micro-batches are sorted by text data sequence length to ensure workload across DP groups remain similar, thereby reducing EP bubbles caused by workload imbalances.

Modality Encoder Forward: The BalanceData module first distributes the modality data from the $inner_dp=0$ rank to the other $inner_dp$ ranks. Then, the modality encoders on each rank compute the corresponding vision and audio embeddings. Finally, the ModalityBridge module aggregates these embeddings at the $inner_dp=0$ rank, which are then passed as input to the LLM decoder.

LLM Decoder Forward and Backward: In this phase, modality embeddings are partitioned on the CP rank and fed into the LLM decoder for its forward and backward passes. The gradients of the vision and audio embeddings are then returned to the backward phase for the modality encoders. This design ensures the training efficiency of the LLM decoder, and also enables isolated optimization for modality encoders.

Modality Encoder Backward: The ModalityBridge module redistributes the modality embedding gradients from the LLM decoder to the other $inner_dp$ ranks, and then the backward pass of the modality encoders is executed.

5.1.2 ModalityBridge

图

Figure 9: Overview of the chunk-based ModalityBridge. The example configuration with num_chunk = 3, processing 4 microbatches of 8 images each across 4 GPUs (DP = 1, CP = 2, PP = 2)

In MDP, the ModalityBridge serves as the communication layer between the multimodal encoders and the LLM decoder. It is responsible for transforming data organization formats to resolve discrepancies arising from the different parallelism strategies employed by the modality encoders and the LLM decoder. This process specifically involves handling modality embeddings during the forward phase and gradients during the backward phase. However, when processing longer context length, significant memory pressure emerges as the $inner_dp=0$ rank must read all micro-batches and perform gather and scatter operations on the modality embeddings and their gradients. To address this challenge, we adopt chunk-based processing within ModalityBridge, which effectively alleviates the memory bottleneck while maintaining bitwise numerical consistency. As illustrated in Figure 9, this module comprises three core components:

Embedding Redistribution: Employs a two-stage chunking approach for data gather and scatter, decomposing the complete data transformation into $num_chunk$ iterations. Each iteration consists of two stages:

Aggregation: Inner-DP embeddings are aggregated to the $inner_dp=0$ rank.

CP partitioning: The aggregated data is split along the $hidden_size$ dimension to ensure uniform embedding distribution and balanced memory usage, followed by scattering to the respective CP ranks to further reduce per-device memory consumption.

During each chunking iteration, the overall memory footprint exhibits a rise-then-fall pattern, significantly lowering the peak memory usage.

Modality Embedding Storage: Stores all gathered-then-scattered chunk data while maintaining global offset information for subsequent indexing.

Embedding Indexing: Provides micro-batch-level embedding retrieval and gradient backpropagation during the LLM forward and backward phases.

Based on these three components, we accomplish the transformation of data formats across different stages. In the forward phase, the transformation is performed according to the two-stage chunking approach, while in the backward phase, Embedding Redistribution executes the reverse process: gradients are first gathered via CP gather and then scattered to the corresponding $inner_dp$ ranks according to the global offset information for backward computation. Meanwhile, the chunking scheme reduces the peak memory usage to $1/num_chunk$ of the original, significantly alleviating memory pressure while ensuring bitwise numerical alignment.

5.2 Performance Tuning

Our overarching strategy is twofold: first, select a distributed configuration by profiling core operator efficiency; second, meet the configuration’s memory budget via targeted memory optimizations. On the communication side, the shortcut architecture enables overlap between EP communication and computation within each micro-batch. In CPU-bound regimes, we employ fused operators to reduce kernel launch overhead and improve end-to-end throughput.

5.2.1 Optimal Distributed Configuration

In large-scale LLM pretraining, the efficiency of core operators is primarily constrained by the sequence length; increasing sequence length typically improves Model FLOPs Utilization (MFU). Accordingly, our system design increases the effective sequence length per EP rank to approach the operators’ high-efficiency regime. Hardware-specific benchmarking results further indicate that reducing CP substantially improves the efficiency of the core operator, as shown in Figure 10.

图

Figure 10: Benchmark results of MoE GEMMs under different CP/EP configurations with an 8K sequence length.

5.2.2 Communication Optimizations

Our training infra contains multiple compute-communication overlaps, mainly including shortcut-based EP overlap and point-to-point (P2P) overlap. We tune the number of streaming multiprocessors (SMs) assigned to communication and compute kernels for each scenario to maximize hardware utilization, and we use distinct P2P groups/streams so that inter-stage pipeline-parallel (PP) communication does not interfere across stages.

5.2.3 Kernel Optimizations

To optimize the training efficiency of MoE models, we maintain computational determinism while implementing kernel optimization and fusion along critical computational paths. Our technical contributions encompass the following areas:

Optimized Grouped GEMM Our optimization strategies for Grouped GEMM achieve approximately 75% MFU in the evaluated scenarios. (1) Dynamic SwapAB: The WGMMA instruction is evaluated with the $N$ dimension varying from 8 to 256, while the $M$ dimension is fixed at 64. We design an optimized kernel that automatically performs SwapAB operations to maximize WGMMA performance. (2) Configurable SM Usage: The Grouped GEMM kernel allows configurable SM counts to avoid resource contention when overlapping with dispatch or combined communication operations. (3) Fine-Tuning: TileShape, PipelineStage, and ClusterShape are carefully tuned for the target workload to maximize hardware utilization and prevent register spilling. (4) Scheduling and Pipeline Strategy: A swizzled block mapping schedule is adopted to significantly improve L2 cache hit rates. In addition, a ping-pong mechanism is introduced during the backward pass to overlap WGMMA computation with the loading and storing of weight gradients.

Fused Permute An efficient fused permute kernel is employed to rearrange tokens for expert alignment, while also integrating several critical functionalities, including metadata computation for the backward pass and token dropping within the CP group.

Fused RoPE We fuse RoPE into the MLA prologue kernel, eliminating the overhead of intermediate data writing and reloading, achieving a $3\times$ speedup compared to the baseline.

Deterministic FA We employ a semaphore-based synchronization scheme that ensures deterministic QK reduction in the backward phase and outperforms the default deterministic implementation, which requires an additional temporary workspace. This approach achieves approximately $0.8\times$ the performance of the non-deterministic version.

5.3 Memory Optimization Strategies

Without optimization, the required memory for our target configuration is approximately 137 GB per device (Table 3). Given 80 GB devices and accounting for EP imbalance peaks, we constrain the theoretical memory footprint to approximately 72 GB.

Table 3: Naïve memory usage breakdown by component.

We combine the techniques in Table 4: (i) a V-shaped PP schedule to bound concurrently alive activation micro-batches (Qi et al., 2024); (ii) selective recomputation for low-FLOP, high-activation operators such as SwiGLU and LayerNorm (DeepSeek-AI et al., 2025); (iii) memory-efficient permute, which moves aggregation of routing probabilities and hidden states into SwiGLU to reduce MoE unpermute memory (Shoeybi et al., 2019); (iv) fine-grained SM budgeting for NCCL communicators to reduce NCCL memory; and (v) Hybrid-Sharding Data Parallel (HSDP) for the modality encoder to further reduce its static footprint (Paszke et al., 2019). To accommodate potential EP load imbalance, we implement dynamic expert recomputation: when any rank is assigned too many tokens, we dynamically recompute its down-projection, freeing all MoE memory except the down-projection inputs on trigger. This prevents training crashes from expert imbalance while incurring only modest overhead.

Table 4: Memory footprint under different optimization settings.

5.4 Numerical Consistency

Large language model pretraining is extremely resource-intensive, often requiring weeks and incurring millions in computational costs. Ensuring the correctness of the training framework is essential to avoid costly retraining due to implementation errors.

In our framework, we enforce deterministic implementations for all computation, communication, and data flow, ensuring that every experiment is reproducible and maintains bitwise-aligned loss values.

For new features, we prioritize bit-aligned implementations to ensure numerical consistency. For example, features like fused_permute and fused_swiglu ensure bitwise-aligned loss whether they are enabled or not. Similarly, kernels like Grouped GEMM and Router GEMM employ a non Split-K implementation to preserve alignment across varying batch sizes or distributed settings.

For features where bit alignment is not feasible, we systematically analyze all sources of numerical deviation and mitigate their impact by benchmarking against the gold reference implementation during verification. For example, we identified and aligned the accumulation order in DeepEP and All2All EP strategies, thereby achieving bit-level consistency in loss values and verifying implementation correctness.