Repository navigation
[Bug] Run the E+PD encode stage when a replica inflight cap is set - #3200
varungup90 merged 4 commits into
Conversation
With requestsInflight set, selectTargetPod returned straight from routeWithEarlyAdmission and never reached the encodeMedia call after Route, so multimodal requests skipped their roleset's encoders. Route through either path and run the encode stage once afterwards. Signed-off-by: MinJun Choi <[email protected]>
Add the case from vllm-project#3198: two serving pods and requestsInflight of 1. Signed-off-by: MinJun Choi <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the selectTargetPod function in gateway.go to ensure that media encoding is performed when routing with early admission (when a replica inflight limit is configured), rather than returning early. It also adds a new test case in gateway_epd_test.go to verify this behavior under an inflight limit. There are no review comments, and I have no feedback to provide.
varungup90
left a comment
There was a problem hiding this comment.
Recommendation: approve with nits. The fix is correct and small, and the new test fails without it. Two nits concern the interaction with the inflight cap, which the PR now makes reachable. This is a review comment, not a formal GitHub approval.
What I checked (head b224022e)
- The bug is as described. On
main, the capped path wasreturn s.routeWithEarlyAdmission(...), which leftselectTargetPodbefore theif err == nil { s.encodeMedia(...) }below it, so E+PD media was never offered to the roleset's encoders whenrequestsInflightwas set. The PR assignsaddr, errfrom either route call and keeps oneencodeMediacall after both.erris the variable already declared bySelectabove, so the assignment is fine. - PD requests are not double-encoded. For
pd,selectTargetPoddoes not split the encoders off (if !isPD { … SplitEncoders }), soencodersis nil andencodeMediareturns at its first line. The PD router runs its own encode stage, asTest_selectTargetPod_PDKeepsEncoderscovers. - The single-candidate fast path is unaffected: it already calls
encodeMediabefore returning.
What I ran (scratch worktree at the head, Go 1.24.7)
gofmt -landgo vetonpkg/plugins/gatewayare clean.go test -race -count=1 ./pkg/plugins/gateway/...passed (all 16 packages).- Fail-before: I restored
main'sgateway.goand kept the PR's test.Test_selectTargetPod_EPlusPD/media_is_encoded_with_a_replica_inflight_capfails. - Mutants of
gateway.go:- skip
encodeMediaon the capped path (the original bug): killed by that subtest; - encode even when routing failed (drop the
err == nilguard): survives.
- skip
- CI at the time of review:
Go Lint and Unit Tests,Go Integration Tests,Installation Smoke / Helm,DCOandtriageare green.Installation E2E Testswas still running, andbuildwas skipped. I did not wait for the E2E job.
Not run: golangci-lint locally, and a real encoder.
Nits (non-blocking)
- A failed route must not encode, and nothing pins that. Dropping the
err == nilguard keeps every test green. That guard now matters: with the cap set, a full target makes an admission-aware router failRoute(ErrTargetReplicaInflightExceeded), and the guard is what stops an E+PD request that is about to get a 429 from paying for the encode HTTP calls. I wrote a throw-away probe (deleted afterwards) with one full pod: a router that callsAdmitTargetgets that error and 0 encodes, as intended. A subtest like that with the encoder counter at 0 would pin it. - Routers that do not call
AdmitTargetstill encode before admission. Using the same probe with the plainfirstPodRouter,selectTargetPodreturns success and the encoder is called once for a pod that is at its cap. The cap is only enforced afterwards, inenforceReplicaInflight, which runs afterselectTargetPod. So under saturation these requests still pay for an encode and are then rejected, which is what I noted on #3153. It is not a regression from this PR, since before it the encode never ran with a cap. If it matters, running the encode stage after the admission step, inHandleRequestBody, would fix it for every router. I would not hold this PR for that.
Verdict: approve with nits. It restores the encode offload for capped E+PD deployments, and the new case pins the reported scenario.
Generated by Claude Code
With a replica inflight cap, a router that admits its target fails Route when the target is full. Check that selectTargetPod returns that error without calling the encoders. Signed-off-by: MinJun Choi <[email protected]>
|
@varungup90 Thanks! I added On the second one, agreed that routers that don't call |
Pull Request Description
With
requestsInflightset,selectTargetPodreturned straight fromrouteWithEarlyAdmission, so theencodeMediacall afterRoutenever ran and E+PD requests skipped their roleset's encoders. Responses were still correct, since the serving pod encodes missing items itself, but the encode offload was lost.Both routing paths now fall through to a single
encodeMediacall, so a new branch can't skip it the same way. I added the case from the issue (two serving pods,requestsInflightof 1) toTest_selectTargetPod_EPlusPD; it fails on main and passes with this change.go test -race ./pkg/plugins/gateway/...passes.Thanks to @Jackmeson1 for the report and repro.
Related Issues
Resolves: #3198