In local language model deployment, speculative decoding has long represented the gold standard for accelerating token generation without sacrificing output quality. However, traditional speculative decoding carries an uncomfortable tax: it requires running two separate models in lockstep.

Under standard setups, developers must load a small 'draft model' (typically 1B to 3B parameters) alongside their primary 70B foundation model. While the draft model generates candidate tokens quickly, running neural forward passes across two distinct weight matrices clogs memory bandwidth and consumes valuable VRAM on unified-memory hardware.

A newly merged optimization in llama.cpp fundamentally changes this trade-off by implementing an ultra-optimized C++ variant of Prompt Lookup Decoding (PLD).

The core architectural insight behind PLD is deceptively simple: in modern software engineering, document retrieval, and editing workflows, the generated response rarely consists of entirely novel vocabulary. When an LLM refactors a Python function or answers questions about an uploaded PDF, the generated tokens are overwhelming re-combinations of phrases, variable names, and data structures already present in the prompt.

Rather than invoking a neural draft model, PLD constructs a lightweight in-memory n-gram index (supporting 2, 3, and 4-gram window spans) directly over the prompt buffer. When the model generates a sequence matching an existing n-gram prefix, the engine instantly grabs the subsequent tokens directly from memory in a microsecond hash lookup and submits them as draft candidates to the main model for parallel verification.

Benchmark measurements published by the development team demonstrate that the n-gram drafting phase executes up to 42 times faster than running a 1B draft model on CPU/Metal backends. In code completion and multi-turn editing tasks, prompt acceptance rates reach 65% to 74%, resulting in an end-to-end 2.4x to 3.1x wall-clock speedup with zero extra VRAM allocation.

The achievement underscores a vital trend in systems engineering: before defaulting to brute-force neural compute, algorithmic exploitation of data redundancy and classical memory indexing can deliver extraordinary performance breakthroughs.