arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.26294cs.CLcs.DC
收藏

张量与序列并行用于内存高效的Transformer训练与推断

Folding Tensor and Sequence Parallelism for Memory-Efficient Transformer Training & Inference

Zyphra

Vasu Shyam, Anna Golubeva, Quentin Anthony

AI总结:

本文提出TSP并行策略,通过在同一设备轴上融合张量并行与序列并行,减少内存开销,适用于长上下文和内存受限的模型训练,同时可与现有并行方案结合使用。

摘要:

我们提出了张量和序列并行(TSP),一种将张量并行(TP)和序列并行(SP)融合到单一设备轴上的并行执行策略。在传统多维并行布局中,TP将权重分割为片段,SP将token分割为片段,分别减少设备上的参数或激活内存。传统上,每种方案被分配到自己的网格维度。TSP相反地,为每个rank分配权重片段和序列片段,从而在同一设备轴上减少参数和激活内存。我们通过两种运行时调度实现此设计。对于注意力机制,rank遍历广播参数片段并通过序列方式交换键/值来重建上下文。对于门控MLP,权重片段在环中循环,部分输出在本地累积。通过在相同设备上分割权重和激活,TSP以增加的通信量换取减少的内存开销。我们提供了理论上的通信和内存分析,描述了TSP注意力和门控MLP块的实现,并将TSP与TP、SP和TP+SP进行了基准测试。这些结果将TSP定位为长上下文和内存受限模型训练的硬件感知替代方案,并作为与现有并行方案如流水线和专家并行结合使用的可行并行轴。

英文摘要:

We present tensor and sequence parallelism (TSP), a parallel execution strategy that folds tensor parallelism and sequence parallelism onto a single device axis. In conventional multi-dimensional parallelism layouts, tensor parallelism (TP) shards model weights while sequence parallelism (SP) shards tokens, reducing per-device parameter or activation memory, respectively. Traditionally, each scheme is assigned its own mesh dimension. TSP instead assigns each rank both a weight shard and a sequence shard, reducing both parameter and activation memory along the same device axis. We implement this design with two runtime schedules. For attention, ranks iterate over broadcast parameter shards and reconstruct context through a sequence-wise key/value exchange. For gated MLPs, weight shards circulate in a ring while partial outputs accumulate locally. By sharding both weights and activations across the same devices, TSP trades additional communication volume for reduced memory overhead. We provide a theoretical communication and memory analysis, describe our implementation of TSP attention and gated MLP blocks, and benchmark TSP against TP, SP, and TP+SP. These results position TSP as a hardware-aware alternative for long-context and memory-constrained model training, and as a viable axis of parallelism in concert with existing parallelism schemes such as pipeline and expert parallelism for dense and mixture-of-expert models.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑