Repository navigation
[Rust Frontend] Generate through an Llm trait - #64695
Merged
Merged
Conversation
This was referenced Oct 30, 2026
BugenZhao
force-pushed
the
bz/engine-client-trait
branch
from
October 30, 2026 11:53
1d80f5b to
43da6d5
Compare
6 tasks done
BugenZhao
marked this pull request as ready for review
October 30, 2026 12:14
sagearc
approved these changes
Oct 30, 2026
Contributor
There was a problem hiding this comment.
towards abstracting tokens-in/tokens-out, this is clean!
rust/src/llm/src/lib.rs is basically all we need
BugenZhao
force-pushed
the
bz/engine-client-trait
branch
from
November 3, 2026 06:31
43da6d5 to
8de8a5d
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
`Llm` is the token-level generate/abort facade over the engine-core client. Name it after what it drives, so that `Llm` can name the layer's interface in the next commit. Pure rename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CJckCBxv8Gtnq23avKQwau Signed-off-by: Bugen Zhao <i@bugenzhao.com>
`TextLlm` owned a concrete `EngineCoreLlm`, so the text, chat, and server layers could only run over an engine-core client. Make `Llm` the layer's interface, the generate/abort subset of Python's `EngineClient`, with `EngineCoreLlm` as its engine-core implementation: - `generate` takes a lowered `GenerateRequest` and streams raw `GenerateOutput`s; detokenization and stop strings stay above it. - `info()` returns `LlmInfo`, the model and engine facts fixed at creation that the upper layers read (context length, model dtype, LoRA support, vLLM version). - Health is two signals, as on the engine-core client: `subscribe_health` turns `false` only on a permanent failure (liveness), while `subscribe_readiness` follows whether new requests can be taken now, such as while engines are paused or asleep. The gRPC health services now read both from the `Llm`. - The trait requires `Any`. Callers that need engine-core specifics, such as the server's admin and utility routes, downcast to `EngineCoreLlm`, so the trait itself does not expose the engine-core client. - New `vllm_llm::Error` variants let implementations that are not backed by engine-core report rejected requests, unsupported fields, unavailability, and remote failures; `vllm-text` classifies the first two as request validation errors. `TextLlm` now holds a `Box<dyn Llm>`, and `ChatLlm` and the server read these facts from `LlmInfo`. No behavior changes. Co-authored-by: Sage Ahrac <80211083+sagearc@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CJckCBxv8Gtnq23avKQwau Signed-off-by: Bugen Zhao <i@bugenzhao.com>
BugenZhao
force-pushed
the
bz/engine-client-trait
branch
from
November 4, 2026 08:36
8de8a5d to
3b03253
Compare
njhill
approved these changes
Nov 5, 2026
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #100109 for commit ℹ️ This PR is 75 commits behind upstream |
6 tasks done
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.
Overview
Make the Rust frontend's token-level generation layer an interface, so
TextLlm,ChatLlm, and the server can run over implementations that are not backed by a local engine-core client, such as an HTTP client to a tokens-in/tokens-out gateway (#63887, llm-d/llm-d-router#3617) or a remote Rust frontend.Claims
vllm_llm::Llmtrait:info(),subscribe_health,subscribe_readiness,generate,abort, andshutdown. A loweredGenerateRequestgoes in, rawGenerateOutputs come out.subscribe_healthturnsfalseonly on a permanent failure (liveness), andsubscribe_readinessfollows whether new requests can be taken now, such as not while engines are paused or asleep./healthand the gRPC health services ([Rust Frontend][gRPC] Separate liveness from inference readiness #63870) read them from theLlm.Llmstruct is renamedEngineCoreLlm(first commit, pure rename) and implements the trait.TextLlmholds aBox<dyn Llm>;ChatLlmand the server read engine facts fromLlmInfoinstead of the engine-core client.vllm_llm::Errorvariants (Unsupported,Unavailable,RemoteInvalidRequest,Remote) for implementations not backed by engine-core.vllm-textclassifiesUnsupportedandRemoteInvalidRequestas request validation errors.EngineCoreLlm.Validation
In
rust/, on each commit:cargo clippy --workspace --all-targets --all-featuresandcargo fmt --all -- --check: clean.cargo nextest run -p vllm-llm -p vllm-text -p vllm-chat -p vllm-server -p vllm-cmd -p vllm-bench: 1615 passed, 13 skipped, on main5c97556318. The other 3 (vllm-chatroundtrip and grammar replay) download real Hugging Face models and fail locally only because the shared model cache is not readable on this machine; this PR does not touch them.This is a refactor of internal Rust APIs, so it adds no tests; generated tokens are unaffected and no model evaluation was run.
Details
EngineClient.EngineCoreClient,vllm-managed-engine), so the interface takes the layer's name,Llm, and the engine-core implementation becomesEngineCoreLlm.LlmrequiresAny; the server downcasts toEngineCoreLlmfor the admin and utility routes that drive the engine-core client. A separate control trait can come once a remote implementation needs those operations.EngineClienttrait beneathLlmthat mirrors the fullEngineCoreClientAPI (about 45 methods, including the utility calls), which every implementation, including an HTTP client, would have to provide. This PR abstracts theLlmlayer itself, as [Rust Frontend] engine client interface #63887 originally proposed, and is co-authored with its author; the HTTP client can build on it.Llmwithout an engine-core client: register engine-core routes only forEngineCoreLlm, and mapUnavailableto 503.AI assistance (Claude) was used for this change.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CJckCBxv8Gtnq23avKQwau