Repository navigation
[Serve] Support keyword inputs with custom batch sizing - #66321
abrarsheikh merged 8 commits into
Conversation
Signed-off-by: Jayesh Suyal <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request simplifies the extraction of batch items in _compute_batch_size by directly accessing the flattened arguments, which enables support for both positional and keyword arguments (including keyword-only parameters) when using a custom batch_size_fn. The documentation has been updated to reflect this behavior, and comprehensive unit tests have been added to verify various calling styles and edge cases. There are no review comments, and I have no additional feedback to provide.
Signed-off-by: Jayesh Suyal <[email protected]>
Signed-off-by: Jayesh Suyal <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
|
Thanks @YashwanthRanjanSingaravel for refining the first-input validation, adding the compatibility coverage, and improving the docs. Really appreciate the careful review and follow-up fixes! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 50487c2. Configure here.
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>

Description
When a single-input batched handler uses
batch_size_fn, passing its input by keyword leaves no positional argument for_compute_batch_sizeto read. The resultingIndexErrorescapes batch assembly. A local Serve deployment reproduces positional success, keyword timeout, then another positional timeout because the batching task has stopped.Read the first payload value from the existing flattened argument representation, after
selfhas already been removed. This preserves successful positional calls and supports a single explicitly supplied input passed by keyword, including keyword-only parameters. Existing multi-input positional calls remain supported. Multi-input keyword calls and variadic keyword (**kwargs) handlers are rejected before queueing because their flattened keyword order is not stable across a batch, and omitting a defaulted input is rejected because there is no explicit value to size. These errors affect only the caller and do not stop the batching worker. General callback-error isolation remains outside this change.The tests exercise functions and bound methods, coroutine and streaming handlers, mixed positional/keyword arrivals in both orders, keyword-only signatures, oversized keyword input recovery, omitted defaults, second-keyword-first ordering, variadic keyword signatures, positional multi-input compatibility, and worker survival after invalid requests. The batching guide describes the supported call forms.
Related work and attribution
This addresses the finding already raised in the review of #59059; it is not a new discovery. Searches for custom sizing and keyword/kwargs fixes found no matching open PR. #66141 fixes callback-error isolation and explicitly excludes keyword compatibility. #64595 restructures per-model queues but leaves this payload extraction unchanged; it touches the same file and may require rebasing.
Validation
macOS arm64, Python 3.12.14, official Ray
3.0.0.dev0wheel at39882c660a6d7b579e39d724ce85d9074d6180fb, with the branch's current Python Serve sources linked into the environment. Because the branch includes newer master changes, the source and wheel revisions are not exact; the focused suite required a runner-local shim for a newer test-fixture helper.TypeErrors; a subsequent valid request succeeds and all batching tasks remain alive.git diff --checkpasses. Vale is excluded for this documentation path and its environment separately failed to compile on this Mac because the C++cassertheader was unavailable.No GPU performance, full-Ray suite, docs build, or upstream CI result is claimed.