---
title: "Ulysses Sequence Parallelism: Training with Million-Token Contexts"
description: "Ulysses Sequence Parallelism, part of Snowflake's Arctic Long Sequence Training protocol, enables training on contexts of hundreds of thousands to millions of tokens."
url: "https://swe.quest/articles/ulysses-sequence-parallelism-training-with-million-token-contexts-a21775c0b516e85a"
canonical: "https://huggingface.co/blog/ulysses-sp"
source: "Hugging Face"
published: "2026-03-09"
difficulty: "hard"
kind: "How-to"
reading_minutes: 13
tags: ["model-training","llms","distributed-systems","hardware"]
---

# Ulysses Sequence Parallelism: Training with Million-Token Contexts

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2026-03-09, 13 min read, How-to. Original: [https://huggingface.co/blog/ulysses-sp](https://huggingface.co/blog/ulysses-sp)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)

## Prerequisites

- transformer attention
- distributed data parallel training ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- DeepSpeed ZeRO
- collective communication

## Keywords

Ulysses Sequence Parallelism, DeepSpeed, Hugging Face Accelerate, TRL SFTTrainer, Ring Attention, FlashAttention, Arctic Long Sequence Training, Liger-Kernel

## Related posts

- [Accelerate ND-Parallel: A guide to Efficient Multi-GPU Training](https://swe.quest/articles/accelerate-nd-parallel-a-guide-to-efficient-multi-gpu-training-b84f16c2d8888d39.md): Hugging Face · 2025-08-08 · Hard · 18 min read · Model training, Distributed systems, Python
  Accelerate's ParallelismConfig, also exposed through Axolotl config fields, lets you compose data parallelism, FSDP, tensor parallelism and context parallelism in one training setup.
- [Fully Sharded Data Parallel: faster AI training with fewer GPUs](https://swe.quest/articles/fully-sharded-data-parallel-faster-ai-training-with-fewer-gpus-9a4d28846db69a7b.md): Meta Engineering · 2021-07-15 · Hard · 8 min read · Model training, Python
  Fully Sharded Data Parallel (FSDP) shards model parameters, gradients and optimizer states across data-parallel GPU workers.
- [Keep the Tokens Flowing: Lessons from 16 Open-Source RL Libraries](https://swe.quest/articles/keep-the-tokens-flowing-lessons-from-16-open-source-rl-libraries-14bbb97951dedd55.md): Hugging Face · 2026-03-10 · Hard · 45 min read · Model training, Distributed systems, Inference & serving, LLMs
  Async 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.
- [The Technology Behind BLOOM Training](https://swe.quest/articles/the-technology-behind-bloom-training-8acc1cff08e9a54f.md): Hugging Face · 2022-07-14 · Hard · 25 min read · Model training, LLMs, Distributed systems, Hardware
  BLOOM, 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.
- [Scaling LLM Inference: Innovations in Tensor Parallelism, Context Parallelism, and Expert Parallelism](https://swe.quest/articles/scaling-llm-inference-innovations-in-tensor-parallelism-context-parallelism-and-0ffa604a22d7428d.md): Meta Engineering · 2025-10-17 · Hard · 5 min read · Inference & serving, LLMs, Distributed systems, Performance engineering, Hardware
  Meta scales LLM inference with three parallelism techniques aimed at latency targets of under 350ms time-to-first-token and under 25ms per incremental token.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
