diff --git a/dashboard/recipes.py b/dashboard/recipes.py index d8820a3e..9e41fdbd 100644 --- a/dashboard/recipes.py +++ b/dashboard/recipes.py @@ -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", diff --git a/docs/systemone.md b/docs/systemone.md index ad32e856..d25d699e 100644 --- a/docs/systemone.md +++ b/docs/systemone.md @@ -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 diff --git a/qwen38-sglang-1m.service.template b/qwen38-sglang-1m.service.template index 3a204d47..1e695ae2 100644 --- a/qwen38-sglang-1m.service.template +++ b/qwen38-sglang-1m.service.template @@ -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 \ diff --git a/qwen38-sglang-64.service.template b/qwen38-sglang-64.service.template index b80ac95c..9edfc4a6 100644 --- a/qwen38-sglang-64.service.template +++ b/qwen38-sglang-64.service.template @@ -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 \ diff --git a/qwen38-sglang.service.template b/qwen38-sglang.service.template index 3a9fb631..a5af7776 100644 --- a/qwen38-sglang.service.template +++ b/qwen38-sglang.service.template @@ -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 \ diff --git a/run.sh b/run.sh index 8c5c88cf..653eea72 100755 --- a/run.sh +++ b/run.sh @@ -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" diff --git a/tests/test_engine_cache_report.py b/tests/test_engine_cache_report.py new file mode 100644 index 00000000..e253d29d --- /dev/null +++ b/tests/test_engine_cache_report.py @@ -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"(?