Skip to content

[data][llm] Promote max_tasks_in_flight_per_actor to a first-class config field and adjust defaults - #63214

Merged
kouroshHakha merged 3 commits into
masterfrom
data-llm-max-tasks-in-flight
May 8, 2026
Merged

kouroshHakha merged 3 commits into
masterfrom
data-llm-max-tasks-in-flight

Conversation

@jeffreywang88

@jeffreywang88 jeffreywang88 commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

Ray Data LLM hardcoded DEFAULT_MAX_TASKS_IN_FLIGHT = 16 instead of using Ray Data's actor-pool fallback, which (a) didn't track max_concurrent_batches when users tuned it and (b) bypassed both DataContext.max_tasks_in_flight_per_actor and the env-var override of the factor.

What changes?

  • New top-level field OfflineProcessorConfig.max_tasks_in_flight_per_actor: Optional[int] = None.
  • Removed the DEFAULT_MAX_TASKS_IN_FLIGHT = 16 constant; engine processors pass config.max_tasks_in_flight_per_actor straight through to ActorPoolStrategy (including None).
  • Default in-flight cap: hardcoded 16 → max_concurrent_batches × FACTOR, resolved by Ray Data's actor pool.
  • DataContext.max_tasks_in_flight_per_actor and RAY_DATA_ACTOR_DEFAULT_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTOR are now honored (previously bypassed by the explicit 16).
  • experimental["max_tasks_in_flight_per_actor"] is deprecated: migrated to the new field at construction with a logger.warning. Top-level field wins if both are set.

Original API

OfflineProcessorConfig(
    ...,
    experimental={"max_tasks_in_flight_per_actor": 32},  # only knob
)

New API

OfflineProcessorConfig(
    ...,
    max_concurrent_batches=8,           # unchanged
    max_tasks_in_flight_per_actor=32,   # new top-level field, Optional[int]
)

Behavior changes

  • Users who set RAY_DATA_ACTOR_DEFAULT_MAX_TASKS_IN_FLIGHT_TO_MAX_CONCURRENCY_FACTOR now have their override honored by Ray Data LLM (previously ignored).
  • Setting via experimental still works but logs a deprecation warning. The top-level field overrides experimental if both are set.
max_concurrent_batches max_tasks_in_flight_per_actor Ray actor max_concurrency Effective in-flight cap
unset (default 8) unset (None) 8 16
16 unset (None) 16 32
unset (default 8) 50 8 50
16 50 16 50

Related issues

Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234".

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@jeffreywang88
jeffreywang88 requested a review from a team as a code owner May 8, 2026 00:46
@jeffreywang88 jeffreywang88 added the go add ONLY when ready to merge, run all tests label May 8, 2026
@jeffreywang88 jeffreywang88 changed the title [data][llm] Promote to a first-class config field and adjust defaults [data][llm] Promote max_tasks_in_flight_per_actor to a first-class config field and adjust defaults May 8, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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]>
@ray-gardener ray-gardener Bot added the data Ray Data-related issues label May 8, 2026

@Aydin-ab Aydin-ab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making a bit more explicit in the doc that it's 2 * max_concurrent_batches

Comment thread python/ray/data/llm.py Resolved
Comment thread python/ray/data/llm.py Resolved

@kouroshHakha kouroshHakha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@kouroshHakha
kouroshHakha enabled auto-merge (squash) May 8, 2026 21:09
@kouroshHakha
kouroshHakha merged commit 75f55e3 into master May 8, 2026
4 checks passed
@kouroshHakha
kouroshHakha deleted the data-llm-max-tasks-in-flight branch May 8, 2026 21:42
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…config field and adjust defaults (ray-project#63214)

Signed-off-by: Jeffrey Wang <[email protected]>
alexandrplashchinsky pushed a commit to alexandrplashchinsky/ray-alex that referenced this pull request May 29, 2026
…config field and adjust defaults (ray-project#63214)

Signed-off-by: Jeffrey Wang <[email protected]>
Signed-off-by: Alexandr Plashchinsky <[email protected]>
dstrodtman added a commit that referenced this pull request Sep 24, 2026
…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]>
dstrodtman added a commit that referenced this pull request Sep 30, 2026
…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]>
dstrodtman added a commit that referenced this pull request Sep 30, 2026
## 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]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ray fails to serialize self-reference objects

3 participants