Repository navigation
[sgl-router] Book the input_ids forwarding outcome only for built bodies - #41307
Closed
ShangmingCai wants to merge 1 commit into
Closed
ShangmingCai wants to merge 1 commit into
ShangmingCai wants to merge 1 commit into
Conversation
A body with an f64-overflow literal (e.g. temperature:1e400) passes the routing-fields fallback, skips the ingress parse when no tokenization is needed, and is only rejected by the PD bootstrap re-parse in build_outgoing_body - after the forwarding outcome was already booked. Book the metric once the outgoing body exists, so a 400 never counts as a dispatched request. TokenizeFailed booking is unaffected: it implies a cached parse, where the build has no failure path. Co-Authored-By: Claude Fable 5 <[email protected]>
3 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.
Follow-up to #41185 (targets its branch, so it folds into that PR): move the
sgl_router_input_ids_forwarding_totalbooking to afterbuild_outgoing_bodysucceeds, so a request rejected while building the outgoing body never counts as dispatched.The corner it closes
There is exactly one reachable book-then-400 path, and it needs all of:
"temperature": 1e400) — the routing-fields fallback (parse_without_sampling_values) accepts it viaIgnoredAny, butserde_json::from_slice::<Value>rejects it (number out of range);needs_tokens == false(forwarding off / no chat formatter, non-token policy, no bucket routing), soparsed_bodyisNoneand ingress never parses the full body;build_outgoing_body(the non-PD rid/sampling path splices raw bytes and never parses).That request booked
disabled, then the client got a 400 and nothing was dispatched — violating the counter's "exactly once per dispatched request" contract. Verified reachable end to end: a PD worker pair plus a1e400body booksdisabledon the base branch despite the 400 response.Every other outcome is safe by construction:
forwarded/tokenize_failedimplycan_forward_input_ids, which guarantees the cached parse, where the build has no failure path. So reordering loses no error bookings, andsgl_router_ingress_tokenize_errors_totalsemantics are unchanged.Modifications
into_outgoing_body: build the outgoing body first, bookrecord_input_ids_forwarding(and theTokenizeFailedingress-error bump) only on theOkpath.Test plan
cargo clippy --all-targets -- -D warningscargo test: all suites pass1e400body → 400 yetdisabledbooked); with this change nothing is booked🤖 Generated with Claude Code