27B lane: SGLang says what the prefix cache served (#49)

Discussion #49 asked for --enable-cache-report. With it, each answer says
how much of its prompt the prefix cache served:
usage.prompt_tokens_details.cached_tokens on the OpenAI routes (8,192
then 9,472 of a 9,539-token prompt that repeats its system message),
cache_read_input_tokens beside input_tokens on /v1/messages (31 and
9,600 where it said 9,631 before), and the proxy's
x-systemone-cached-tokens (0, then 2,176). Without it the cache serves
the same and says nothing.

Measured on the 27B lane behind the proxy on 2026-10-24, with the flag
and without: the SDKs, fetch under Node and Bun, LiteLLM, Claude Code,
opencode, Hermes and pi each did their task; opencode 1.19.4 recorded
33,536 of a turn's 33,650 prompt tokens as read from the cache, its
total unchanged, so it compacts where it did; bench.sh gave 64.9 against
64.0 tok/s (three runs each, their spreads overlapping).

The three 27B units and run.sh pass it, and the recipes' drift check
knows the switch. The flash lane, on another build, is not measured and
does not pass it. tests/test_engine_cache_report.py fails on the old
files and passes on the new ones; the 28 test modules that read these
files pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-10-24 10:20:12 +02:00
1 parent ee1980e709
commit a9fd5e4c3d
7 files changed
+64 -6

No files matched your search

+1
View File
@@ -118,6 +118,7 @@ SWITCHES = (
# endpoint every fleet asks for; unauthenticated
# on the engine port, same trust model as that
# port's whole surface (SECURITY.md)
"--enable-cache-report", # 27B lanes: each answer says what the prefix cache served (#49)
"--disable-prefill-cuda-graph",
"--ple-offload-embedding", # flash lane: the only reason 176B fits one GB10
"--trust-remote-code",
+3 -2
View File
@@ -62,8 +62,9 @@ one to ten levels, which is what the live API answers rather than what its docs
contract report what it has no room for: `x-systemone-label-mass` (how much of the model's
first-token probability landed on any label; near 1 means the prompt worked),
`x-systemone-branches`, and `x-systemone-cached-tokens` when the engine runs with
`--enable-cache-report` (neither lane does today, so the fan-out table below reads the cache
through latency instead).
`--enable-cache-report`, as the 27B lane does since discussion #49 (0, then 2,176 on a second
question about the same state, measured 2026-10-24). The flash lane does not, and the fan-out table
below, measured before, reads the cache through latency.
**Why `top_logprobs` on `/v1/chat/completions`, and never `token_ids_logprob` on `/generate`.**
On the served build, `get_token_ids_logprobs_raw` appends a bare `[]` for a co-batched request
+5 -1
View File
@@ -21,6 +21,10 @@ ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-preflight.sh qwen38-sglang
# The key goes to the server in a file SGLang merges in memory (see engine-secrets.sh),
# written again before every start, so it is on no command line.
ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-secrets.sh
# --enable-cache-report: each answer says how much of its prompt the prefix cache served
# (usage.prompt_tokens_details.cached_tokens, and cache_read_input_tokens beside input_tokens on
# /v1/messages), which the engine counts anyway. Asked in discussion #49, measured on this lane
# on 2026-10-24: every client did its task, and the throughput did not move.
ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpus all \
--memory 100g --memory-swap 100g --shm-size 16g --network host --ipc=host \
-e TORCHINDUCTOR_CACHE_DIR=/cache/inductor -e SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 -e HF_HUB_OFFLINE=1 \
@@ -43,7 +47,7 @@ ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpu
--max-mamba-cache-size 96 --max-running-requests 8 \
--enable-torch-compile --torch-compile-max-bs 4 \
--num-continuous-decode-steps 2 --sleep-on-idle \
--enable-metrics \
--enable-metrics --enable-cache-report \
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
--chat-template /out/chat-template-sglang.jinja \
--config /out/engine-secrets.yaml \
+5 -1
View File
@@ -29,6 +29,10 @@ ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-preflight.sh qwen38-sglang
# The key goes to the server in a file SGLang merges in memory (see engine-secrets.sh),
# written again before every start, so it is on no command line.
ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-secrets.sh
# --enable-cache-report: each answer says how much of its prompt the prefix cache served
# (usage.prompt_tokens_details.cached_tokens, and cache_read_input_tokens beside input_tokens on
# /v1/messages), which the engine counts anyway. Asked in discussion #49, measured on this lane
# on 2026-10-24: every client did its task, and the throughput did not move.
ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpus all \
--memory 32g --memory-swap 32g --shm-size 8g --network host --ipc=host \
-e TORCHINDUCTOR_CACHE_DIR=/cache/inductor \
@@ -52,7 +56,7 @@ ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpu
--max-mamba-cache-size 12 --max-running-requests 4 \
--enable-torch-compile --torch-compile-max-bs 4 \
--num-continuous-decode-steps 2 --sleep-on-idle \
--enable-metrics \
--enable-metrics --enable-cache-report \
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
--chat-template /out/chat-template-sglang.jinja \
--config /out/engine-secrets.yaml \
+5 -1
View File
@@ -21,6 +21,10 @@ ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-preflight.sh qwen38-sglang
# The key goes to the server in a file SGLang merges in memory (see engine-secrets.sh),
# written again before every start, so it is on no command line.
ExecStartPre=/bin/bash __HOME__/.config/qwen38/engine-secrets.sh
# --enable-cache-report: each answer says how much of its prompt the prefix cache served
# (usage.prompt_tokens_details.cached_tokens, and cache_read_input_tokens beside input_tokens on
# /v1/messages), which the engine counts anyway. Asked in discussion #49, measured on this lane
# on 2026-10-24: every client did its task, and the throughput did not move.
ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpus all \
--memory 100g --memory-swap 100g --shm-size 16g --network host --ipc=host \
-e TORCHINDUCTOR_CACHE_DIR=/cache/inductor \
@@ -44,7 +48,7 @@ ExecStart=/bin/bash -c 'exec /usr/bin/docker run --rm --name qwen38-sglang --gpu
--max-mamba-cache-size 96 --max-running-requests 8 \
--enable-torch-compile --torch-compile-max-bs 4 \
--num-continuous-decode-steps 2 --sleep-on-idle \
--enable-metrics \
--enable-metrics --enable-cache-report \
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
--chat-template /out/chat-template-sglang.jinja \
--config /out/engine-secrets.yaml \
+1 -1
View File
@@ -151,6 +151,6 @@ exec docker run --rm --name qwen38-sglang-run --gpus all \
--reasoning-parser qwen3 --tool-call-parser qwen3_coder \
--chat-template /out/chat-template-sglang.jinja \
--sleep-on-idle \
--enable-metrics \
--enable-metrics --enable-cache-report \
--config /out/engine-secrets.yaml \
--host "$ENGINE_BIND" --port "$PORT"
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""The 27B's units and run.sh start SGLang with --enable-cache-report (discussion #49, 2026-10-24).
With it, each answer says how much of its prompt the prefix cache served:
usage.prompt_tokens_details.cached_tokens on the OpenAI routes, cache_read_input_tokens beside
input_tokens on /v1/messages, and the proxy's x-systemone-cached-tokens. Without it the cache
serves the same and says nothing. Measured on the 27B lane behind the proxy on 2026-10-24, with the
flag and without: the SDKs, fetch under Node and Bun, LiteLLM, Claude Code, opencode, Hermes and pi
each did their task, opencode's total and Claude Code's count stayed what they were, and bench.sh
gave 64.9 against 64.0 tok/s (three runs each, their spreads overlapping). The recipes' drift check
knows the switch, so a 27B unit written before it says so in the cockpit.
"""
import pathlib
import re
import sys
import unittest
REPO = pathlib.Path(__file__).resolve().parents[1]
LAUNCHES = ("qwen38-sglang.service.template", "qwen38-sglang-1m.service.template",
"qwen38-sglang-64.service.template", "run.sh")
FLAG = re.compile(r"(?<![\w-])--enable-cache-report(?![\w-])")
def code(name):
"""The file without its comment lines: a flag named in prose is not passed."""
return "\n".join(ln for ln in (REPO / name).read_text().splitlines() if not ln.lstrip().startswith("#"))
class TheFlagIsPassed(unittest.TestCase):
def test_each_27b_launch_passes_it_once(self):
for name in LAUNCHES:
with self.subTest(name=name):
self.assertEqual(len(FLAG.findall(code(name))), 1)
def test_the_recipes_see_a_unit_without_it(self):
sys.path.insert(0, str(REPO / "dashboard"))
import recipes
self.assertIn("--enable-cache-report", recipes.SWITCHES)
self.assertTrue(recipes._switches("--enable-metrics --enable-cache-report")["--enable-cache-report"])
self.assertFalse(recipes._switches("--enable-metrics --enable-cache-reports")["--enable-cache-report"])
if __name__ == "__main__":
unittest.main()