Skip to content

Map SGLang's prefix cache and retraction counters - #544

Merged
dennis-upbound merged 1 commit into
modelplaneai:mainfrom
dennis-upbound:dennis/sglang-metric-mapping
Oct 20, 2026
Merged

dennis-upbound merged 1 commit into
modelplaneai:mainfrom
dennis-upbound:dennis/sglang-metric-mapping

Conversation

@dennis-upbound

Copy link
Copy Markdown
Collaborator

Description of your changes

The built-in SGLang mapping renames running and waiting requests, KV usage and the two token histograms, but none of SGLang's prefix cache or retraction counters. modelplane_prefix_cache_hits_total, modelplane_prefix_cache_lookups_total and modelplane_requests_preempted_total are empty for every SGLang deployment, so a prefix cache hit rate across a vLLM and an SGLang deployment shows SGLang at nothing. The comment above _SGLANG and test_sglang_mappings said SGLang publishes none of them, checked against v0.4.9.post2. Both versions the repo pins now do.

This maps the three counters onto vLLM's names:

SGLang Becomes
sglang:cached_tokens_total modelplane_prefix_cache_hits_total
sglang:prompt_tokens_total modelplane_prefix_cache_lookups_total
sglang:num_retracted_requests_total modelplane_requests_preempted_total

Counters have no buckets, so #523 doesn't apply, and each pair counts the same thing in the same unit. SGLang counts when a request finishes where vLLM counts when it's scheduled, and cached_tokens_total has a cache_source label that sum by (deployment) folds away. The telemetry docs now say both.

sglang:queue_time_seconds stays unmapped. Its buckets differ from vLLM's and between the two pinned SGLang versions, which is #523.

The metric names come from SGLang's source at v0.5.10.post1 and v0.5.12.post1. This didn't run against a live SGLang engine.

Fixes #543

I have:

  • Read and followed Modelplane's contribution process.
  • Run nix flake check (or ./nix.sh flake check) and made sure it passes.
  • Added or updated tests covering any composition function changes.
  • Signed off every commit with git commit -s.

🤖 Generated with Claude Code

The built-in SGLang mapping renamed running and waiting requests, KV
usage and the token histograms, but none of SGLang's prefix cache or
retraction counters. modelplane_prefix_cache_hits_total,
modelplane_prefix_cache_lookups_total and
modelplane_requests_preempted_total were empty for every SGLang
deployment, so a prefix cache hit rate across vLLM and SGLang showed
SGLang at nothing.

SGLang v0.5.10.post1 and v0.5.12.post1, the versions the repo pins,
publish cached_tokens_total, prompt_tokens_total and
num_retracted_requests_total, which count what vLLM's prefix cache
hits, lookups and preemptions count, in the same units. Counters have
no buckets, so they share vLLM's names. SGLang counts when a request
finishes where vLLM counts when it's scheduled, and labels its hits
with a cache_source. The telemetry docs say so.

sglang:queue_time_seconds stays unmapped: its buckets differ from
vLLM's and between the two pinned SGLang versions (modelplaneai#523).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Dennis Ramdass <dennis@upbound.io>
@github-actions

Copy link
Copy Markdown

Docs preview: https://modelplane-docs-pr-544.vercel.app (ready once the site's Content workflow finishes)

@dennis-upbound dennis-upbound moved this from Backlog to In Review in Modelplane Roadmap Oct 20, 2026

@haarchri haarchri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this update

@dennis-upbound
dennis-upbound merged commit d0086a8 into modelplaneai:main Oct 20, 2026
6 checks passed
@negz negz moved this from In Review to Done in Modelplane Roadmap Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

SGLang's prefix-cache and retraction counters never reach the modelplane_* surface

3 participants