Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

Smart Reply: reuse the system-prompt state (first token 1.40 → 0.81 s); batch work 120k - #669

Merged
techmore merged 1 commit into
devfrom
claude/reply-prefix-cache
Oct 28, 2026
Merged

techmore merged 1 commit into
devfrom
claude/reply-prefix-cache

Conversation

@techmore

Copy link
Copy Markdown
Owner

Two speed-ups for the Smart Reply model server (reply-modeld.py, #666).

  • System-prompt cache: every draft starts with the same fixed instructions (181 of ~225 prompt tokens). The server now keeps the model state after them and reuses a copy per draft, so only the conversation lines are read. The shared prefix is found by comparing the prompt with a probe (Qwen's template can't render a system message alone); a changed system prompt (personal notes) rebuilds it. MSERIES_REPLY_PREFIX_CACHE=0 turns it off.
  • MLX_OMARCHY_BATCH_WORK=120000 in the unit, the scoreboard value (Adopt Honeykrisp 9323171c12 and a 120k MLX submit budget (+45–80% decode) #664).

Five English threads, Qwen3.5-4B, warm averages:

Setting First token Total
No cache, 20k (before) 1.40 s 2.75 s
No cache, 120k 1.36 s 2.89 s
Cache, 20k 0.81 s 2.41 s
Cache, 120k (now) 0.81 s 2.27 s

Verified on the laptop: mseries-reply draft rust/mseries-reply/fixtures/lunch.json 1.8 s → 1.4 s warm, log shows 181 tokens served from the cache.

🤖 Generated with Claude Code

reply-modeld caches the model state after the fixed system prompt (181 of ~225
tokens) and reuses a copy per draft. First token 1.40 -> 0.81 s on the five
English threads; Smart Reply's warm lunch draft 1.8 -> 1.4 s. The service now
uses the scoreboard's MLX_OMARCHY_BATCH_WORK=120000 (no measurable change on
replies this short).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@techmore
techmore merged commit bc9d6cc into dev Oct 28, 2026
18 checks passed
@techmore
techmore deleted the claude/reply-prefix-cache branch October 28, 2026 16:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant