TERRA: A Hierarchical Parallel Training and Memory Orchestration Framework for High-Resolution AI-based Earth Modeling
Analyze & explore related research in Conceptio
Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.
1
TERRA: A Hierarchical Parallel Training and Memory Orchestration Framework for High-Resolution AI-based Earth Modeling
arXiv:2608.15211v1 [cs.CV] 15 Aug 2026
Ruohan Wu, Ziqi Zhu, Yang Zhao, Jiarui Tang, Yingzhe Cui, Junshi Chen, Zhao Jing, Jun Shi, and Hong An
Abstract—Training high-resolution AI-based Earth forecasting models is memory-intensive. Window-based Swin Transformers reduce the quadratic cost of global attention, but existing distributed systems such as AERIS primarily target pixel-level models and do not jointly support convolutional sampling modules and shifted-window execution. Long-lead rollout finetuning further increases activation memory. To address these challenges, we present TERRA, a hierarchical parallel training framework for high-resolution Earth forecasting. TERRA introduces SamplingAware Window, Sequence, and Tensor Parallelism (SAWSTP), which preserves spatially contiguous layouts for sampling modules and routes tokens into topology-aware ragged window layouts for Transformer execution. For long-lead finetuning, Memory Orchestration (MO) provides rollout-aware checkpoint planning and combines input buffering with budget-constrained activation offloading. Experiments on the 1/12◦ GLORYS-based Wenhai workload show that TERRA supports models with up to 11.4B parameters on 96 H200 GPUs and sustains up to 39.76 PFLOPS, achieving 65.0% strong-scaling and 94.1% weak-scaling efficiency. Compared with checkpoint-only policies, MO further reduces peak allocated GPU memory by 32.2%–51.8% with at most 20.0% step-time overhead, which makes finetuning with smaller patch sizes and longer rollouts feasible for improved forecasting accuracy. Index Terms—Deep learning, weather and ocean forecasting, distributed training, Swin Transformer, memory management.
I. I NTRODUCTION
A
I-based Earth forecasting has emerged as a promising approach for advancing high-resolution weather and ocean
This work was supported in part by Laoshan National Laboratory under Grant LSKJ202300305 and in part by the Anhui Provincial Natural Science Foundation under Grant 2508085QF210. (Corresponding authors: Jun Shi and Hong An.) Ruohan Wu and Jun Shi are with the School of Computer Science and Technology, University of Science and Technology of China, Hefei 230026, China (e-mail: ruohanwu@mail.ustc.edu.cn; shijun18@ustc.edu.cn). Ziqi Zhu is with the School of Artificial Intelligence and Data Science, University of Science and Technology of China, Hefei 230026, China (e-mail: ta1ly@mail.ustc.edu.cn). Yang Zhao, Jiarui Tang, Junshi Chen, and Hong An are with the School of Computer Science and Technology, University of Science and Technology of China, Hefei 230026, China, and also with the Department of Ocean Big Data and Artificial Intelligence, Laoshan Laboratory, Qingdao, China (email: yang zhao@mail.ustc.edu.cn; tjr@mail.ustc.edu.cn; cjuns@ustc.edu.cn; han@ustc.edu.cn). Yingzhe Cui is with the Department of Ocean Big Data and Artificial Intelligence, Laoshan Laboratory, Qingdao, China (e-mail: cuiyingzhe@lsnl.cn). Zhao Jing is with the Frontiers Science Center for Deep Ocean Multispheres and Earth System and the Key Laboratory of Physical Oceanography/Academy of Future Ocean, Ocean University of China, Qingdao, China, and also with the Department of Ocean Big Data and Artificial Intelligence, Laoshan Laboratory, Qingdao, China (e-mail: jingzhao@ouc.edu.cn).
prediction [1], [2], [3], [4], [5], [6], [7]. Recent models increasingly adopt finer spatial resolutions to represent complex Earth-system dynamics. However, training these models at scale remains challenging because high-resolution, multivariate training data increases the number of spatial tokens and creates large activation tensors. Recent systems have demonstrated that large-scale parallel training can support Earth forecasting models with greater parameter capacity. ORBIT [8] combines Fully Sharded Data Parallelism (FSDP) [9] with tensor parallelism (TP) [10] to train Vision Transformer (ViT)-based Earth models [11] with up to 113B parameters on 1.4◦ data. At higher spatial resolutions, however, activation memory rather than parameterrelated memory can become the dominant training bottleneck. Window-based Swin Transformers [12] are therefore particularly attractive because they avoid the quadratic cost of global attention. AERIS [13] scales pixel-level Swin Transformers with up to 80B parameters on 0.25◦ data through SequenceWindow Parallelism (SWiPe), which combines window parallelism (WP), sequence parallelism (SP) [14], and pipeline parallelism (PP) [15]. Despite this progress, the SWiPe method for pixel-level Swin Transformers still faces several challenges. First, SWiPe does not support convolutional sampling modules, which reduce the token resolution and activation memory of Transformer blocks and can also improve forecasting accuracy. Second, SWiPe relies on PP, whose bubbles cannot be effectively amortized under small global batch sizes. Third, AERIS considers only fixed window assignments. When the window size is small and the number of windows per rank is sufficient, complete-window WP provides sufficient parallelism, making SP communication unnecessary. When the window size is large, fixed window assignment requires substantial padding to maintain uniform window ownership. Its roundrobin ownership also increases the communication required by shifted-window execution. Moreover, using smaller patch sizes [16] and finetuning with longer lead times can improve long-lead forecasting accuracy. However, these methods also significantly increase activation memory, especially for the 1/12◦ GLORYS-based Wenhai workload [6], [17]. To address these challenges, we present TERRA, a hierarchical parallel training and memory orchestration framework for high-resolution Earth forecasting. TERRA introduces Sampling-Aware Window, Sequence, and Tensor Parallelism (SAWSTP), which defines an I/O topology for sampling modules and a Transformer topology for Swin Transformer
2
blocks. The I/O topology applies Domain Parallelism (DMP) to partition high-resolution inputs into spatially contiguous regions and parallelizes convolutional sampling modules through halo exchange [18]. The Transformer topology integrates WP, SP, and TP with FSDP, avoiding PP and its pipeline bubbles at small global batch sizes. Differentiable token routes connect the two topologies by converting spatial DMP partitions into the window-oriented layouts required by Transformer blocks and support distributed shifted-window execution across different WP, SP, and TP configurations. Building on these token routes, TERRA introduces costaware window assignment to adapt the Transformer topology to different window sizes and parallel configurations. It uses ragged window ownership and selects among WP/SP topologies to reduce padding and shifted-window communication while balancing workloads. To reduce the activation-memory pressure of long-lead finetuning, TERRA further introduces Memory Orchestration (MO). Building on activation checkpointing [19], [20], [21], [22], MO separately profiles the retained activation memory and backward recomputation peaks of sampling and Transformer checkpoint units. It uses these measurements to construct a lead-dependent checkpoint plan that balances rollout-wide activation accumulation against local recomputation peaks. Input buffering bounds the GPU lifetime of rollout inputs and labels. If the predicted peak still exceeds the target memory budget, MO selectively offloads activation boundaries to host memory [23], [24], [25], [26] until the predicted peak satisfies the budget. We implement TERRA as an open-source training framework available at https://github.com/ruohan12345/TERRA and evaluate it through pretraining and rollout finetuning of hierarchical GLORYS-based Wenhai models. The contributions of this work are summarized as follows: • We design SAWSTP, a parallelism strategy that applies halo-exchange-based DMP to convolutional sampling modules and combines WP, SP, TP, and FSDP for Transformer blocks. It scales Wenhai model training to 96 H200 GPUs, achieving up to 65.0% strong-scaling and 94.1% weak-scaling efficiency, with sustained performance of up to 39.76 PFLOPS. • We introduce cost-aware ragged window assignment that adapts the WP/SP topology to the window size and parallel configuration. It reduces padding and shiftedwindow communication while balancing workloads, providing a 1.03×–1.18× training-step speedup over the fixed AERIS-style baseline. • We develop MO for long-lead finetuning by combining profile-guided, lead-dependent checkpoint planning with input buffering and budget-constrained activation offloading. MO reduces peak allocated GPU memory by 32.2%– 51.8% relative to checkpoint-only policies, with at most 20.0% step-time overhead. • We pretrain, finetune, and evaluate hierarchical Wenhai models on the GLORYS-based workload. The results demonstrate that hierarchical sampling, smaller patch sizes, and longer rollout finetuning enabled by TERRA improve long-lead forecasting accuracy.
TABLE I N OTATION FOR THE W ENHAI MODEL . Notation H, W Ĥ, Ŵ C p α d Nh w L
Description Spatial resolution of the input field Padded spatial resolution of the input field Number of input physical variables Patch size Stride of each down- or up-sampling module Embedding dimension Number of attention heads Attention-window size Number of Swin Transformer blocks
II. BACKGROUND AND M OTIVATION A. AI-based Earth Forecasting Models AI-based models have become an important approach for global weather and ocean forecasting [1], [2], [3], [4], [5], [6], [7]. However, the increasing spatial resolution substantially raises the computational and memory requirements of model training. For example, Pangu-Weather is trained on 1/4◦ ERA5 data with 721 × 1440 grid points [2], [27], whereas Wenhai uses 1/12◦ GLORYS data with 2041 × 4320 grid points [6], [17]. TERRA targets the Wenhai workload, whose high-resolution multivariate ocean inputs impose substantial memory pressure during training. In Wenhai, each input is a dense multivariate ocean field on a regular latitude–longitude grid, represented as Xt ∈ RB×H×W ×C , where B is the micro-batch size, H and W are the spatial dimensions, and C = 93 is the number of ocean variables. As shown in Fig. 1(a), Wenhai first maps the input field to patch tokens, which are then processed by a hierarchical encoder–decoder architecture that combines convolutional down- and up-sampling modules with windowbased Swin Transformer blocks [12]. This design reduces the number of tokens processed by the Transformer blocks while preserving multiscale spatial representations. Table I summarizes the main notation of the Wenhai model. As shown in Fig. 1(b), AI-based Earth forecasting is autoregressive. Given an initial state Xt at time t, the predicted state at lead time k∆t is fed back as the input to the next forecast step, producing the state at lead time (k + 1)∆t. To improve long-lead forecast accuracy, models are typically pretrained for single-step forecasting and then finetuned over multiple autoregressive steps [1], [3], [4], [6]. During pretraining, the model learns a single-step forecasting operator fθ that maps Xt to Xt+∆t . During finetuning, the same model parameters are reused over a K-step rollout: X̂t+k∆t = fθ X̂t+(k−1)∆t , 1 ≤ k ≤ K, (1) where X̂t = Xt and K is the rollout length. The finetuning objective sums the prediction losses over the K forecast steps, which directly optimizes long-lead forecast accuracy. However, the finetuning also retains intermediate activations across the rollout until backpropagation, which substantially increase the memory footprint.
3
Lead t
Pred Lead t+1
Finetune Model
Pretrain Model
Pred Lead t+1
Model
Pred Lead t+2
Lead t+1
Loss Function
Lead t+2
Loss Function
Lead t Pad
Pad Back
Patch Embedding
Output Embedding
Loss 1 Down Blocks
Swin Transformer Blocks
Pre-Processing
Up Blocks
…
Loss 2
Final Loss
Post-Processing
(a) Hierarchical Swin-based model.
(b) One-step pretraining and multi-step rollout finetuning.
Training high-resolution forecasting models presents both substantial I/O overhead and memory pressure. A single training sample can contain a large multivariate spatial field, making the micro-batch size per GPU typically small (e.g. B = 1). Recent systems therefore distribute one sample across multiple devices to reduce the per-rank input and activation footprint [8], [13], [28], [29], [30]. The GPU memory footprint of DNN training consists primarily of model parameters, gradients, optimizer states, and activations [31]. Different parallel and memory-management techniques target different components. Data parallelism (DP) replicates the model and distributes samples across ranks, but it cannot reduce the memory required by an individual high-resolution sample. FSDP and ZeRO-style methods shard parameters, gradients, and optimizer states [9], [32], [33], [34], [35]. TP [10], [36] partitions Transformer parameters and intermediate activations, SP [14] partitions token sequences, and PP partitions model layers into stages [15]. Activation checkpointing trades additional recomputation for a smaller activation footprint [19], [20], [21], [22], while activation offloading transfers selected activations outside GPU memory for later reuse [23], [24], [25], [26]. To improve the efficiency of large-scale Earth modeling, a series of memory-efficient parallel training systems has been proposed. For example, Jigsaw focuses on spatially partitioned execution for high-resolution inputs through distributed patch embedding and matrix operations [28]. ORBIT combines FSDP and tensor parallelism to scale the parameter capacity of ViT-based Earth foundation models [8], while ORBIT-2 further targets hyper-resolution climate downscaling with spatially partitioned execution of extremely long token sequences [29]. AERIS addresses distributed training of pixellevel Swin Transformers through SWiPe, which partitions window activations and distributes the computation of shiftedwindow attention blocks across GPUs [13].
C. Motivation The following observations motivate the design of TERRA for high-resolution hierarchical Earth forecasting models.
No sampling With sampling OOM
100 80 60 40 20 0 p=2
p=3
p=4
p=6
p=8
(a) Patch-size memory. Peak allocated GPU memory (GB)
B. Memory-Efficient Parallel Training
Peak allocated GPU memory (GB)
Fig. 1. High-resolution Earth forecasting model and training stages.
p=4 p=6 p=8 OOM
100 80 60 40 20 0 1
2
4
6
Finetune lead time
(b) Rollout memory. Fig. 2. Memory pressure in training high-resolution Earth forecasting models.
1) Limitations of Existing Swin Parallelism for HighResolution Earth Modeling and Parameter Scaling: Prior work has shown that larger models and smaller patch sizes can improve weather-forecasting accuracy [16]. Existing distributed Swin Transformer systems such as AERIS use SWiPe to train pixel-level Swin Transformers with a patch size of p = 1 and scale models to 80B parameters [13]. However, extending this design to higher-resolution training data and more parameters presents additional challenges. Finer spatial resolutions and smaller patch sizes both increase the number of patch tokens and the associated activation memory. AERIS is evaluated on 0.25◦ data, whereas Wenhai uses 1/12◦ data. At a fixed patch size, this resolution difference produces roughly nine times more tokens and activations. As shown in Fig. 2(a), reducing the patch size substantially
4
increases peak memory, while sampling modules alleviate this pressure by reducing the token resolution processed by the Transformer blocks and can improve forecasting accuracy through multi-scale feature learning. However, combining parallel Transformer execution with parallel sampling modules remains challenging because they favor different tensor layouts. Sampling modules require spatially contiguous partitions for convolution, whereas Swin Transformer blocks require window-major token layouts for window attention. For parameter scaling, Table II summarizes the model settings and supported parallelism of ORBIT, AERIS, and TERRA. AERIS relies on PP to partition Transformer layers across devices. Its WP and SP distribute activation across multiple GPUs but do not reduce parameter-related memory [13]. PP bubbles are difficult to amortize under small global batch sizes. For example, Wenhai uses a global batch size of only 16. ORBIT instead combines TP with FSDP to scale Earth foundation models [8]. However, complex distributed windowattention operations with shifted windows make TP integration with SWiPe challenging. 2) Efficient Window Assignment Requires Topology-Aware Optimization: To support distributed shifted-window execution, SWiPe adopts a fixed window-assignment strategy that maps attention windows to ranks through inter-window WP and intra-window SP. However, this fixed mapping does not adapt to the number of complete windows available under a given parallel topology. When many complete windows are available per rank, the fixed WP mapping can incur avoidable WP communication during distributed window shifting, as well as padding overhead from its regular layout. TERRA mitigates both sources of overhead through a row-contiguous window-assignment method. When only a few complete windows are available per rank, WP may not divide the window grid evenly. Padding the window grid to equalize window counts increases computation and memory consumption, whereas avoiding padding can leave ranks with imbalanced workloads. Although SP can mitigate this imbalance by further partitioning individual windows across ranks, it introduces additional all-to-all communication. Therefore, window assignment should jointly consider padding overhead, window-shift communication, workload balance, and the required topology of WP and SP. 3) Long-Lead Finetuning Requires Activation-Aware Memory Management: Long-lead finetuning fundamentally changes the memory characteristics of high-resolution Earthmodel training. During one-step pretraining, activations are bounded within a single forward–backward pass. In contrast, rollout finetuning repeatedly reuses the same model parameters across multiple forecast steps and retains intermediate rollout states and activations until backpropagation, making long-lead finetuning increasingly dominated by activation memory. As shown in Fig. 2(b), peak memory increases rapidly with rollout lead time and can eventually cause out-of-memory (OOM) failures. Although activation checkpointing and activation offloading have been extensively studied for DNN training, existing policies do not adequately capture the heterogeneous memory behavior of sampling and Transformer checkpoint units in
TERRA Hierarchical Swin Transformer
Task
Parallel Framework SAWSTP (DP, DMP, WP, SP, TP, FSDP)
Cost-aware Window Assignment
Pretraining
Input Resolution
Memory Orchestration
Patch size
Window Size
Checkpoint Planning
Budget Offloading
Input Buffer
Finetuning
Fig. 3. Overview of TERRA.
hierarchical Earth models. High-resolution sampling blocks retain individually large activation tensors, which are difficult to mitigate through activation checkpointing alone. Moreover, long-lead finetuning requires high-resolution input and label tensors from multiple lead times to reside on the GPU. These tensors alone impose a substantial memory footprint. Consequently, activation-memory optimization should employ separate strategies for different activation units while accounting for the rollout process and remaining compatible with distributed execution, rather than relying on a single global checkpointing or offloading strategy. III. TERRA OVERVIEW To address the aforementioned challenges, we propose TERRA, a hierarchical parallel training and memoryorchestration framework for high-resolution AI-based Earth forecasting models. As shown in Fig. 3, TERRA targets hierarchical Swin Transformer models and supports configurations with varying input resolutions, patch sizes, window sizes, and model scales. It integrates SAWSTP with MO to support distributed pretraining and long-lead finetuning under these configurations. SAWSTP partitions each high-resolution training sample into spatially contiguous DMP shards for patch embedding and sampling modules, and then routes the resulting tokens to Swin Transformer blocks executed with WP, SP, TP, and FSDP. Building on SAWSTP, TERRA employs cost-aware window assignment to select a ragged window assignment based on the input and parallel configuration. During long-lead finetuning, MO manages the per-rank memory pressure arising from rollout activations and high-resolution input and label data while preserving the execution semantics of SAWSTP. IV. PARALLEL T RAINING F RAMEWORK A. Hierarchical Swin Parallelism As shown in Fig. 4, TERRA realizes distributed execution of hierarchical Swin Transformer models through SAWSTP. Hierarchical Swin Transformer models combine convolutional down- and up-sampling modules with Swin Transformer blocks that contain window-based multi-head self-attention (W-MSA) and shifted window-based multi-head self-attention (SW-MSA) [12]. Sampling modules operate on spatially contiguous feature maps to preserve local convolutional dependencies, whereas Transformer blocks require window-major token layouts for distributed attention and shifted-window execution.
5
TABLE II C OMPARISON OF MODEL SETTINGS AND PARALLELISM SUPPORT IN ORBIT [8], AERIS [13], AND TERRA. Model setting Model architecture Vision Transformer Pixel-level Swin Transformer Hierarchical Swin Transformer
Framework ORBIT AERIS TERRA
DP
Parallel sampling × × ✓
WP × ✓ ✓
Parallelism support SP TP × ✓ ✓ × ✓ ✓
I/O Topology
PP × ✓ ×
DP ✓ ✓ ✓
FSDP ✓ × ✓
I/O Topology
Transformer Topology Rank 0
Patch Embedding
Rank 1 DMP
Resolution 1.4◦ 0.25◦ 1/12◦
Rank 2
Swin Transformer Blocks
DMP Token Route
Down Blocks
Rank 3
Top Halo
DMP Token Route
Patch Recovery Up Blocks
Parallel Sampling Blocks
Parallel Swin Transformer Blocks ×2
DMP Conv / TConv Stride=2
DMP Conv Stride=1
DMP GN
Block 0 W-MSA
Block 1 SW-MSA
Block 0 MLP
Block 1 MLP
Rank 0 Rank 1 Rank 2 Rank 3
Layernorm Shift Token Route
SiLU
Bottom Halo
Window Attention Shift Token Route
Fig. 4. SAWSTP Training Framework for the hierarchical Swin Transformer.
To overcome this mismatch, SAWSTP employs two stagespecific logical topologies, namely a sampling-aware I/O topology and a multi-level Transformer topology. The two topologies use the same participating ranks but organize them into different communication groups. The I/O topology is built on DMP, which partitions each high-resolution training sample and its corresponding labels into spatially contiguous shards. Each rank therefore loads and processes only the input and label tensors that it owns. This topology preserves the DMP layout through patch embedding, sampling, patch recovery, and loss computation. The Transformer topology remaps the sampled feature maps into window-major layouts for Swin Transformer execution. It factorizes Transformer computation with WP, SP, and TP, which determine complete-window ownership, intra-window sequence partitioning, and operator-level sharding, respectively. FSDP is orthogonal to these parallel dimensions and can shard parameters, gradients, and optimizer states over the combined DP × WP × SP process group. The differentiable DMP token route connects the two topologies by converting between DMP-partitioned and window-major layouts. Within the Transformer topology, the shift token route redistributes tokens for shifted-window attention. During backpropagation, the inverse routes ensure correct gradient propagation.
B. Sampling-Aware I/O topology The I/O topology first pads the input field Xt ∈ RB×H×W ×C to a padded shape of B × Ĥ × Ŵ × C, where Ĥ and Ŵ satisfy the divisibility requirements of patch embedding, sampling modules, and subsequent window formation. It then partitions the padded input into Pg contiguous spatial stripes along the height dimension, where Pg is the number
of ranks in the DMP group. Each rank owns a local tile and directly loads only its corresponding input and label tensors. Given a patch size p, each rank applies patch embedding to its local tile, producing a feature map of shape B× PĤg p × Ŵ p ×d, where d is the embedding dimension. This feature map serves as the input to the hierarchical sampling modules. Downsampling and up-sampling modules use strided convolution (Conv) and transposed convolution (TConv), respectively, with stride α = 2 in this work. Each sampling module also contains residual blocks composed of Conv, Group Normalization (GN), and SiLU operators. Consequently, a downsampling module reduces the local feature-map shape to Ŵ B × αPĤg p × αp × d, while the corresponding up-sampling module restores the spatial resolution. The down-sampled features are subsequently routed to the Transformer blocks, substantially reducing Transformer-stage activation memory. This encoder–decoder sampling design also supports multiscale feature learning, and the evaluation in Fig. 15(a) confirms its benefit to forecasting accuracy. Parallel convolution in sampling modules has been extensively studied in prior training systems [18], [30], [37], [38], [39]. SAWSTP adopts a halo-exchange-based implementation [39] that partitions activations along the height dimension while keeping the Conv, TConv, and GN parameters replicated across DMP ranks. Before each local Conv or TConv operation, neighboring ranks exchange only the boundary rows required by the operator. The communication volume scales with the halo width rather than the full local feature-map size. The halo exchange is differentiable, allowing boundary gradients to be returned to their original ranks during backpropagation.
6
WP Topo(2, 2, 1, 1) (0, 0) (0, 1) (0, 0) (0, 1) WP-x
P2P
Shift Token Route (1, 0) (1, 1) (1, 0) (1, 1)
WP-y
WP-SP Topo(1, 2, 2, 1)
I/O Topology: DMP Stripe Layout
DMP Token Route
(0, 1, 0)
(0, 0, 0) (0, 0)
(0, 1)
(0, 0)
(0, 1)
Shift Token Route
SP: All-to-All
All-to-All
(0, 1, 1)
(0, 0, 1)
(0, 0, 0)
(0, 1, 0)
(0, 0, 1)
(0, 1, 1)
WP-SP-TP Topo(1, 1, 2, 2) TP: All-gather+Reduce-scatter
Color for a complete attention window
(0, 0, 0) (0, 0)
(0, 0, 0, 0)
(0, 0)
(0, 0, 0, 1)
Shift Token Route
SP: All-to-All (0, 0)
(0, 0)
(0, 0, 1)
(0, 0, 1, 0)
(0, 0, 1, 1)
Fig. 5. Multi-level Transformer topology with DMP and shift token routes in SAWSTP.
C. Multi-Level Transformer topology After the sampling modules produce lower-resolution feature maps under the I/O topology, the spatially contiguous DMP-stripe layout must be converted into the window-major layout required by Swin Transformer execution. SAWSTP performs this conversion through the DMP token route. To support different Transformer execution strategies, SAWSTP represents the Transformer stage using a factorized topology Topo(m, n, s, t), where (m, n) defines a two-dimensional WP grid for complete-window ownership, s denotes the SP degree for intra-window sequence partitioning, and t denotes the TP degree for sharding Transformer operators and intermediate activations. Under a selected topology, each Transformer rank is identified by a factorized coordinate (i, j, k, l), where (i, j) specifies the WP coordinate, k identifies the intra-window SP coordinate, and l identifies the TP coordinate. For clarity, Topo(m, n), Topo(m, n, s), and Topo(m, n, s, t) denote pure WP, WP+SP, and WP+SP+TP, respectively. Fig. 5 illustrates how the same DMP-stripe layout is transformed into the window-major layouts required by these Transformer topologies. Each complete attention window is represented by a 2 × 2 block with the same color, while the coordinate labels indicate the ranks responsible for the corresponding distributed window data. The gray boxes show the layouts directly produced by the DMP token route, and the layouts before the gray boxes conceptually show how complete windows are split into SP and TP sub-tiles. Under pure WP, each complete window is assigned to one WP rank, while the shift token route uses point-to-point (P2P) communication to redistribute tokens across WP ranks for shifted-window execution. When SP is enabled, each window is further partitioned along the intra-window sequence dimension, and Ulysses-based all-to-all communication reorganizes these sequence shards around window attention. The Topo(m, n, s, t) extends the WP+SP design of AERIS with FSDP and TP. AERIS-style WP+SP partitions window
activations but does not shard Transformer parameters. AERIS primarily uses PP to reduce parameter-related memory. However, pipeline bubbles are difficult to amortize under the limited global batch sizes of high-resolution Earth forecasting models such as Wenhai. SAWSTP instead applies FSDP over the DP × WP × SP process group. For Transformer blocks with a large hidden dimension d, FSDP must all-gather the full parameters of each wrapped unit before its execution, which can cause OOM failures. SAWSTP therefore introduces Megatron-style TP [10], [36] within each WP–SP group. As shown in Fig. 5, TP further partitions the computation assigned to each SP rank. It uses all-gather to materialize the activations required for a SP rank and reduce-scatter to restore the TP-sharded activation states afterward. Therefore, for a fixed world size, TP further shards Transformer parameters while preserving the per-rank activation layout of AERIS-style WP+SP partitioning. D. Differentiable Token Routes SAWSTP couples a DMP-based I/O topology with a multilevel Transformer topology that integrates WP, SP, and TP. These topologies assign tensor ownership, layouts, and communication groups differently, making it nontrivial to ensure correct token routing in the forward pass and gradient propagation in the backward pass. To address this issue, TERRA indexes both the DMP-stripe and window-major layouts using the same global two-dimensional token grid. The corresponding conversion from DMP-stripe layout to window-major layout is implemented as the DMP token route. After down-sampling, the Transformer-stage token grid has spatial size HT × WT , where HT =
Ĥ , pα
WT =
Ŵ . pα
(2)
The corresponding attention-window grid contains Mh × Mw windows, where Mh = HT /w and Mw = WT /w. Each
7
Fixed
Ragged
Density-aware
SP=2
Rank 0
Rank 1
Rank 2
Rank 3
Padding
Fig. 6. Fixed, ragged, and density-aware window assignment.
Transformer-stage token on the token grid is identified by a global (u, v). Its attention-window coordinate is u coordinate , wv ), and its within-window offset is determined by ( w (u mod w, v mod w). Under the DMP-stripe layout, (u, v) identifies the source rank and local offset of a token in its spatial stripe. Given the selected Topo(m, n, s, t) topology and window-assignment policy, (u, v) determines the owner of its complete attention window, its destination rank, and its local offset in the windowmajor tensor. Tokens with the same destination rank are gathered using torch.index_select in PyTorch [40] and packed into contiguous send buffers. TERRA then exchanges the peer-wise buffers through batched P2P communication. Each destination rank restores received tokens at their destination positions to construct the required window-major tensor. The shift token route uses the same coordinate-based mechanism. Window shifting changes the global coordinate (u, v) of each token, from which TERRA determines its new destination rank and local offset. The corresponding tokens are gathered, communicated, and restored using the same indexed packing procedure. Both routes are implemented as autograd-aware communication primitives. Their backward passes apply the inverse mappings to return gradients to the corresponding source ranks and local offsets. This design allows TERRA to support different Transformer topologies and window-assignment policies and provides the basis for the window-assignment optimizations presented in Section V. V. C OST-AWARE W INDOW A SSIGNMENT A. Ragged Window Assignment The multi-level Transformer topology maps complete attention windows to ranks along the WP dimension. As shown in the left part of Fig. 6, the AERIS-style fixed assignment uses two-dimensional round-robin mapping to distribute the windows of an Mh ×Mw grid across an m×n WP mesh. The illustrated example uses Mh = 9, Mw = 5, and m = n = 2. Fixed assignment provides uniform window ownership only when Mh and Mw are divisible by m and n, respectively. Otherwise, the input spatial dimensions are padded to Ĥ × Ŵ , where H W Ĥ = pαwm, Ŵ = pαwn. (3) pαwm pαwn
This ensures that every WP rank receives the same number of complete windows. However, the additional padded tokens increase activation memory and computation. Moreover, twodimensional round-robin ownership requires distributing attention windows to adjacent WP ranks, which brings substantial P2P communication during shifted-window execution. To address this issue, TERRA instead adopts a ragged Topo(mn, 1) assignment. As shown in the middle part of Fig. 6, it avoids padding introduced for equal window ownership and preserves row-major contiguous ownership. Let M = Mh Mw be the total number of complete windows. After flattening the window grid in row-major order, the M complete windows are indexed from 0 to M − 1. WP rank r, where 0 ≤ r < mn, owns the contiguous window-index range [Lr , Rr ), where (r + 1)M rM , Rr = . (4) Lr = mn mn The ragged assignment is enabled by the DMP token route, which allows each WP rank to receive tokens from the DMP ranks for a different number of complete windows. Thus, every complete window is assigned exactly once, and the window counts of any two ranks differ by at most one. Moreover, only boundary windows whose shifted-window token fragments cross a WP-rank boundary require P2P communication, whereas windows in the interior of each rank’s contiguous range remain local. This substantially reduces the communication volume of shifted-window execution. B. Density-Aware Window Assignment The ragged Topo(mn, 1) assignment is effective when the window grid is dense enough to provide sufficient assignment granularity. As the window size w increases, the number of complete windows decreases, and each complete window becomes a coarse assignment unit. The resulting ragged WP assignment can therefore become imbalanced. As shown in the right part of Fig. 6, assigning ten windows to four ranks with ragged Topo(4, 1) gives two ranks three windows each and the other two ranks two windows each. When the WP group size exceeds the number of complete windows, pureWP assignment can even leave some ranks with no assigned window. SP can mitigate this load imbalance by partitioning each complete attention window across SP ranks. For example, setting s = 2 changes the topology to Topo(2, 1, 2), and the resulting twenty window sub-tiles allow each of the four ranks to process five sub-tiles. However, SP introduces allto-all communication around window attention. This tradeoff motivates TERRA’s density-aware assignment, which extends the ragged WP assignment with SP when the performance benefit of improved assignment granularity covers the additional communication cost. Table III summarizes the communication characteristics of the fixed baseline and the two TERRA assignments. AERISstyle fixed assignment incurs P2P communication during window shifting. Ragged assignment limits this overhead to rankboundary windows. Density-aware assignment preserves this
8
TABLE III C OMMUNICATION CHARACTERISTICS OF WINDOW ASSIGNMENTS . Strategy Communication Fixed Topo(m, n) Two-dimensional WP P2P Ragged Topo(mn, 1) Boundary-only P2P Density-aware Topo(mn/s, 1, s) Boundary-only P2P + SP all-to-all
Algorithm 1 Density-aware window assignment 1: Input: rank count mn for WP and SP 2: Output: selected topology 3: bestTime ← +∞ 4: for each valid divisor s of mn do 5: candidateTopology ← Topo(mn/s, 1, s) 6: candidateTime ← Profile(candidateTopology) 7: if candidateTime < bestTime then 8: bestTime ← candidateTime 9: bestTopology ← candidateTopology 10: end if 11: end for 12: return bestTopology
reduced P2P communication while additionally introducing SP all-to-all communication. Algorithm 1 describes an offline profiling-based strategy for density-aware window assignment. Given mn ranks assigned to the WP and SP dimensions, TERRA enumerates the valid divisors s of mn. For each s, it constructs the corresponding Topo(mn/s, 1, s) candidate, profiles the candidate for several iterations, and selects the topology with the lowest average training-step time. The selected topology is then used throughout the subsequent training steps. For high window density, s = 1 is typically selected because ragged WP already provides sufficient load balance without introducing all-to-all communication. For low window density, a larger s is selected only when its load-balancing benefit outweighs the additional SP communication overhead. VI. M EMORY O RCHESTRATION A. Activation Bottleneck in Finetuning SAWSTP reduces the per-rank memory footprint of hierarchical Swin Transformer training. However, long-lead finetuning remains dominated by activation memory, particularly with small patch sizes. Fig. 7 shows the allocated GPU-memory timelines during the forward (FWD) and backward (BWD) passes of ten-lead rollout finetuning. During FWD, checkpoint boundaries generated at each lead remain resident until their corresponding BWD computations and therefore accumulate across the rollout. During BWD, recomputation of a sampling or Transformer checkpoint unit produces a short-lived local peak. Although numerous memory-optimization techniques based on activation recomputation [19], [20], [21], [22] and activation offloading [23], [24], [25], [26] have been proposed, it remains nontrivial to jointly determine recomputation granularity and offloading decisions for hierarchical rollout finetuning under SAWSTP. Sampling and Transformer checkpoint
units exhibit different checkpoint-boundary tensor sizes and recomputation peaks, while high-resolution input and label tensors further introduce a non-negligible baseline memory footprint. These characteristics require an architecture-aware policy that models rollout-wide tensor lifetimes and satisfies a target GPU-memory budget. TERRA addresses this challenge through Memory Orchestration (MO), a profile-based two-stage policy. MO first constructs an architecture-aware checkpoint-only plan by modeling rollout-wide boundary accumulation and local recomputation peaks. When checkpointing alone cannot satisfy a target GPU-memory budget, MO combines input buffering with selective boundary offloading to meet the budget.
B. Profile-Based Checkpoint Planning The first stage of MO constructs a checkpoint-only policy from a block-wise runtime memory profile under the selected SAWSTP configuration. Inspired by the runtime memory tracer in PatrickStar [31], TERRA records the profile at runtime and visualizes the allocated GPU-memory timeline. It uses torch.cuda.memory_allocated for the allocated-memory timeline and torch.cuda.max_memory_allocated for peak memory. As shown in Fig. 7, the p = 2, DMP = 4, and DP = 2 configuration exhibits distinct forward and backward memory patterns under different checkpointing policies. MO distinguishes sampling and Transformer checkpoint units because they exhibit different boundary activation sizes and recomputation peaks. As shown in the lower-left part of Fig. 4, each sampling module contains several Conv-based residual blocks. For sampling modules, MO considers two checkpoint granularities. At the coarse granularity, D0 treats patch embedding and the subsequent down-sampling module as one checkpoint unit, whereas U0 combines the up-sampling module with patch recovery. At the fine granularity, D1 combines patch embedding with the first stride-two convolution and checkpoints each subsequent residual block independently. U1 applies the analogous fine-grained partitioning to the upsampling module and patch recovery. The Transformer stage contains L = 10 Swin Transformer blocks. MO profiles checkpoint units containing tseg ∈ {1, 2, 3, 4, 5, 10} consecutive blocks. Coarser units retain fewer checkpoint boundaries across the rollout but produce larger peak memory during recomputation, whereas finer units have the opposite tradeoff. Figs. 7 (a) and 7(b) illustrate this tradeoff for D0 /U0 with tseg = 1 and tseg = 3, respectively. In particular, the coarse D0 /U0 units can substantially reduce boundary memory because their internal boundaries correspond to high-resolution feature maps. For each checkpoint unit i, MO profiles its boundary memory Ei and backward peak Pi . A checkpoint-only policy π selects the sampling granularity and Transformer segment length at each rollout lead. MO predicts the resulting peak memory as M (π) = Mbase + max {Ai (π) + Pi (π)} , i
(5)