Repository navigation
[data][llm] Promote max_tasks_in_flight_per_actor to a first-class config field and adjust defaults - #63214
Conversation
Signed-off-by: Jeffrey Wang <[email protected]>
max_tasks_in_flight_per_actor to a first-class config field and adjust defaults
There was a problem hiding this comment.
Code Review
This pull request promotes max_tasks_in_flight_per_actor from an experimental configuration to a top-level field in OfflineProcessorConfig and its subclasses. It introduces deprecation warnings for the experimental key and implements a resolution strategy that defaults to a calculated value based on max_concurrent_batches. Feedback identifies a potential type mismatch where a float could be assigned to an integer field when bypassing Pydantic validation, suggesting an explicit integer cast to ensure compatibility with Ray Data's actor pool.
| * DEFAULT_ACTOR_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTOR, | ||
| ) | ||
| # Bypass `validate_assignment=True` so we don't re-fire the deprecation warning | ||
| object.__setattr__(self, "max_tasks_in_flight_per_actor", resolved) |
There was a problem hiding this comment.
The resolved value for max_tasks_in_flight_per_actor can be a float, particularly when calculated using DEFAULT_ACTOR_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTOR, which is defined as a float. The max_tasks_in_flight_per_actor field is typed as Optional[int], but using object.__setattr__ bypasses Pydantic's type coercion. This could result in a float value being passed to ray.data.ActorPoolStrategy, which expects an integer and may lead to unexpected behavior or a runtime error.
To ensure an integer is always assigned, the resolved value should be explicitly cast to int. This would also align with the original logic in Ray Data's actor pool, which performs this integer conversion.
| object.__setattr__(self, "max_tasks_in_flight_per_actor", resolved) | |
| object.__setattr__(self, "max_tasks_in_flight_per_actor", int(resolved)) |
Signed-off-by: Jeffrey Wang <[email protected]>
Aydin-ab
left a comment
There was a problem hiding this comment.
making a bit more explicit in the doc that it's 2 * max_concurrent_batches
kouroshHakha
left a comment
There was a problem hiding this comment.
The approach is sound — using a Pydantic mode="after" validator to eagerly resolve the None sentinel is clean, and the resolution order (explicit > experimental > formula) is implemented correctly. The behavioral no-op for default users (8×2=16) is a good property.
Note
This review was co-written with AI assistance (Claude Code).
Signed-off-by: Jeffrey Wang <[email protected]>
…config field and adjust defaults (ray-project#63214) Signed-off-by: Jeffrey Wang <[email protected]>
…config field and adjust defaults (ray-project#63214) Signed-off-by: Jeffrey Wang <[email protected]> Signed-off-by: Alexandr Plashchinsky <[email protected]>
…d the pin_memory condition - The vLLM compatibility table covers nightly and 2.50 through 2.58, not every release, so the lead-in now says recent Ray releases. - max_tasks_in_flight_per_actor defaults to None, which resolves to DataContext.max_tasks_in_flight_per_actor or 2 * max_concurrent_batches. #63214 replaced the fixed default of 16. - The iter_torch_batches docstring applies pin_memory only when the collate output is a TensorBatchType. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
…d the pin_memory condition - The vLLM compatibility table covers nightly and 2.50 through 2.58, not every release, so the lead-in now says recent Ray releases. - max_tasks_in_flight_per_actor defaults to None, which resolves to DataContext.max_tasks_in_flight_per_actor or 2 * max_concurrent_batches. #63214 replaced the fixed default of 16. - The iter_torch_batches docstring applies pin_memory only when the collate output is a TensorBatchType. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
## Description Style and grammar pass on six Ray Data modality guides against Ray's [writing-style guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html): `working-with-images.md`, `working-with-text.md`, `working-with-tensors.md`, `working-with-pytorch.md`, `working-with-llms.md`, and `scaling-collation-functions.md`. Prose only, apart from one code fix: the PyTorch migration example now imports `transforms`, which it uses. No other code, testcode, literalinclude blocks, code comments, or URLs changed. Stacked on #66420. Review and merge that stack first. This branch targets `doc-1524-data-style-ops`. It's the fourth of five PRs that apply the same pass to the top-level Ray Data pages. ### All six pages - Rewords task headings as imperatives, such as "Read images" and "Scale to multiple GPUs", and conceptual headings as questions, such as "How does the processor pipeline work?". Each reworded heading keeps its old URL fragment through an explicit label named after the old slug. Headings that already had a matching label need no new one. One old fragment can't be kept: `working-with-llms#cross-node-parallelism`, because `serve/llm/user-guides/cross-node-parallelism.md` already defines that label name. Nothing in the repo links to it. Three more old fragments are dropped on purpose because their names are single words: `#embeddings`, `#classification`, and `#multimodality`. Sphinx labels are global, so a label with a generic name would claim it for the whole site and break the build of any later page that defines it. Those headings keep their existing specific labels, such as `embedding_models`. - Uses second person, active voice, present tense, and "such as" for examples. Recasts "lets", "allows", and "enables". - Removes em dashes, parentheticals, first-person plural, "will", and filler. - Fixes list lead-ins and punctuation, and uses `1.` for ordered lists. Opening lists of section links stay, because they're the pages' only links to their sections. - Keeps `{ref}` link text that quotes another page's title in that title's words, such as "Saving Data API". ### Page-specific changes - `working-with-llms.md`: Spells "Hugging Face" consistently in prose, defines "VLM" once, and turns five bold paragraph labels into lead-in sentences. Gives the real default for `max_tasks_in_flight_per_actor`: it resolves to `DataContext.max_tasks_in_flight_per_actor` or `2 * max_concurrent_batches`, which #63214 introduced in place of the fixed 16. Scopes the vLLM table's lead-in to recent releases, since the table doesn't cover every one. The "Known issue" admonition keeps its title and gains the `warning` class, because the issue raises an `ImportError`. It also moves a bold "Usage data collection" label into a `note`. - `working-with-pytorch.md`: Replaces the legacy "Ray Datasets" product name, recasts the migration section into imperatives, says `pin_memory` applies only when the collate function returns tensors, as its docstring does, and puts the `map` and `map_batches` tab titles in inline code. - `scaling-collation-functions.md`: Fixes the "improving better" typo, and turns the two bold table captions into `list-table` titles. Every number and instance type is unchanged. - `working-with-images.md` and `working-with-text.md`: Put the default column names `image` and `text` in inline code. - `working-with-tensors.md`: Changes the H1 from "Working with Tensors / NumPy" to "Working with tensors and NumPy". ### Other files - Updates link text in `train/user-guides/data-loading-preprocessing.rst` that quotes the old headings, and fixes its "Pytorch" casing. ## Questions for reviewers Apart from the `max_tasks_in_flight_per_actor` default, this pass kept the scope of every claim. These points need a Ray Data maintainer. Each one predates this PR. - **Example variable (`scaling-collation-functions.md`):** the "after" example reassigns `dataset` but passes `train_dataset` to the trainer. - **`torchaudio` (`working-with-pytorch.md`):** the transforms section names `torchaudio`, but it has no `torchaudio` example. - **Custom tokenizers (`working-with-llms.md`):** are `mistral`, `deepseek_v32`, and `grok2` `tokenizer_mode` values? If so, the sentence can name them that way instead of in parentheses. The page says "DeepSeek-V3", but the example file's docstring says "DeepSeek-V3.2". - **`batch_size="auto"` (`working-with-tensors.md`):** the page recommends `batch_size="auto"` but doesn't say that `map_batches` requires an explicit integer `batch_size` when `num_gpus` is set (`dataset.py`). - **Note placement (`working-with-llms.md`):** the usage-data note sits under the NIXL troubleshooting heading. ## Verification - A follow-up commit applies source-verified fixes from automated review. It scopes the collate batch-alignment note to output blocks, because the example repartitions only after `map_batches`. It mentions the alpha `pin_memory` argument of `iter_torch_batches`, imports `transforms` in the PyTorch migration example, and describes what the tensors page covers instead of limitations it doesn't list. It also refers to the value of `max_concurrent_batches` rather than a batch size. - A meaning-diff review compared every before-and-after pair. A conservative filter cleared 37 blocks as cosmetic, and reviewers checked the remaining blocks against the pre-edit text and the Ray source. Two drifted and are fixed in a follow-up commit: a new lead-in implied that Ray Data LLM handles row, actor, and pipeline failures automatically, and the Office Hours item had lost "new". The reviewers confirmed the TP*PP gloss against `placement.py` and `vllm_engine_stage.py`, and that the Hugging Face processor, not Ray, resizes image inputs. - `vale` with Vale 3.12, run from the repo root: no warning- or error-level alerts on the six pages. - `codespell`: no hits. - The pre-commit hooks passed. - A structural check against each pre-edit file confirmed the code-fence count, role targets, and URLs are unchanged. The only anchor changes are the added old-slug labels. None were removed. - Before adding each label, I grepped `doc/source` for the label name in hyphen and underscore forms. The only collision is the `cross-node-parallelism` case above. ## AI assistance I made these edits with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
## Description Style and grammar pass on six Ray Data modality guides against Ray's [writing-style guide](https://docs.ray.io/en/master/ray-contribute/writing-style.html): `working-with-images.md`, `working-with-text.md`, `working-with-tensors.md`, `working-with-pytorch.md`, `working-with-llms.md`, and `scaling-collation-functions.md`. Prose only, apart from one code fix: the PyTorch migration example now imports `transforms`, which it uses. No other code, testcode, literalinclude blocks, code comments, or URLs changed. Stacked on ray-project#66420. Review and merge that stack first. This branch targets `doc-1524-data-style-ops`. It's the fourth of five PRs that apply the same pass to the top-level Ray Data pages. ### All six pages - Rewords task headings as imperatives, such as "Read images" and "Scale to multiple GPUs", and conceptual headings as questions, such as "How does the processor pipeline work?". Each reworded heading keeps its old URL fragment through an explicit label named after the old slug. Headings that already had a matching label need no new one. One old fragment can't be kept: `working-with-llms#cross-node-parallelism`, because `serve/llm/user-guides/cross-node-parallelism.md` already defines that label name. Nothing in the repo links to it. Three more old fragments are dropped on purpose because their names are single words: `#embeddings`, `#classification`, and `#multimodality`. Sphinx labels are global, so a label with a generic name would claim it for the whole site and break the build of any later page that defines it. Those headings keep their existing specific labels, such as `embedding_models`. - Uses second person, active voice, present tense, and "such as" for examples. Recasts "lets", "allows", and "enables". - Removes em dashes, parentheticals, first-person plural, "will", and filler. - Fixes list lead-ins and punctuation, and uses `1.` for ordered lists. Opening lists of section links stay, because they're the pages' only links to their sections. - Keeps `{ref}` link text that quotes another page's title in that title's words, such as "Saving Data API". ### Page-specific changes - `working-with-llms.md`: Spells "Hugging Face" consistently in prose, defines "VLM" once, and turns five bold paragraph labels into lead-in sentences. Gives the real default for `max_tasks_in_flight_per_actor`: it resolves to `DataContext.max_tasks_in_flight_per_actor` or `2 * max_concurrent_batches`, which ray-project#63214 introduced in place of the fixed 16. Scopes the vLLM table's lead-in to recent releases, since the table doesn't cover every one. The "Known issue" admonition keeps its title and gains the `warning` class, because the issue raises an `ImportError`. It also moves a bold "Usage data collection" label into a `note`. - `working-with-pytorch.md`: Replaces the legacy "Ray Datasets" product name, recasts the migration section into imperatives, says `pin_memory` applies only when the collate function returns tensors, as its docstring does, and puts the `map` and `map_batches` tab titles in inline code. - `scaling-collation-functions.md`: Fixes the "improving better" typo, and turns the two bold table captions into `list-table` titles. Every number and instance type is unchanged. - `working-with-images.md` and `working-with-text.md`: Put the default column names `image` and `text` in inline code. - `working-with-tensors.md`: Changes the H1 from "Working with Tensors / NumPy" to "Working with tensors and NumPy". ### Other files - Updates link text in `train/user-guides/data-loading-preprocessing.rst` that quotes the old headings, and fixes its "Pytorch" casing. ## Questions for reviewers Apart from the `max_tasks_in_flight_per_actor` default, this pass kept the scope of every claim. These points need a Ray Data maintainer. Each one predates this PR. - **Example variable (`scaling-collation-functions.md`):** the "after" example reassigns `dataset` but passes `train_dataset` to the trainer. - **`torchaudio` (`working-with-pytorch.md`):** the transforms section names `torchaudio`, but it has no `torchaudio` example. - **Custom tokenizers (`working-with-llms.md`):** are `mistral`, `deepseek_v32`, and `grok2` `tokenizer_mode` values? If so, the sentence can name them that way instead of in parentheses. The page says "DeepSeek-V3", but the example file's docstring says "DeepSeek-V3.2". - **`batch_size="auto"` (`working-with-tensors.md`):** the page recommends `batch_size="auto"` but doesn't say that `map_batches` requires an explicit integer `batch_size` when `num_gpus` is set (`dataset.py`). - **Note placement (`working-with-llms.md`):** the usage-data note sits under the NIXL troubleshooting heading. ## Verification - A follow-up commit applies source-verified fixes from automated review. It scopes the collate batch-alignment note to output blocks, because the example repartitions only after `map_batches`. It mentions the alpha `pin_memory` argument of `iter_torch_batches`, imports `transforms` in the PyTorch migration example, and describes what the tensors page covers instead of limitations it doesn't list. It also refers to the value of `max_concurrent_batches` rather than a batch size. - A meaning-diff review compared every before-and-after pair. A conservative filter cleared 37 blocks as cosmetic, and reviewers checked the remaining blocks against the pre-edit text and the Ray source. Two drifted and are fixed in a follow-up commit: a new lead-in implied that Ray Data LLM handles row, actor, and pipeline failures automatically, and the Office Hours item had lost "new". The reviewers confirmed the TP*PP gloss against `placement.py` and `vllm_engine_stage.py`, and that the Hugging Face processor, not Ray, resizes image inputs. - `vale` with Vale 3.12, run from the repo root: no warning- or error-level alerts on the six pages. - `codespell`: no hits. - The pre-commit hooks passed. - A structural check against each pre-edit file confirmed the code-fence count, role targets, and URLs are unchanged. The only anchor changes are the added old-slug labels. None were removed. - Before adding each label, I grepped `doc/source` for the label name in hyphen and underscore forms. The only collision is the `cross-node-parallelism` case above. ## AI assistance I made these edits with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Why
Ray Data LLM hardcoded
DEFAULT_MAX_TASKS_IN_FLIGHT = 16instead of using Ray Data's actor-pool fallback, which (a) didn't trackmax_concurrent_batcheswhen users tuned it and (b) bypassed bothDataContext.max_tasks_in_flight_per_actorand the env-var override of the factor.What changes?
OfflineProcessorConfig.max_tasks_in_flight_per_actor: Optional[int] = None.DEFAULT_MAX_TASKS_IN_FLIGHT = 16constant; engine processors passconfig.max_tasks_in_flight_per_actorstraight through toActorPoolStrategy(includingNone).16→max_concurrent_batches × FACTOR, resolved by Ray Data's actor pool.DataContext.max_tasks_in_flight_per_actorandRAY_DATA_ACTOR_DEFAULT_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTORare now honored (previously bypassed by the explicit16).experimental["max_tasks_in_flight_per_actor"]is deprecated: migrated to the new field at construction with alogger.warning. Top-level field wins if both are set.Original API
New API
Behavior changes
RAY_DATA_ACTOR_DEFAULT_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTORnow have their override honored by Ray Data LLM (previously ignored).experimentalstill works but logs a deprecation warning. The top-level field overridesexperimentalif both are set.max_concurrent_batchesmax_tasks_in_flight_per_actormax_concurrencyRelated issues
Additional information