-
Notifications
You must be signed in to change notification settings - Fork 651
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
Add generator-style run_batch function #2513
base: main
Are you sure you want to change the base?
Conversation
This change adds a new generator_style parameter to run_batch that allows yielding results as they become available, while maintaining the performance benefits of batch processing. This is particularly useful when you want to process results as soon as they are ready, for example to save them to disk. When generator_style=True, run_batch yields tuples of (arguments, result) as they become available, instead of returning a list at the end. Fixes sgl-project#303
As suggested in the issue, we don't need to return the arguments with each result. The user can maintain their own mapping if needed.
Please fix the CI test cases https://github.com/sgl-project/sglang/actions/runs/12506724584/job/34892097249?pr=2513 |
The CI stil fails |
EDIT: ok.. when call |
Let me know when it is fully ready. |
@merrymercy Now i confirm it actually works in my case -- feel free to take a look when you have time |
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.
You chunking logic changes the behavior of the old code. Please revert it. When you add this functionality, please do not change any existing behavior and only add additional code to support the new functionality. Make sure when generator_style == False
, it runs exactly the old code.
4b96829
to
acaf7ba
Compare
This PR adds a new
generator_style
parameter torun_batch
that allows yielding results as they become available, while maintaining the performance benefits of batch processing. This is particularly useful when you want to process results as soon as they are ready, for example to save them to disk.Changes
generator_style
parameter torun_program_batch
ininterpreter.py
that defaults toFalse
generator_style
parameter to therun_batch
method inir.py
to expose it to usersUsage Examples
The generator mode yields results as soon as they are available, which is useful for:
Implementation Details
generator_style=True
, results are yielded through Python generators as they completeFixes #303
PR co-authored by OpenHands: https://www.all-hands.dev/share?share_id=b1757eabec18e7204a615b889819333dca4cb4388a7da4fe5b8b074f3595a582