Add scheduler for batched requests - #22035
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22035
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (6 Unrelated Failures)As of commit b7131d7 with merge base 89e6f90 ( BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review this code |
This PR needs a
|
|
Claude finished @metascroy's task in 2m 16s —— View job Code review:
|
Adds extension/llm/scheduler, a header-only step scheduler for batched LLM serving. A Request is one step for one sequence, either a single decode token or one prefill chunk, which callers submit() and await via std::future, with get_work() assembling the next Batch. Decodes are served first in arrival order up to max_decode_sequences, then the remainder of max_batch_size goes to prefill, which is organized as a FIFO per session plus a rotation across sessions so a long prompt advances one chunk per pass instead of monopolizing the batch. The scheduler reads only request_id, session_id, and tokens.size(). Everything else lives in RequestParams/ResponsePayload and is carried through untouched, so payload fields can be added without touching scheduling logic. SchedulerParams is immutable and self-validating with max_batch_size derived rather than stored, making inconsistent limits unrepresentable. The payload already accommodates upcoming dflash speculative decoding: OutputRows::All requests a prediction at every drafted position, an absent sampling returns the raw distribution instead of tokens, and accept/reject stays in the caller where the draft output lives. Ships with 53 gtest cases covering scheduling order, fairness, cancellation, completion, and a randomized invariant check that models queued() exactly. All pass under -Wall -Wextra -Werror and ThreadSanitizer, and the suite is wired into CMake as an INTERFACE target beside extension_llm_cache.