Conversation
There was a problem hiding this comment.
Pull request overview
Adds bounded in-flight scheduling for generation batches when LMClient(max_parallel_requests=...) is set, to avoid creating one task per batch item up front while preserving ordering, callbacks, and cancellation semantics.
Changes:
- Refactors async generation logic into
src/infermesh/_generation.pyand routesLMClient.agenerate*through it. - Implements bounded-window scheduling for
agenerate_batch(and thereforegenerate_batch, via the sync runner) and plumbs queue-admission timing into request metrics. - Updates docs and adds tests covering bounded ordering, strict-failure cancellation, and queue-wait including scheduler delay.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/infermesh/client.py |
Routes agenerate/agenerate_batch through new private helpers; updates docstrings to document bounded batching behavior. |
src/infermesh/_generation.py |
New helper module implementing bounded-window scheduling and shared generation request logic. |
src/infermesh/_client_runtime.py |
Adds optional queue_started_at to include scheduler delay in queue-wait metrics. |
tests/test_client_batch.py |
Adds bounded-window tests for ordering, concurrency cap, and strict failure behavior. |
tests/test_client_limits.py |
Adds test asserting queue-wait includes bounded-scheduler delay. |
docs/guide.md |
Documents using max_parallel_requests for large batches; updates examples. |
README.md |
Documents bounded batch behavior; updates examples to set max_parallel_requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
generate_batchandagenerate_batchwhenmax_parallel_requestsis set.LMClientkeeps the public API surface explicit.max_parallel_requestsis required for large or memory-sensitive Python batch runs.Testing
uv run pytest tests/test_client_batch.py tests/test_client_limits.py tests/test_cli_bench.py -quv run pre-commit run -a