Repository navigation
Conversation
Signed-off-by: jiangxt2 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request ensures that environment and placement configurations (such as runtime_env, label_selector, fallback_strategy, and scheduling_strategy) are preserved from the original read operation during count pushdown optimization. A corresponding test has been added to verify this behavior. The feedback suggests also preserving placement group-related arguments (placement_group, placement_group_bundle_index, and placement_group_capture_child_tasks) to prevent scheduling violations when placement groups are defined directly in ray_remote_args.
| ray_remote_args={ | ||
| "num_cpus": min(self._PER_TASK_NUM_CPUS_ALLOCATION, read_num_cpus), | ||
| **{ | ||
| key: read_files.ray_remote_args[key] | ||
| for key in ( | ||
| "runtime_env", | ||
| "label_selector", | ||
| "fallback_strategy", | ||
| "scheduling_strategy", | ||
| ) | ||
| if key in read_files.ray_remote_args | ||
| }, | ||
| }, |
There was a problem hiding this comment.
In Ray, placement groups can be specified either via scheduling_strategy (using PlacementGroupSchedulingStrategy) or directly via the placement_group option in ray_remote_args (along with placement_group_bundle_index and placement_group_capture_child_tasks).
If a user specifies the placement group directly using placement_group in ray_remote_args, this constraint will currently be discarded for the count task, which could lead to scheduling violations or failures if the count task runs on a node without the required access/placement.
To ensure all placement constraints are preserved, we should also carry over placement_group, placement_group_bundle_index, and placement_group_capture_child_tasks.
ray_remote_args={
"num_cpus": min(self._PER_TASK_NUM_CPUS_ALLOCATION, read_num_cpus),
**{
key: read_files.ray_remote_args[key]
for key in (
"runtime_env",
"label_selector",
"fallback_strategy",
"scheduling_strategy",
"placement_group",
"placement_group_bundle_index",
"placement_group_capture_child_tasks",
)
if key in read_files.ray_remote_args
},
},There was a problem hiding this comment.
The legacy placement_group options are deprecated. When neither scheduling_strategy nor label_selector is present, Ray Data adds a default scheduling strategy; Ray rejects combining a non-None strategy with a concrete legacy placement_group. Blindly forwarding these options can therefore fail. Explicit scheduling_strategy=None may allow the legacy path, but this PR does not forward those legacy options. For placement groups, I'd keep this change scoped to scheduling_strategy.
Description
Preserve the read task's runtime environment and placement options when pushing
count()down to file metadata. This lets metadata reads use the same storage access and placement constraints as the original read.Before: Count tasks discard the read task's environment and placement options and always request 0.5 CPU.
After: Count tasks inherit
runtime_env,label_selector,fallback_strategy, andscheduling_strategy. They request 0.5 CPU by default or the smaller explicit read CPU request; an explicitNonerequests no CPU. GPU and other read resources are not carried over.Subsystem: Logical planning / query optimization.
Related issues
Related to #67269. This is the count-task option fix split out at the reviewer's request; row-count reuse remains separate.
Additional information
Testing:
PYTHONPATH=python:python/ray/data/tests/datasource pytest -q python/ray/data/tests/datasource/test_read_parquet_v2.py— 131 passed with Python 3.12 and PyArrow 23 using a prebuilt Ray Core. The count test checks default, explicitNone, 0.1 CPU placement group, and 1 CPU options; it executes count for the zero-CPU fallback and placement group cases.AI assistance was used to prepare this change.