Repository navigation
Description
name: {{$now}} prompt variable silently kills prefix caching
about: Report a problem with the Unsloth Studio desktop app or web UI
title: "[Studio Bug] {{$now}} prompt variable silently kills prefix caching (full prefill every request)"
labels: bug
Environment
Where are you using Unsloth?
- Studio desktop application
- Studio web UI (
unsloth studio) - Unsloth CLI
- Python package or notebook
- Colab or Kaggle
Operating system and version:
Windows 11 25H2 (x64)
GPU model(s) and accelerator backend:
NVIDIA RTX 5070 Ti 16GB + RTX 5060 Ti 16GB, NVIDIA CUDA
Versions:
Unsloth Version
v0.1.800-beta
Package Version
2026.8.18
llama.cpp Version
b10360-mix-87da1a2
What happened?
Steps to reproduce:
- Add the {{$now}} prompt variable to the system prompt (e.g. as a "The current time is {{$now}}" line)
- Run a chat with any model and let the conversation grow (example at ~42k tokens)
- Send a message: ~55s to first token (full prompt processed at ~755 tok/s)
- Send another (even just "ok"): same ~55s. Every request, every chat, forever.
Expected behavior:
After the first message, the KV/prefix cache should be reused for the identical prompt prefix; 2nd+ messages should have sub-second first token.
Actual behavior:
Full prompt is re-processed on EVERY request. {{$now}} gets filled with the current time (second precision) on each request, so the first tokens of the prompt differ every time → prefix cache never matches → full prefill every message. At 100k+ filled context this became 90s+ per message.
Model and operation involved:
Qwen3.8-27B Q4_K_M (GGUF), inference/chat.
Diagnostics and logs
N/A - no crash, pure performance issue. Key numbers:
| Setup | First token | Cache hits |
|---|---|---|
| with {{$now}} | 55,310 ms | full re-process |
| without | 950 ms | 51,765-67,940 tok |
Same model, same settings, same rig. Only difference was that one line.
Desktop application
N/A (no crash/error screen, "Copy Diagnostics" not applicable)
Studio web UI
N/A
Model-specific logs, if applicable
N/A
Python package or notebook, if applicable
N/A
Additional context
- The tell IS in the stats panel but easy to miss: when nothing is reused, the "Cache hits" row is hidden entirely instead of showing 0.
- Moving the variable to the BOTTOM of the system prompt does NOT help - the conversation still comes after it, so the whole chat gets rebuilt every turn. For a system-prompt variable the only real fixes are day precision ({{$date}}) or removal.
- Workaround: use {{$date}} instead of {{$now}} - instant fix (55.3s → 0.95s).
- This took me days to figure it out, I tried putting all kinds of params like: "--swa-full --cache-reuse 256 --ctx-checkpoints 4" etc.
Suggested fixes :
Warn in the prompt-variables UI when {{$now}}/{{$time}} is used in the system prompt - a tooltip like: "high-precision time variables kill prefix caching - use {{$date}} or remove"
OR remove the {{$now}} entirely.
The idea is - for the casual users like me is hard to track this down as an issue.
REPORT MADE with the help of my LLM, since English is NOT my main language, and I'm also not that technical.
Activity
danielhanchen commentedon Oct 5, 2026
We recently added #8879 which will auto set dates and new dates which miss the prefix cache make it a new user message to not miss the prefix cache