Repository navigation
warmup: warm the prompt cache after start and show cache reuse - #67
Open
DevelopmentCats wants to merge 2 commits into
Open
DevelopmentCats wants to merge 2 commits into
DevelopmentCats wants to merge 2 commits into
Conversation
A profile's WARMUP_FILE is a chat request sent after up, restart and switch, and by the router when a server comes back. 'warmup capture' records one from a real request through the router; 'warmup' sends it and reports cached tokens. The router counts prompt and cached tokens per model for status, the panel and /router/stats. vLLM is started with --enable-prompt-tokens-details. Docs cover llama.cpp's prompt cache on hybrid models. Refs #65
There was a problem hiding this comment.
🟡 Changes recommended
The capture endpoint allows anyone with the shared inference API key to retrieve another client’s complete request, exposing messages, conversation history, and tool results.
5 open issues
What changed in this PR
Adds prompt-cache warm-up and reuse reporting to llm-helper, addressing the first-turn latency described in #65 without changing cache-size defaults.
Changes:
- Adds
WARMUP_FILE, capture/manual warm-up commands, and automatic warm-up hooks. - Tracks cached prompt tokens through the router and exposes them in status, the panel, and
/router/stats. - Enables vLLM token details and documents cache behavior, configuration, and limitations.
| File | Description |
|---|---|
internal/web/static/machine.js |
Displays cache percentages. |
internal/web/server.go |
Adds a cache-stat lookup callback. |
internal/web/server_internal_test.go |
Tests cache display for healthy instances. |
internal/web/api.go |
Includes cache percentages in instance status. |
internal/warmup/warmup.go |
Implements request preparation, sending, capture trimming, and usage parsing. |
internal/warmup/warmup_internal_test.go |
Tests warm-up requests and usage handling. |
internal/router/models.go |
Integrates recovery warm-up, capture, and usage inspection. |
internal/router/cache.go |
Implements cache accounting and capture coordination. |
internal/router/cache_internal_test.go |
Tests accounting, capture, and recovery warm-up. |
internal/profile/profile.go |
Defines the WARMUP_FILE profile setting. |
internal/engine/registry_test.go |
Updates expected vLLM arguments. |
internal/cli/watch.go |
Adds warm-up after watched startup. |
internal/cli/warmup.go |
Adds warm-up commands and cache-reporting helpers. |
internal/cli/warmup_internal_test.go |
Tests CLI warm-up and router integration. |
internal/cli/vllmargs_internal_test.go |
Updates expected launch arguments. |
internal/cli/serve.go |
Connects panel status to router cache counts. |
internal/cli/router.go |
Adds stats/capture endpoints and backend warm-up configuration. |
internal/cli/root.go |
Registers the warm-up command. |
internal/cli/root_internal_test.go |
Updates the pinned command list. |
internal/cli/profiles.go |
Adds cache counts to status output. |
internal/cli/editset.go |
Recognizes WARMUP_FILE as a standard key. |
docs/reference/cli/warmup/capture.md |
Adds generated capture-command reference. |
docs/reference/cli/warmup.md |
Adds generated warm-up-command reference. |
docs/reference/cli.md |
Lists the warm-up command. |
docs/providers.md |
Explains llama.cpp cache behavior and sizing. |
docs/profiles.md |
Documents warm-up configuration and capture. |
docs/multi-instance.md |
Documents router cache reporting and limits. |
docs/manifest.json |
Routes the new reference pages. |
CHANGELOG.md |
Records warm-up and cache-reporting features. |
catalogue/engines/vllm.json |
Enables prompt-token cache details. |
Review effort: Balanced
This branch has not been deployed
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.


Refs #65.
The first agent turn on a fresh or restarted server re-reads the whole fixed prompt. This sends that prompt ahead of time and shows how much of each model's prompts is served from cache. The cache size default is unchanged.
What changes
WARMUP_FILE(profile key): path to a JSON/v1/chat/completionsbody. It is sent withmax_tokens: 1:up,restartandswitch, once the server is healthy;It is a plain chat request, so it works on every engine.
llm-helper warmup capture <profile>: the router saves the next chat request for that model, keeps everything before the first user message, replaces that message withHi, writes it under the data directory and setsWARMUP_FILE.llm-helper warmup [profile]: sends the request twice and prints prompt and cached tokens for each send.usage(streamed or not) from chat replies and counts prompt and cached tokens per model. Shown instatus, the panel (cache N%) andGET /router/stats(behind the API key like the rest of the router). Router traffic only.serveargs gain--enable-prompt-tokens-detailsso it reports cached tokens.providers.md(host--cache-ramcache, the hybrid checkpoint limit, setting the size withLLAMA_ARG_CACHE_RAMorEXTRA_ARGS, unified memory),WARMUP_FILEinprofiles.md, cache counts inmulti-instance.md.Not covered
waitForLaunch) have no warm-up hook after boot; the router still warms them when they come up.--enable-prompt-tokens-details, so the router shows no cache share for them.Checks
gofmt -l .,go vet ./...,go test -race ./...(onlyinternal/detect TestProbeReportsThisMachinefails, same as onmain),tools/recipediffvet and tests,prettier --check ..LiquidAI/LFM2-350M-GGUF:Q4_K_M(hybrid) behind the router: the router warmed the backend when it came up, captured a streamed chat (~2.6k-token system prompt plus a tool), and both warm-ups through the router read 2647 of 2656 prompt tokens from the restored checkpoint. The router counts matched. Not tested on the Sparks or on vLLM.