[Data] Honor compute= in filter(expr=...), deprecate concurrency=#63576
Merged
goutamvenkat-anyscale merged 2 commits intoMay 22, 2026
Merged
Conversation
The `filter(expr=...)` path built its compute strategy as `TaskPoolStrategy(size=concurrency)`, silently ignoring any `compute=` argument. This broke fusion with downstream operators that set their compute strategy explicitly (Task->Task fusion requires matching sizes per `operator_fusion._fuse_compute_strategy`). Route the expr branch through `get_compute_strategy` so it follows the same resolution rules as `map`, `map_batches`, `flat_map`, and the `fn` branch of `filter`: `compute=` takes precedence, `concurrency=` remains as a deprecated fallback that emits the standard warning, and both unset falls back to `TaskPoolStrategy()`. Stateless predicate expressions also reject `ActorPoolStrategy`, mirroring the existing guardrail for regular functions. Signed-off-by: Goutam <goutam@anyscale.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the filter operation in Ray Data to properly handle compute strategies when predicate expressions are used. It replaces a hardcoded TaskPoolStrategy with get_compute_strategy, allowing the compute parameter to be honored and maintaining concurrency as a deprecated fallback. The PR also includes a suite of tests to ensure correct strategy resolution and proper error handling for incompatible strategies like ActorPoolStrategy. I have no feedback to provide.
richardliaw
approved these changes
May 22, 2026
richardliaw
left a comment
Contributor
There was a problem hiding this comment.
so we previously just ignored the param? lol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dataset.filter(expr=...)built its compute strategy asTaskPoolStrategy(size=concurrency), silently ignoring anycompute=argument the caller passed. This broke fusion with downstream operators that set their compute strategy explicitly (Task→Task fusion requires matchingsizeperoperator_fusion._fuse_compute_strategy).get_compute_strategy(fn=None, ...)so it follows the same resolution rules asmap,map_batches,flat_map, and thefnbranch offilter:compute=takes precedence,concurrency=remains a deprecated fallback that emits the standard warning, and both unset falls back toTaskPoolStrategy(). Predicate expressions also rejectActorPoolStrategy, mirroring the existing guardrail for regular functions (both are stateless).Repro
Before: the filter's
compute=was discarded → upstreamsize=None, downstreamsize=20→ fusion blocked.After: both ops carry
size=20→Filter(...)->Projectappears as a single fused operator.Test plan
pytest python/ray/data/tests/test_filter.py— 43 passed, including 4 new tests:test_filter_expr_compute_resolution(parametrized):compute=andconcurrency=both round-trip intoFilter.compute.test_filter_expr_compute_honors_taskpoolstrategy: explicitTaskPoolStrategy(size=20)is preserved.test_filter_expr_concurrency_is_deprecated: legacyconcurrency=still works but logs the deprecation warning.test_filter_expr_rejects_actor_pool: passingActorPoolStrategyraises (same asmap(fn=lambda r: r, compute=ActorPoolStrategy(...))).pre-commit run --files ...).🤖 Generated with Claude Code