Module prompt_lookup

Module prompt_lookup 

Source
Expand description

2026-10-02: Prompt-lookup decoding: copy proposals from a sequence’s own history (prompt and generated tokens). An index maps every n-gram of the history to the position just after its latest occurrence, so a proposal costs one hash lookup however long the history is. The proposal is the continuation of that occurrence, up to a window that doubles after a fully accepted copy and halves after a broken one. Host code only.

Owner: speculative. Invariants:

  • A proposal is only ever a slice of the history it was asked about: the n tokens before its start equal the history’s last n tokens, it is non-empty, and it never reaches past the history’s end.
  • The index never holds the history’s own final n-gram (it has no continuation yet), so a proposal never points at the suffix itself.
  • A stale entry (left by a rewind of the history) can never produce a proposal: every hit is re-checked token by token before it is used.
  • CopyWindow::current stays within [min, max].

Structs§

CopyWindow
2026-10-02: Copy window: how many tokens a copy may propose. It doubles after a copy is accepted in full and halves after one is cut short.
PromptLookupConfig
2026-10-02: Serve-wide prompt-lookup settings (--prompt-lookup-*).
PromptLookupIndex
2026-10-02: Per-sequence n-gram index over a token history.
PromptLookupSeq
2026-10-02: One sequence’s prompt-lookup state: its index, its copy window, and the length of the copy now awaiting verification (0 when the pending drafts are the model drafter’s).

Constants§

WINDOW_START
2026-10-02: Where a sequence’s copy window starts (capped at --prompt-lookup-max-drafts). A short first copy bounds the verify rows an untested match can waste; a fully accepted copy doubles the window.

Functions§

backoff_rounds
2026-10-02: Rounds to skip after misses copies in a row that matched nothing: 2^(misses-1), capped at cap (0 for no backoff).