Repository navigation
[doc][train] Style pass on the Ray Train overview and framework pages - #66888
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Ray Train documentation across several files to improve readability, style consistency, and formatting. The review feedback highlights several areas for correction: correcting inaccurate performance parity claims for PyTorch and TensorFlow benchmarks to state 'comparable throughput' instead; updating the TensorFlow-Keras checkpointing documentation to accurately reflect that the entire model is saved rather than just weights; adding a missing import json statement in a code example to prevent a NameError; and updating outdated text regarding the deprecation and removal of AccelerateTrainer.
dstrodtman
left a comment
There was a problem hiding this comment.
Meaning check on the style edits. I compared all 135 edited blocks against their before text and the Ray source at this commit. 39 were mechanically cosmetic, and 90 of the 96 that needed judgment kept their meaning, so the rest of the diff is safe to skim.
Commit 0efb9eb already fixes the 6 edits that changed a claim:
benchmarks.md: both parity sentences say "These benchmarks show that the two frameworks perform similarly (within N%)" again. The flat "within N% of each other" forced a two-sided reading that the tables contradict. Whether the figures hold at all is still open in the Gemini threads.overview.md: "To use Ray Train effectively, understand the following four main concepts" restores both qualifiers.distributed-tensorflow-keras.md: three hedges are restored: "consider using Ray Data", "you might want to convert", and "consider implementing a custom training loop".
Removed on purpose: "Ray Train is the simplest solution for distributed training" on the landing page. It's an unmeasured superlative, and nothing else in doc/source depends on it.
The Gemini threads already cover the benchmark percentages, "weights but not models", the missing import json, and the stale AccelerateTrainer deprecation note. One more pre-existing question is inline.
Review drafted with AI assistance (Claude Code): one reviewer agent per file compared each before/after edit against the Ray source at this commit.
…t enforced) Add Train/Terms.yml and Train/Capitalization.yml, a path-scoped [doc/source/train/**] section in .vale.ini, and a "Writing Ray Train docs" section in writing-style.md. Grow the Train and General accept lists from the Train Vale.Spelling baseline, add a WandB -> W&B swap to the shared Ray/Brands.yml, and tighten the RLlib accept entries for PyTorch and TensorFlow, whose bracket-class regexes accepted Pytorch and Tensorflow repo-wide. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
## Why are these changes needed? This PR applies the Ray writing-style guide and its new "Writing Ray Train docs" terms table (#66885) to the Ray Train user guides. It's one of three style-pass PRs for Ray Train, split by section. **Stacked on #66885.** Retarget it to `master` once that PR and #66883 merge. ## What changed - **Trainer and term casing:** "trainer" is lowercase in prose, with class names in code style. "Fault tolerance", "local mode", and "training worker" follow the terms table. - **Headings:** sentence case, imperatives for task headings ("Save checkpoints during training"), question headings for conceptual sections in elastic training, and "Label: Title" in place of parenthetical prefixes, such as "Deprecated: Set the local staging directory" and "PyTorch: Set the communication backend". - **Voice and wording:** removed first-person plural, passive, "will", "allows/enables", filler, and Latin abbreviations. Benefits lists in fault tolerance, checkpoints, persistent storage, and hyperparameter optimization are now prose. - **Structure:** ordered lists use `1.`, bold "Step N:" and "Option N:" pseudo-headings become headings, lead-ins, or rubrics, and a resource-leak caveat in asynchronous validation moves into a `caution`. - **Unicode punctuation:** curly quotes and em dashes are ASCII now. That includes a `param_space={...}` inline code sample that used curly quotes. - **Old URL fragments keep working.** Each reworded heading with a specific old slug gets a MyST label named after that slug, such as `(saving-checkpoints-during-training)=`. Generic two-word slugs such as `#getting-started` and `#viewing-metrics` don't get labels, because a site-wide label would claim the name. Nothing in the repo links to those. - **Fixes a broken link target:** `python/ray/air/config.py` and `python/ray/tune/tune.py` link to `persistent-storage.html#setting-the-local-staging-directory`. That fragment broke when the heading gained its "(Deprecated)" prefix. A label restores it. - **New `{rubric}` directives** replace two bold option labels inside a Transformers tab in `checkpoints.md`. Please check that they render in the preview. ## Questions for maintainers These are pre-existing claims that the pass kept as written: - `checkpoints.md`: "you can't use a temporary directory that Ray Train might delete before the upload finishes, for example from `tempfile.TemporaryDirectory`". Python deletes a `TemporaryDirectory` when its context exits. Is Ray Train the right actor, or does this mean `delete_local_checkpoint_after_upload`? - `fault-tolerance.md`: does Ray Train V2 still need `RAY_TRAIN_V2_ENABLED=1` "starting in Ray 2.43" on master? - `persistent-storage.md`: "In the preceding example, the training loop saves some artifacts to the worker's current working directory." No preceding example does that. - `hyperparameter-optimization.md`: "The next section on fault tolerance describes this further." That section doesn't mention driver snapshots to `storage_path`. - `local-mode.md`: the prose says to change only `num_workers`, but the diff also adds `use_gpu=True`. Also, "master node" matches torchrun's `MASTER_ADDR`. Keep it or write "head node"? - `elastic-training.md`: "Without a retry limit, the run exits on the first such failure" describes the `max_failures` default. Should it say "without retries"? - `using-accelerators.md`: "Get the associated devices with `get_device`" uses a plural for a function that returns one device. ## Duplicate check No open PR restyles these pages. I searched open `ray-project/ray` PRs that touch `doc/source/train/`. The only hits are #66883 (the slug renames this stack builds on) and #66885 (the Train Vale rules). ## Testing ```bash vale --output=line doc/source/train/<changed files> # from the repo root, with #66885's .vale.ini codespell <changed files> pre-commit run --files <changed files> ``` - Vale leaves only intentional alerts: acronym definitions (Google.Parens, Google.Acronyms), passives with no actor to name, "will be removed in a future release", "currently" on a temporary limitation, and spelling false positives such as "nullable", "autoencoder", and "prefetches". - A per-file check against a pre-edit snapshot confirms that code blocks, `{ref}`/`{py:*}` role targets, and URLs are unchanged. The only added `(label)=` anchors keep old heading fragments working. - `pre-commit` passed, but only the master-branch link check applied. No hook lints Markdown under `doc/source/train/`, so the hook run doesn't validate the prose. - A meaning check compared every edited block with its before text and the Ray source. A follow-up commit restores the few edits that changed a claim, and the review comment on this PR lists them. - Prose-only change: no library tests run. The Read the Docs preview is the build check. AI assistance (Claude Code) drafted these edits and ran the meaning check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Apply the Ray writing-style guide and the Ray Train terms table to the Train landing page, overview, benchmarks, and the DeepSpeed, Horovod, Hugging Face Accelerate, and TensorFlow and Keras guides. Lowercase "trainer" in prose and put class names in code style, use sentence-case headings and sidebar titles, replace first-person plural and passive constructions, and drop filler and marketing qualifiers. Keep the old URL fragment for the one reworded DeepSpeed heading. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
A review of the style-pass diff for meaning changes found edits that strengthened a recommendation, dropped a hedge or qualifier, or narrowed an ambiguous referent. Restore the original strength of each claim while keeping the style fixes around it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
The style pass turned the bold "Step 1" and "Step 2" labels into H3 headings, which put the threading warning inside the Step 2 section. The warning covers the whole training function, so place it before Step 1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
4f9e442 to
942ba25
Compare
6a8a91b to
03fd844
Compare
#66894) ## Why are these changes needed? The Ray Train style-pass PRs, #66886, #66887, and #66888, flagged pre-existing problems in the pages they edited and left them as written, because a style pass shouldn't change claims. This PR fixes the ones that don't change a technical claim. Each fix is settled by the page itself, its own code sample, or its own tables. **Stacked on #66886, #66887, and #66888.** Those three PRs are siblings on `doc-1549-train-vale-style`, #66885's branch, so this PR targets that branch and starts from a merge of all three. Until they merge, the diff here includes their changes. Review only the three commits after the merge commit: - `ea20d30` getting-started guides - `af794c9` overview, framework, and example pages - `67b7b59` user guides Once the style PRs land, I'll rebase onto `master` and retarget there. ### Getting-started guides - Eight numbered lists describe components, parameters, or what a function does, not steps. They're now bullets, as the bot review on #66886 suggested: the three-component lists in the PyTorch, JAX, LightGBM, Transformers, and XGBoost guides, the `prepare_model` and `prepare_data_loader` lists, and the LightGBM `ScalingConfig` parameters. The intro lists that run from "Configure..." to "Launch..." are real sequences and stay numbered. - `getting-started-jax.md`: "PodSlices" is "Pod slices", Google's spelling, in the body and the front-matter description. ### Overview, framework, and example pages - `benchmarks.md`: "perform similarly (within 2.5%)" and "(within 1%)" are false as two-sided bounds. The page's own tables show a 9.5% gap in the PyTorch 16-worker CPU row and 4.3% in the TensorFlow one, both with Ray Train faster. The sentences now say what the tables show: Ray Train is at most 2.5% (PyTorch) and 1% (TensorFlow) slower, and faster in the CPU rows named. - `distributed-tensorflow-keras.md`: "saving model weights but not models" contradicts the sample, which calls `model.save(... "model.keras")` and stores the epoch. The load sample calls `json.dump` without importing `json`, which fails when a reader copies the block alone. - `deepspeed.md`: the `:skipif: True` skeleton used `tokenized_datasets`, `collate_fn`, `num_epochs`, `loss`, and `ray` without defining or importing them, while it defined `train_dataset` and never used it. It now passes `train_dataset` and declares the placeholders the same way it already declares `model = ...`. The runnable versions are literal-included from tested files in `python/ray/train/examples/deepspeed/`. - `examples/lightning/lightning-cola-advanced.ipynb`: "this examples uses" typo, flagged on #66883. The matching "with with" typo in the vicuna notebook isn't fixed here, because #66892 deletes that notebook. ### User guides - `persistent-storage.md`: "In the preceding example, the training loop saves some artifacts to the worker's current working directory." No preceding example does that. - `hyperparameter-optimization.md`: "The next section on fault tolerance describes this further." The next section doesn't cover driver snapshots. The link now points to the driver fault tolerance section of the fault tolerance guide, which does. - `local-mode.md`: the prose said to change only `num_workers`, but the sample's diff also sets `use_gpu=True`. "Master node" stays: the section runs `torchrun` without a Ray cluster, so "head node" would mislead. - `using-accelerators.md`: `get_device` returns one device. - `data-loading-preprocessing.md`: "Ray Data splits all datasets" becomes "Ray Train splits", matching the same page's own statement that Ray Train splits all datasets with `Dataset.streaming_split` by default. Two code comments change to match. Corrections that need Ray Train engineering to confirm are in #66895, stacked on this one. ## Related issue number None. Not a duplicate: I searched open PRs touching `doc/source/train/`. The open PRs there are this stack (#66883, #66885, #66886, #66887, #66888) and the example cleanups (#66892, #66893), which don't touch these lines. ## Checks - Docs-only. The code edits are in a `:skipif: True` skeleton, an untested sample block, and code comments. - `vale` on the changed files from the repo root: alerts only removed, none added. - `codespell` on the changed files: clean. - `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the changed files: clean. - The notebook still parses as JSON. - Full `-W` doc build: relying on the Read the Docs preview. AI assistance (Claude Code) was used to research and draft these edits. Draft until the submitter has reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…#66895) ## Why are these changes needed? The Ray Train style-pass PRs, #66886, #66887, and #66888, flagged pre-existing claims that looked inconsistent with the source and kept them as written. This PR corrects the ones that current source settles. Each claim was already in the docs before the style pass, so none of them is drift that the style pass introduced. It's stacked on #66894, the mechanical fixes for the same pages, which builds on the three style PRs. The diff against #66894's branch is one commit, `6c6db91`. **For Ray Train reviewers:** these corrections change what the docs say, so please confirm them. Each item cites the source it rests on. Items marked **confirm** carry a specific point to check. ### Getting-started guides - `getting-started-jax.md`: "By default, this configuration requests one GPU per worker." `use_gpu` defaults to `False` (`python/ray/train/v2/api/config.py`). One GPU per worker is what `use_gpu=True` gives you when `resources_per_worker` isn't set (`_resources_per_worker_not_none` in `python/ray/air/config.py`). - `getting-started-transformers.md`: `prepare_trainer` doesn't validate configurations (`python/ray/train/huggingface/transformers/_transformers_utils.py`). It swaps in Ray Data-aware dataloaders and records a usage tag, so "validate its configurations" goes. - `getting-started-pytorch-lightning.md`: the strategy classes accept their base classes' arguments, but the `RayDDPStrategy` docstring says `process_group_backend`, `timeout`, and `start_method` are disabled and belong in `TorchConfig` (`python/ray/train/lightning/_lightning_utils.py`). The sentence now says so. - `getting-started-pytorch-lightning.md`: CI tests `pytorch-lightning==1.8.6` in the Lightning 1.x lane (`python/requirements/ml/lightning1.txt`, `.buildkite/ml.rayci.yml`) and `2.6.1` in the main ML lanes (`python/requirements_compiled.txt`). Nothing installs 1.6.5 or 2.1.2. The minimum, `>=1.6.5`, stays as written. Whether to raise it is a separate question for the Train team. ### User guides - `checkpoints.md`: Python, not Ray Train, deletes a `tempfile.TemporaryDirectory` when its `with` block exits, which can happen before an async upload finishes. Ray Train deletes the local directory only after the upload, when `delete_local_checkpoint_after_upload` is set (`_upload_checkpoint` in `python/ray/train/v2/_internal/execution/context.py`). The sentence names the right actor and points out that the page's sample uses `tempfile.mkdtemp`. - `fault-tolerance.md`, `hyperparameter-optimization.md`, and `api/api.md`: Ray Train V2 is the default starting in Ray 2.51. `is_v2_enabled()` defaults `RAY_TRAIN_V2_ENABLED` to `True` (`python/ray/train/v2/_internal/constants.py`) since #57857, which `ray-2.51.0` contains and `ray-2.50.0` doesn't. The intro notes and the "Enable `RAY_TRAIN_V2_ENABLED=1`" migration steps now scope the variable to Ray 2.43 through 2.50. Whether to drop these notes entirely is a scope decision for the Train team. - `elastic-training.md`: "Without a retry limit, the run exits on the first such failure," where "such failures" includes node preemption. `DefaultFailurePolicy` (`python/ray/train/v2/_internal/execution/failure_handling/default.py`) charges preemptions to `max_preemption_failures`, which defaults to `-1`, unlimited (`FailureConfig` in `python/ray/train/v2/api/config.py`). Other worker failures count against `max_failures`, which defaults to 0. The prose and the sample's comment now say so, and the sample's emphasized line moves down one to stay on `run_config`. **Confirm** node loss: a failure counts as a preemption only when `RayActorError.preempted` is set, which needs drain information, so an unannounced node loss should count against `max_failures`. - `results.md`: "Ray Train stores all training results, including reported metrics" contradicts the note at the top of the same page. In V2, the report handler keeps only reports that carry a checkpoint (`python/ray/train/v2/_internal/execution/checkpoint/report_handler.py`). The sentence now says Ray Train stores checkpoints and the metrics attached to them. - `asynchronous-validation.md`: worker 0's return value is rejected with a `ValueError` if `contains_tensor(result)` is true (`python/ray/train/v2/_internal/execution/worker_group/worker.py`). That check inspects nested containers, so "can't contain" is more accurate than "can't be". "Must be Python-based" overstated it. The sentence now suggests converting with `.item()`, as the page's sample does. ### Framework pages - `huggingface-accelerate.md`: "the plan is to deprecate `AccelerateTrainer` in Ray 2.8" is stale. #40274 deprecated it in 2.8.0, and #41276 removed it in 2.9.0. Whether to keep the migration section at all is a scope decision for the Train team. - `distributed-tensorflow-keras.md`: `train.report` doesn't save checkpoint state "on the trainer, where you ran your Python script". Workers copy checkpoint files to the configured storage path (`persist_current_checkpoint` in `python/ray/train/v2/_internal/execution/storage.py`, called from `_upload_checkpoint`). The sentence now says so and links the persistent storage guide. ## Related issue number None. Not a duplicate: I searched open PRs touching `doc/source/train/`. The open PRs there are this stack and the example cleanups (#66892, #66893), which don't touch these lines. Questions from the style pass that need a Train decision rather than a source check aren't in this PR. Examples are whether Lightning's `AsyncCheckpointIO` is incompatible in every upload mode, whether the PyTorch and TensorFlow parity benchmarks should be rerun or retired, and when to drop the V2 opt-in and `AccelerateTrainer` migration notes. They're tracked separately for Ray Train engineering. ## Checks - Docs-only: every change is in a `.md` file under `doc/source/train/`, so no library tests run. The one sample edit, a code comment in `elastic-training.md`, is in an untested `code-block`. - Every cited claim was checked against the source at this branch's base. - `vale` on the changed files from the repo root: alerts only removed, none added. - `codespell` on the changed files: clean. - `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the changed files: clean. - Full `-W` doc build: relying on the Read the Docs preview. AI assistance (Claude Code) was used to research and draft these edits. Draft until the submitter has reviewed every changed line and a Ray Train reviewer has confirmed the claims. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Why are these changes needed?
This PR applies the Ray writing-style guide and its new "Writing Ray Train docs" terms table (#66885) to the Ray Train landing page, overview, benchmarks, and the DeepSpeed, Horovod, Hugging Face Accelerate, and TensorFlow and Keras guides. It's one of three style-pass PRs for Ray Train, split by section. The getting-started guides and the user guides follow in their own PRs.
Stacked on #66885. Retarget it to
masteronce that PR and #66883 merge.What changed
TorchTrainerandTensorflowTrainer.overview.mddefines the concept, so it changes to match the terms table.deepspeed.md#benefits-of-using-ray-train-with-deepspeedstays valid through a label.Questions for maintainers
These are pre-existing claims that the pass didn't change:
benchmarks.md: the text says PyTorch and Ray Train perform "within 2.5%" of each other, but the 16-worker CPU row shows 430.88 s versus 475.97 s, about 9.5%. The TensorFlow "within 1%" claim is about 4.3% on its 16-worker row.huggingface-accelerate.md: "the plan is to deprecateAccelerateTrainerin Ray 2.8" is stale.AccelerateTrainerno longer exists inpython/ray. What should the migration section say?distributed-tensorflow-keras.md: the checkpointing text says Ray Train saves "model weights but not models", but both examples callmodel.save(... "model.keras"). The load example also callsjson.dumpwithout importingjson.Duplicate check
No open PR restyles these pages. I searched open
ray-project/rayPRs that touchdoc/source/train/. The only hits are #66883 (the slug renames this stack builds on) and #66885 (the Train Vale rules).Testing
{ref}/{py:*}role targets, and URLs are unchanged. The only added(label)=anchors keep old heading fragments working.pre-commitpassed, but only the master-branch link check applied. No hook lints Markdown underdoc/source/train/, so the hook run doesn't validate the prose.AI assistance (Claude Code) drafted these edits and ran the meaning check.
🤖 Generated with Claude Code