StepCache: Step-Level Reuse with Lightweight Verification and Selective Patching for LLM Serving
Organizations: Department of Science, Technology & Mathematics, Lincoln University, USA
Abstract
We address LLM serving workloads where repeated requests share a common solution structure but differ in localized constraints, such as output schema, variable names, or numeric constants. Prior caching approaches typically reuse either full responses (semantic caching) or model-internal KV/prefix states, which are respectively brittle under partial changes or tightly coupled to specific backends. We present StepCache, a backend-agnostic step-level reuse layer that segments outputs into ordered steps, retrieves the best-matching cached request, verifies steps using lightweight task-aware checks, and regenerates only failing regions via selective patching. StepCache additionally supports strict structured-output enforcement for JSON, including single-step extraction, required-key constraints, and one-shot repair, as well as conservative skip-reuse fallbacks for semantic changes. For linear equations, StepCache promotes verification into correction via a bounded repair loop with a deterministic fallback that guarantees correctness when the backend model fails. In a CPU-only perturbation-heavy micro-benchmark on math and JSON variants, averaged over three seeds, StepCache reduces mean latency from 2.13 s to 0.67 s, median latency from 2.42 s to 0.01 s, and p95 latency from 3.38 s to 3.30 s. It also reduces total token usage from 36.1k to 27.3k and improves end-to-end correctness from 72.5% to 100% under task-specific checks and a stitched-output integrity check. Across requests, 79.7% take the reuse-only fast path, 5.4% require patching, and 14.9% trigger skip-reuse.
Figures & tables
| Metric | Baseline | StepCache |
|---|---|---|
| Mean latency (s) | 2.13 0.04 | 0.67 0.04 |
| Median latency (s) | 2.42 0.05 | 0.01 0.00 |
| p95 latency (s) | 3.38 0.03 | 3.30 0.04 |
| Total tokens (all) | 36.1 0.1k | 27.3 0.9k |
| Tokens / request | 162.7 0.6 | 123.0 4.0 |
| Quality pass rate | 72.5 0.5% | 100% |
| Task | Perturb | ReuseOnly% | Patch% | Skip% | Tokens Saved | Final% |
|---|---|---|---|---|---|---|
| json | low | 100.0 | 0.0 | 0.0 | 119 | 100 |
| json | med | 100.0 | 0.0 | 0.0 | 84 | 100 |
| json | high | 100.0 | 0.0 | 0.0 | 89 | 100 |
| json | keys_change | 0.0 | 100.0 | 0.0 | -42 | 100 |
| math | low | 96.7 | 0.0 | 3.3 | -17 | 100 |
| math | med | 96.7 | 0.0 | 3.3 | 19 | 100 |
LLM Serving
Large language model serving studies how to deliver model responses with low latency, high throughput, and efficient use of compute and memory.
See all 207 papers