[WIP] Document 1M-token training and add a context-parallelism example - #6846
Open
qgallouedec wants to merge 21 commits into
Open
[WIP] Document 1M-token training and add a context-parallelism example#6846qgallouedec wants to merge 21 commits into
qgallouedec wants to merge 21 commits into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bae6acb881
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
qgallouedec
force-pushed
the
reorg-examples
branch
from
August 22, 2026 19:02
2a20c0d to
b4be6ba
Compare
qgallouedec
force-pushed
the
long-context-example
branch
from
August 22, 2026 19:02
5905aef to
6004d03
Compare
qgallouedec
force-pushed
the
reorg-examples
branch
from
August 24, 2026 12:29
b4be6ba to
c15eb3a
Compare
qgallouedec
force-pushed
the
long-context-example
branch
from
August 24, 2026 12:29
6004d03 to
97e00f8
Compare
qgallouedec
force-pushed
the
reorg-examples
branch
from
August 24, 2026 14:38
c15eb3a to
f0f2368
Compare
qgallouedec
force-pushed
the
long-context-example
branch
from
August 24, 2026 14:38
97e00f8 to
34a50e7
Compare
qgallouedec
force-pushed
the
reorg-examples
branch
from
August 24, 2026 16:25
7e70831 to
0042a0f
Compare
qgallouedec
force-pushed
the
long-context-example
branch
from
August 24, 2026 16:25
34a50e7 to
581e0b8
Compare
- One folder per example, named method + task (grpo_wordle, sft_gpt_oss, ...); each folder holds everything the example needs (scripts, notebooks, prompts, chat templates, eval code) - Split the openenv, vlm, and ppo buckets into per-example folders - Drop thin single-trainer example scripts, redundant with trl/scripts (CLI) and the runnable snippets in each trainer's doc page - Drop orphaned examples/cli_configs - Rewrite example_overview.md as a single index of examples; rewire all doc links, Colab badges, and the harbor runtime path strings
Suggested by @sergiopaniego in review.
The reorg removed the Scripts / OpenEnv Scripts / OpenEnv Notebooks sections; jobs_training.md and openenv.md still linked to their anchors.
The reorg renamed folders but kept legacy file names (sft_qwen_vl.ipynb under sft_qwen3_vl/, openenv_sudoku_grpo.ipynb, grpo_trl_lora_qlora.ipynb, *_vlm.py, bare ppo.py/rloo.py/gspo.py). Every folder's main entry is now examples/<name>/<name>.py or .ipynb; variant and helper files keep their suffixed names. All Colab badges, doc links, and docstring run commands updated in the same sweep.
Deleting examples/scripts/gold.py removed text-mode GOLD's only end-to-end recipe (there is no trl gold CLI). It comes back as examples/gold_chatbot_arena/, with its doc section and Index row. The online DPO benchmark blocks still invoke the deleted examples/scripts/online_dpo.py; the prose now says to run them from a v1.10.0 checkout.
- openenv.md: enumerate the 8 ready-to-use OpenEnv examples instead of pointing at the generic Index - jobs_training.md: say which Index entries are uv-submittable, and stop calling trl/scripts/sft.py an example script - add the missing run-command docstrings (grpo_2048, ppo_sentiment, ppo_tldr) and drop rloo_math's pip line that disagreed with its script header - examples/README.md: defer the layout description to the docs page instead of duplicating it - distillation_trainer.md: the section documents the CLI, not an example script - drop the stale examples/notebooks/wandb/ gitignore entry - add a test asserting the example_overview Index stays in sync with the examples/ folders
… config beside it
qgallouedec
force-pushed
the
reorg-examples
branch
from
August 24, 2026 19:18
b153620 to
62dd7aa
Compare
qgallouedec
force-pushed
the
long-context-example
branch
from
August 24, 2026 19:18
581e0b8 to
0206ec1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two things, both about training on sequences far longer than the usual few thousand tokens:
docs/source/distributing_training.md, with the configurations I verified and the levers in the order you hit them;examples/sft_long_context/, a runnable example that trains a book-length sequence per step on one 8xH100 node, plusexamples/accelerate_configs/context_parallel_8gpu.yaml.Measured
One 8xH100 node, bf16,
per_device_train_batch_size=1,loss_type="chunked_nll"(the default):Context length scales with node count (Qwen3-8B: 1M on 1 node at 364 s, 2M on 2 nodes at 696 s, 4M on 4 nodes at 1346 s), because each GPU keeps the same shard of the sequence.
It is real training, not just "it fits": Qwen3-30B-A3B with YaRN x32 on PG-19 books at 1M context goes from loss 4.88 to 2.37 in six steps.
Assumptions
Everything here is written as if the rest of the series has landed. Each of these is a separate PR, and the text or the example changes if one of them does not merge:
activation_checkpointing_offloadcontext_parallel_8gpu.yamlsetsfsdp_activation_checkpointing_offload: true; the guide lists it as lever 3SFTTrainersubclass wrappingtraining_stepinsdpa_kernel([SDPBackend.CUDNN_ATTENTION], set_priority=True)— covering the backward too, since checkpoint recompute must pick the same backend — and every step time above is ~1.7x largercp-eval-loss-scaling— apply CP to the evaluation patheval_lossmultiplied bycp_sizeTwo more that are not assumptions, just constraints of what exists today, both stated in the example:
Note
Low Risk
Documentation and example scripts only; no trainer or library behavior changes in this diff.
Overview
Adds a Training at 1M tokens and beyond section to the distributed-training guide: verified step-time and memory tables (up to 4M on one node, multi-node scaling), ordered memory/speed levers (
chunked_nll, FSDP activation offload, CP alltoall + bf16 merge, param offload, MLP sequence tiling, YaRN viarope_parameters), optional selective checkpointing that keeps attention outputs, and explicit CP limits (full causal attention only; no packing).Ships a runnable Qwen3-8B @ 1,048,576 tokens example under
examples/sft_qwen_3_8_1M_context/with an 8-GPU FSDP2 context-parallel Accelerate config (activation checkpointing + host offload), PG-19 concatenation (notpacking=True), and Transformers v5 RoPE overrides.Reviewed by Cursor Bugbot for commit 3132df9. Bugbot is set up for automated code reviews on this repo. Configure here.