fix(sglang): preserve cached token usage - #10925
Merged
Merged
Conversation
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
ishandhanani
temporarily deployed
to
external_collaborator
June 24, 2026 14:53 — with
GitHub Actions
Inactive
ishandhanani
marked this pull request as ready for review
June 24, 2026 14:57
ishandhanani
enabled auto-merge (squash)
June 24, 2026 14:57
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesCached token details in completion_usage
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
This comment has been minimized.
This comment has been minimized.
tedzhouhk
approved these changes
Jun 24, 2026
ishandhanani
temporarily deployed
to
external_collaborator
June 24, 2026 18:09 — with
GitHub Actions
Inactive
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
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.
Summary
The unified SGLang backend now forwards SGLang's cached-token count into OpenAI completion usage. This restores cache observability for warm requests, including HiCache; the existing
dynamo.sglangpath already returns this field.CLOSES: DYN-3275
How This Was Implemented
prompt_tokens_details.cached_tokensfrom final SGLang response metadata when the count is nonzero.Walkthrough
SglangLLMEngine.generateincludes cached-token details in terminal completion usage.Validation
ruff check components/src/dynamo/sglang/llm_engine.pyQwen/Qwen3-0.6B, SGLang0.5.13.post1, and HiCache enabled. The base backend logged#cached-token: 512on the warm request.Before (
origin/main) — exact warm-responseusage:{"completion_tokens":4,"prompt_tokens":516,"total_tokens":520}After — exact warm-response
usage:{"completion_tokens":4,"prompt_tokens":516,"prompt_tokens_details":{"audio_tokens":null,"cached_tokens":512},"total_tokens":520}python -m dynamo.sglangwith--enable-cache-report --enable-hierarchical-cachealready returns the same warm-responseusageas the patched unified backend.sglang.launch_serverreturnedprompt_tokens_details.cached_tokens: 512on the warm request.Summary by CodeRabbit