explaingit

bigattichouse/packed-twin-inference

Analysis updated 2026-05-18

12C++Audience · developerSetup · hard

TLDR

A speed technique for local AI models that guesses several upcoming words at once and verifies them in a single batch, making text generation faster with no change to output quality.

Mindmap

mindmap
  root((Packed Twin Inference))
    What it does
      Speeds up local LLM inference
      Same output quality
      Batch-verifies guessed tokens
    Tech stack
      C++
      llama.cpp
      CUDA
    Use cases
      Faster local AI inference
      Faster code editing
      OpenAI-compatible server
    Audience
      Developers
      Self-hosted AI users
    How it works
      Text lookup guesses
      Built-in token predictor
      Safety verification step
    Performance
      2x on code editing
      1.2x to 1.4x on fresh prose
      Falls back to normal speed

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Speed up locally hosted large language model inference on your own GPU.

USE CASE 2

Get faster code editing and refactoring responses from a self-hosted AI coding assistant.

USE CASE 3

Run an OpenAI-compatible local server that serves accelerated model responses to other tools.

USE CASE 4

Study a speculative decoding technique that combines text lookup with a model's built-in token predictor.

What is it built with?

C++llama.cppCUDA

How does it compare?

bigattichouse/packed-twin-inferencecommonmugger/steam-controller-remappercrystalgovernor/osu
Stars121212
LanguageC++C++C++
Setup difficultyhardmoderatehard
Complexity3/54/5
Audiencedevelopergeneralgeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires a capable local GPU and building on top of llama.cpp to run large models.

In plain English

Packed Twin Inference is a technique and codebase for making a locally-run AI language model generate text significantly faster, without changing the quality or accuracy of what it produces. The target audience is people who run large AI models on their own hardware and want to get more tokens per second out of the same GPU. The core problem it addresses is that modern large language models are slow because each word they generate requires loading roughly 25 gigabytes of model weights from GPU memory, and the GPU's actual computing units sit mostly idle during that load. The insight is that verifying a batch of 16 or 32 guesses in a single pass costs only a few times more than generating one token, not 16 or 32 times more. So if you can guess upcoming tokens cheaply, you batch-verify those guesses and accept all the correct ones at once, dramatically increasing throughput. The project combines two sources of free guesses. First, a text lookup: when the model is re-typing something already in the conversation (such as editing code it just wrote, or quoting a document), the continuation can often be found by simple string matching. Second, the specific AI model this is tested with (Qwen3.6-27B) has a small built-in predictor that guesses the next token with about 85% accuracy at a fraction of the cost of a full pass. Both sources are combined so that when they disagree, the built-in predictor wins. A safety mechanism verifies every guess against the model's actual output before emitting it, which means wrong guesses are silently discarded and the final text is byte-for-byte identical to what the model would have produced without any of this acceleration. The project includes a test that deliberately corrupts drafts and confirms the output still matches the baseline. In practice, the speedup depends heavily on what is being generated. Editing and refactoring existing code benefits the most, reaching about 2x faster in measurements. Generating fresh prose with no overlap to the prompt gives a more modest improvement around 1.2x to 1.4x. In the worst case, when every guess is wrong, the system shuts speculation off and runs at roughly normal speed. The code is built on top of llama.cpp, the popular open-source library for running AI models locally. It exposes an OpenAI-compatible server API and a command-line chat interface.

Copy-paste prompts

Prompt 1
Explain how speculative decoding speeds up large language model inference without changing the output.
Prompt 2
Walk me through how this project verifies guessed tokens against the real model output to stay byte-for-byte accurate.
Prompt 3
Help me set up llama.cpp with this speedup technique on my own GPU.
Prompt 4
Explain why editing existing text speeds up more than generating brand new text with this method.
Prompt 5
What GPU and model setup would I need to get the 2x speedup this project reports for code editing?

Frequently asked questions

What is packed-twin-inference?

A speed technique for local AI models that guesses several upcoming words at once and verifies them in a single batch, making text generation faster with no change to output quality.

What language is packed-twin-inference written in?

Mainly C++. The stack also includes C++, llama.cpp, CUDA.

How hard is packed-twin-inference to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is packed-twin-inference for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.