Files
alzeo/tests/test_engine_cache_report.py
T
Hasan BasbunarandClaude Opus 5.5 4c031634ad v1.51: the Liquid AI LFM3 lane (lfm3), on vLLM's own nightly image, in every lane list
Liquid AI's LFM3 1.7B in its official NVFP4 (LiquidAI/LFM3-1.7B-NVFP4 at cfe4b5ea), served by
vllm/vllm-openai's nightly of commit 60bd6dd by digest, pulled as published: LFM3 came to vLLM on
2026-11-06 and is in no release. A text lane of its own on the text lanes' port, behind the proxy and
its key: the key by --config (redacted in vLLM's own log line), the vLLM lanes' middleware for every
route but /health and /metrics, its served name lfm3-1.7b, the model's whole window (262,144), the
qwen3 reasoning parser and the qwen3_coder tool-call parser its template's form asks for, the prompt
tokens details, its own vLLM, FlashInfer and Triton caches. --gpu-memory-utilization is LFM3_GMU, 0.75:
this nightly extends its KV cache into every byte left free after its warmup, and the reference box
kept 1,087 MiB available at its lowest with none set. The prefix cache at vLLM's default for this
hybrid model, measured 99 to 100 % of an agent's next turn.

One engine at a time: Conflicts= and After= with every engine unit, both ways. install-lfm3.sh on
vllm-lane.sh like the other vLLM lanes (--units-only, --prepare, --stage, --uninstall, the proof with a
tool call), refused on a 64 GB box (fits_64 False: no 64 GB share was measured); install.sh puts its
unit in on demand (--no-lfm3, --with-lfm3, --all-weights, 41 GB), switch-model.sh lfm3 fetches its
checkpoint in its own image and points opencode at it, uninstall.sh takes it all, check-pins.sh
checks its revision and its image, the cockpit's sudoers its unit.

Its clients: the opencode provider lfm3 (oc-lfm3.py, its window by oc-limits.sh), pi and omp. Its
template reads enable_thinking, true by default, and no level: opencode offers the high and none
variants, pi off and high alone (HELD_LEVELS maps every other level to null), the two states it holds.

Found on the way: the vLLM lanes' cache-report test now lists it, and its family tests, the lists'
counts and the --all-weights total (1235 GB) follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:38:53 +01:00

61 lines
3.2 KiB
Python

#!/usr/bin/env python3
"""Every text lane asks its engine to say what the prefix cache served (discussion #49): the 27B's units,
run.sh and the flash launcher start SGLang with --enable-cache-report, and the vLLM lanes pass
--enable-prompt-tokens-details (2026-10-25; six since the Liquid AI LFM3 lane, 2026-11-16).
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", "qwen38-flash-launch.sh.template")
FLAG = re.compile(r"(?<![\w-])--enable-cache-report(?![\w-])")
VLLM_UNITS = ("qwen38-kolibri.service.template", "qwen38-nemotron.service.template",
"qwen38-nemotron-super.service.template", "qwen38-flash-local.service.template",
"qwen38-ornith-122b.service.template", "qwen38-lfm3.service.template")
VLLM_FLAG = re.compile(r"(?<![\w-])--enable-prompt-tokens-details(?![\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_sglang_launch_passes_it_once(self):
for name in LAUNCHES:
with self.subTest(name=name):
self.assertEqual(len(FLAG.findall(code(name))), 1)
def test_each_vllm_unit_passes_its_own_once(self):
"""vLLM counts the cached tokens too and says nothing of them without the flag; every vLLM lane's
unit is here, so a seventh one added without the flag fails the second assertion."""
units = sorted(p.name for p in REPO.glob("qwen38-*.service.template") if "vllm serve" in code(p.name)
or "vllm/vllm-openai" in code(p.name) or "--enable-auto-tool-choice" in code(p.name))
self.assertEqual(units, sorted(VLLM_UNITS))
for name in VLLM_UNITS:
with self.subTest(name=name):
self.assertEqual(len(VLLM_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()