Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion experimental/sgl-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ serde_json = "1"
tempfile = "3"
tower = { version = "0.5", features = ["util"] }
tokio = { version = "1.42", features = ["test-util"] }
# The hand-rolled mock engine in tests/proxy/grpc_chat.rs.
# The hand-rolled mock engine in tests/proxy/grpc_routing.rs.
prost = "0.14"
tonic-prost = "0.14.6"
# Low-level msgpack encoder used to hand-construct wire bytes in
Expand Down
23 changes: 21 additions & 2 deletions experimental/sgl-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ embeddings endpoint reads none.
response. It is served as embeddings are, except that a batch of text stays text,
since the engine takes token IDs for only one prompt.

## Completions

`/v1/completions` has the engine's interface and is prepared like chat (sampling
contract, PD bootstrap, DP rank), with the prompt forwarded as sent: tokens the
router computes for routing do not replace it.

## Rerank

`/v1/rerank` has the engine's interface: the same `V1RerankReqInput` body and
Expand Down Expand Up @@ -695,8 +701,21 @@ over HTTP.
| RPC | Routed like |
|---|---|
| `ChatComplete` | `/v1/chat/completions`: same rendering, `input_ids` forwarding, PD and DP-rank handling |

Every other RPC answers `UNIMPLEMENTED`. Request metadata and `trace_headers`
| `Complete` | `/v1/completions` |
| `Generate`, `TextGenerate` | `/generate` with `input_ids` or `text` |
| `Embed`, `TextEmbed`, `OpenAIEmbed` | `/v1/embeddings` |
| `Classify`, `OpenAIClassify` | `/v1/classify` |
| `Rerank` | `/v1/rerank` |

The OpenAI RPCs carry the HTTP route's JSON body, so they are prepared exactly as
over HTTP. A typed RPC is prepared from its fields with the same rules, and the
router's additions (rid, PD bootstrap, DP rank, sampling defaults) are set on the
proto it forwards. A text prompt is tokenized once, as its HTTP route forwards
`input_ids`: `TextGenerate` is sent as `Generate` with `return_text`, so the engine
still supplies the text, and `TextEmbed` as `Embed`. They stay text RPCs under
`--disable-input-ids-forwarding`, without a tokenizer, or, for `TextGenerate`, with
`return_text_in_logprobs`. Other RPCs, such as
`Tokenize`, `HealthCheck` and the admin RPCs, answer `UNIMPLEMENTED`. Request metadata and `trace_headers`
act as HTTP headers for routing and forwarding, and a cancelled call aborts the
engine request. Router errors arrive as a gRPC status carrying the HTTP path's
message and an `x-router-error-code` trailer; an engine's status passes through
Expand Down
Loading
Loading