Ulysses Sequence Parallelism: Training with Million-Token Contexts
Ulysses Sequence Parallelism, part of Snowflake's Arctic Long Sequence Training protocol, enables training on contexts of hundreds of thousands to millions of tokens. Each GPU holds a shard of the sequence, and all-to-all collectives regroup the data so each GPU computes attention over every position for a subset of heads. That costs O(n·d/P) communication per GPU, versus O(n·d) over P−1 serial hops for Ring Attention. Ulysses is now integrated into Hugging Face Accelerate (ParallelismConfig with a DeepSpeed backend), the Transformers Trainer and TRL's SFTTrainer, which handle dataloader sharding, shifted labels and token-weighted loss aggregation automatically. Practical guidance covers padding to a multiple of sp_size, the num_heads ≥ sp_size constraint, choosing FlashAttention versions, ZeRO-3 offload, expandable_segments, Liger-Kernel, and balancing SP against DP across GPU counts.
Related posts
- Accelerate ND-Parallel: A guide to Efficient Multi-GPU Training
Hugging Face hardMasterAccelerate's ParallelismConfig, also exposed through Axolotl config fields, lets you compose data parallelism, FSDP, tensor parallelism and context parallelism in one training setup. The guide explains how each strategy trades memory for communication. FSDP shards weights, gradients and optimizer states and gathers each layer when needed. Tensor parallelism splits linear layers column-wise then row-wise so only one all-reduce is required, which makes it best kept within a single NVLink node. Context parallelism shards the sequence and uses RingAttention so very long contexts fit in memory. It then covers hybrid combinations such as HSDP, FSDP+TP and FSDP+CP, with guidance on matching each parallelism degree to intra-node versus inter-node bandwidth.
- Fully Sharded Data Parallel: faster AI training with fewer GPUs
Meta Engineering hardMasterFully Sharded Data Parallel (FSDP) shards model parameters, gradients and optimizer states across data-parallel GPU workers. It does this by decomposing DDP's all-reduce into reduce-scatter and all-gather steps, gathering each layer's full weights just in time for the forward and backward passes and then discarding them. It produces results identical to PyTorch DDP, overlaps communication with computation, can offload optimizer state to CPU, and is meant to scale to trillions of parameters. It is available through FairScale, fairseq, VISSL and PyTorch Lightning, with caveats around nested wrapping, consistent weight initialization, optimizer parameter groups, mixed precision and checkpointing.
- Keep the Tokens Flowing: Lessons from 16 Open-Source RL Libraries
Hugging Face hardMasterAsync RL post-training libraries have converged on one architecture: disaggregate inference and training onto separate GPU pools, connect them with a rollout buffer, and push weights asynchronously so generation never stops and training never waits. A survey of 16 open-source libraries (verl, AReaL, SLIME, PRIME-RL, NeMo-RL and others) compares them on seven axes: orchestration, buffer design, weight sync, staleness management, partial rollouts, LoRA support and training parallelism. Ray dominates orchestration, NCCL broadcast is the default weight-transfer method, staleness handling ranges from dropping samples to importance-sampling correction, LoRA support is sparse, and distributed MoE support is emerging as the differentiator. Throughput math shows why this matters, with 32K-token rollouts on a 32B model taking hours per step on one H100. The findings shape TRL's new async trainer, which uses a bounded queue with per-token model versions, packed NCCL weight sync and partial rollout support.
- The Technology Behind BLOOM Training
Hugging Face hardMasterBLOOM, a 176B-parameter multilingual GPT-3-style model, was trained over 3.5 months on 384 A100 80GB GPUs on the Jean Zay supercomputer using Megatron-DeepSpeed's 3D parallelism. ZeRO data parallelism shards parameters, gradients and optimizer states across GPUs. Megatron-LM tensor parallelism splits GEMMs column-wise then row-wise, needing two all-reduces per layer, so it should stay within a single node's fast interconnect. Pipeline parallelism uses micro-batches (chunks/GAS) to shrink the idle bubble, with global batch size computed as mbs*chunks*dp_degree. Hardware, checkpoint sizes (2.3TB full, 329GB bf16 weights) and dataset details are also covered.
- Scaling LLM Inference: Innovations in Tensor Parallelism, Context Parallelism, and Expert Parallelism
Meta Engineering hardMasterMeta scales LLM inference with three parallelism techniques aimed at latency targets of under 350ms time-to-first-token and under 25ms per incremental token. For tensor parallelism, custom direct-data-access allreduce algorithms (flat and tree) cut communication latency, beating RCCL by 10-50% on decode and bringing AMD MI300X to parity with H100. Context parallelism via ring attention, in Pass-KV and Pass-Q variants, enables 1M-token prefill in under a minute on one H100 host and near-linear scaling for Llama 3 405B (128K tokens in 3.8s over 16 nodes). Expert parallelism for MoE models relies on all-to-all token exchange that costs 10-30% of latency, and Meta is moving toward N-D parallelism with disaggregated prefill and decode tiers on heterogeneous hardware.