Skip to content

Weeks 9-11: speculative decoding + persistent KV cache #6

Description

@ai-hpc

Goal

Speculative decoding (draft model accelerating a target model) and persistent KV cache across multi-turn conversations. These are the two biggest end-user latency wins after the basic decode loop is fast.

Tasks

Speculative decoding

  • Add --draft-model <gguf> flag. Use a small model (e.g., TinyLlama Q4) to draft and the production model (Phi-4-mini Q4) to verify.
  • Implement n-gram draft acceptance + reject-and-recompute path in src/engine/.
  • Measure tok/s with vs without on the Week 2 corpus.

Persistent KV cache

  • Disk-backed cache for the last N conversations (/opt/jllm/data/kv-cache/<conv-id>.bin).
  • On a multi-turn call, hydrate the cache for the matching conversation id before decode.
  • Size cap + LRU eviction.

Acceptance

  • Speculative decoding delivers ≥1.5× tok/s on the Week 2 corpus with the same final-text output (no quality regression).
  • Persistent KV cache reduces second-turn prompt-eval time by ≥80%.
  • All Week 1 coherence + Week 3 kernel + Week 6 multi-model tests still pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    betaBeta milestone work

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions