-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Data] Revisiting make_async_gen
to address issues with concurrency control for sequences of varying lengths
#51661
Conversation
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
python/ray/data/_internal/util.py
Outdated
@@ -915,49 +918,14 @@ def make_async_gen( | |||
base_iterator: Iterator[T], | |||
fn: Callable[[Iterator[T]], Iterator[U]], | |||
num_workers: int = 1, | |||
queue_buffer_size: int = 2, | |||
queue_buffer_size: Optional[int] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raulchen i'd recommend reviewing in isolation as this was written from scratch
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
make_async_gen
to address issues with concurrency control for sequences of varying lengthsmake_async_gen
to address issues with concurrency control for sequences of varying lengths
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Fixed fixture Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
iter(range(3)), | ||
_transform_b, | ||
): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, maybe use multiple workers and test that transform fn is entered at most once per worker.
and for simplicity in the multi-threading case, we can just use a counter instead of capturing the logs.
Can you update the PR description as the fix has changed? |
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
… on whether ordering has to be preserved; Updated docs Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
… queue instead of N Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Tidying up Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Signed-off-by: Alexey Kudinkin <ak@anyscale.com>
Why are these changes needed?
This change addresses potential deadlocks inside
make_async_gen
when used in with functions producing sequences of wildly varying in lengths.Fundamentally
make_async_gen
was trying to solve 2 problems respective solutions for which never actually overlapped:Implement parallel processing based on transforming an input iterator into an output one, while preserving back-pressure semantic, where input iterator should not be outpacing output iterator being consumed.
Implement parallel processing allowing ordering of the input iterator being preserved.
These requirements coupled with the fact the transformation is expected to received and produce iterators are what led to erroneous deduction that it could be implemented:
To resolve that problem fundamentally we decoupling this 2 use-cases into
Preserving order: has N input and output queues, with the input queues being uncapped (while output queues still being capped at
queue_buffer_size
), meaning that incoming iterator will be unrolled eagerly by the producer (till exhaustion)Not preserving order: has 1 input queue and N output queues, with both input and output queues being capped in size based
queue_buffer_size
configuration. This allows to implement back-pressure semantic where consumption speed will limit production speed (and amount of buffered data)Changes
preserve_ordering
paramRelated issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.