Document 1M-token training and add a context-parallelism example - #6846
Document 1M-token training and add a context-parallelism example#6846qgallouedec wants to merge 45 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".
2a20c0d to
b4be6ba
Compare
5905aef to
6004d03
Compare
b4be6ba to
c15eb3a
Compare
6004d03 to
97e00f8
Compare
c15eb3a to
f0f2368
Compare
97e00f8 to
34a50e7
Compare
7e70831 to
0042a0f
Compare
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
`accelerate launch` does not read the script's dependency header, so the `transformers>=5.0` it declares is not enforced. On v4 the `rope_parameters` override is dropped silently and the run starts around loss 10.6 instead of 4.4.
Also quote the 1M step time measured on a correctly configured machine.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 78dde06. Configure here.
…rate one huggingface/transformers#48444 landed the same offload behind `gradient_checkpointing_kwargs={"offload": True}`, so the example no longer needs an unreleased accelerate. Measured back to back on one 8xH100 node: 379.76 s/step with transformers, 379.75 s/step with huggingface/accelerate#4175, same loss.
`gradient_checkpointing` is already `True` in `SFTConfig`. Also correct the `logging_steps` default in the comment (10, not 500) and attribute the two version requirements separately.
The sequence parallelism and million-token material was two thirds of `distributing_training`, which is otherwise about multi-GPU and multi-node launching. It gets its own page next to the other how-to guides, and `distributing_training` points at it.
The opening sentence called them the same thing, which the note right below it contradicts: here CP is ring attention on FSDP2 and SP is ALST/Ulysses on DeepSpeed.
There was a problem hiding this comment.
most of this is moved content. I want to re-write the whole section in a follow-up pr

Training on sequences far longer than the usual few thousand tokens:
docs/source/long_context_training.md, a new how-to guide, moved out ofdistributing_training.mdand extended with the configurations I verified and the levers in the order you hit themexamples/sft_qwen3_8b_1m_context/, a runnable example that trains a book-length sequence per step on one 8xH100 nodeMeasured
One 8xH100 node, bf16,
per_device_train_batch_size=1,loss_type="chunked_nll"(the default). Qwen3-8B at 1,048,576 tokens: 380 s/step, 56.2 GB per GPU. Runs end to end, 12 steps, and saves.Depends on
transformers >= 5.16 for gradient checkpointing
offload(huggingface/transformers#48444, merged). Without it Qwen3-8B at 1M does not fit. The example checks the version at startup.Corrections since the first version
The step times I first posted came from machines where the system CUDA shadowed the cuDNN bundled with torch, so torch fell back to FlashAttention and every number was inflated. huggingface/transformers#48163 looked like a 1.7x win there and is now closed: PyTorch already prefers cuDNN on Hopper by itself.
Earlier revisions required huggingface/accelerate#4175 instead. Measured back to back on one node, the two are the same (379.75 s vs 379.76 s), so the example uses the transformers one and needs no unreleased accelerate.