Where GGUF Quantization Loses Precision: Dual-Model Token Divergence and Sampler Cutoff with inside-llm

Hands-on benchmark of single-binary tool inside-llm comparing Q2_K and Q8_0 GGUF weights side-by-side to inspect token divergence lines, sampler pipeline cutoffs, and Logit Lens hidden state dynamics.

Anyone running local large language models has faced this dilemma when selecting a quantization tier.

You hesitate before downloading weights.

If you download Q8_0, files easily span a dozen gigabytes. Your GPU VRAM cannot hold them; once weights spill into system RAM, generation speeds collapse to two or three tokens per second, turning the terminal into a slideshow.

If you download Q2_K or Q3_K, the weight files fit into VRAM comfortably, yet doubts linger. How much reasoning capability was cut away by extreme 2-bit or 3-bit compression? Academic papers publish neat perplexity tables, but what do those numbers actually mean for daily programming and logical inference?

Nobody can tell from a perplexity score alone.

Degradation in model intelligence is rarely a uniform decline. Instead, it hits a specific pivot point across long reasoning traces. As probability distributions flatten out, the sampler picks a candidate that appears grammatically sound but is factually derailed. From that single token onward, subsequent generation cascades into complete hallucination.

Why does it derail so abruptly?

Previously, inspecting decision divergence between two quantization levels required writing custom Python scripts with model forward hooks to capture raw logits. That workflow was tedious and debugging efficiency was painfully low.

Recently, an open-source project named inside-llm emerged on GitHub. It turns this cumbersome workflow into a single self-contained binary inspection tool.

Authored by Manuel García, the repository lives at https://github.com/manuelgscom/inside-llm under the MIT license. It embeds a native llama.cpp engine inside the binary. In the browser, it loads two GGUF weights side-by-side and pinpoints the exact boundary where outputs diverge token by token.

How does it run under the hood? Is it genuinely practical?

I pulled it onto a local workstation for a hands-on verification run.

inside-llm UI: side-by-side model probability comparison, sampler gate filtering stages, and 3D probability relief

1. Hardware Environment and Single-Binary Architecture: How It Runs

To keep benchmark figures grounded, here is the hardware environment:

Many visualization analysis suites are notorious for tedious configuration. You first configure Python virtual environments, install PyTorch, and wrestle with native build dependencies; whenever CUDA runtime versions mismatch, environment setup consumes half a working day.

The architectural choice of inside-llm reflects old-school C++ pragmatism. The backend engine is written in C++17, linking statically against llama.cpp and ggml. The web frontend is built with Svelte 5, using three.js for 3D probability relief rendering. During compilation, all frontend web assets are embedded directly into the standalone binary executable.

After granting execution permissions via chmod +x, you run the binary directly in the shell. The console prints a single line stating listening on :8642 and stays completely quiet.

Open your browser and navigate to http://localhost:8642 — the user interface renders instantly. No pip install, no npm run dev, and no commercial API key configuration. When I first ran it, I instinctively checked the README for required environment variables, only to realize none were needed.

# Grant execution permissions
chmod +x ./inside-llm

# Start the local dual-model inspection engine on port 8642
./inside-llm --port 8642

Data communication relies on lightweight binary frames streaming over WebSockets between the browser and the underlying C++ engine.

Official precompiled releases provide both Linux and Windows binaries with CUDA and Vulkan backends. Even on an office workstation lacking the full CUDA developer toolkit, as long as your GPU driver is installed, unpacking the archive lets you run it immediately.

2. Dual-Stream Side-by-Side Comparison: Catching Token Divergence Between Q2_K and Q8_0

Inside the web UI, the core workflow involves picking Model A and Model B.

A strict prerequisite applies here: both models must share the exact same tokenizer vocabulary. I selected two quantization tiers from the same lineage for controlled comparison:

Regarding loading overhead, both models map into memory via mmap: Model A takes 1.2 seconds to load, while Model B takes 4.1 seconds. First-token latency measures 310 milliseconds, and dual-stream lockstep throughput stabilizes at 28.4 tokens per second.

The interface offers two execution modes:

Testing with a complex concurrent counter reasoning trace demonstrated the phenomenon clearly. For the first thirty tokens, generation between both models aligned perfectly. At token position 31, divergence erupted.

Where did it deviate?

The probability bar chart revealed the cause instantly.

On the Q8_0 side, the candidate token eight commanded a massive 0.87 probability, suppressing competing candidates into flat terrain.

Switching to Q2_K, eight plummeted to 0.31 while six climbed to 0.29. A cluster of tail candidates that normally sat below 0.01 was artificially elevated to roughly 0.05.

The probability was not lost; it was flattened out by quantization noise. Once distributions flatten, even minor sampler jitter picks the wrong branch.

In the Stream panel, divergence points are highlighted with a prominent magenta marker. Opening the candidate inspector reveals mirrored probability bar charts.

The right panel displays Shannon entropy and bidirectional Kullback-Leibler divergence: treating Q8_0 as reference distribution P and compressed Q2_K as candidate distribution Q. Prior to token position 31, KL divergence hovered steadily near 0.04; at this specific token, the divergence value leaped to 1.82. Quantization precision loss is no longer an abstract label, but a measurable jump coordinate on a timeline.

3. Sampler Pipeline Tracking: What Do Top-k, Top-p, and Min-p Actually Prune?

When tuning sampler parameters in ollama or llama-server, many teams rely entirely on guesswork. Should temperature be 0.7 or 0.8? Does Top-p at 0.9 prune away valid creative candidates? How does the widely praised Min-p threshold improve upon traditional cutoffs?

Usually tuning feels like guessing outside a black box. inside-llm cuts a transparent skylight into that box.

Its Gates panel reproduces the entire llama.cpp sampler filtering chain. When a raw logits vector emerges, it passes sequentially through repetition penalties, Top-k, Top-p, Min-p, temperature scaling, and GBNF grammar constraints. Above each filtering stage, the UI displays the exact count of surviving candidate tokens.

# Launch with specific model pairs and custom context length
./inside-llm \
  --model-a ./models/Qwen2.5-7B-Instruct-Q2_K.gguf \
  --model-b ./models/Qwen2.5-7B-Instruct-Q8_0.gguf \
  --ctx 4096

Clicking any filtering stage immediately renders distribution comparison charts before and after truncation.

The actual behavior was eye-opening:

You might assume Top-p 0.9 is lenient, yet in high-confidence contexts where the top token holds 0.92 probability, Top-p cuts away thousands of viable alternative tokens at the very first step. Conversely, under flat distributions, Top-p admits dozens of ambiguous edge tokens.

In contrast, setting Min-p to 0.05 links the truncation floor dynamically to top candidate confidence: when top token confidence reaches 0.92, the absolute cutoff threshold scales automatically to 0.046, cleanly eliminating the 0.01 to 0.03 tail noise elevated by Q2_K quantization. That visual feedback proves far more instructive than scanning documentation.

4. Logit Lens Hidden State Projection: At Which Layer Does the Model Decide?

If inside-llm only displayed final logits, it would merely be a polished debugging UI. Adding the --lens flag activates an embedded full-layer hidden state projection mechanism based on Logit Lens.

The Qwen2.5-7B architecture contains 28 Transformer layers. Does the model reach its conclusion at the final layer, or has it locked onto the winning candidate deep inside intermediate layers?

Enabling Logit Lens reveals a 2D layer-by-step projection map below the main workspace, which can also be viewed as a 3D probability relief landscape. The horizontal axis represents generation timesteps, while the vertical axis represents neural network physical depth.

Evaluating an algorithmic complexity proof prompt revealed striking dynamics. Upon prompt ingestion, candidates across the first five layers remained high-entropy noise.

At which layer does the answer solidify?

Around layer 14, probability for the key algorithm identifier began coalescing. By layer 21, even with seven remaining layers ahead, candidate confidence surged past 82%; subsequent layers merely refined grammatical transitions and punctuation.

On the heavily degraded Q2_K model, this probability coalescence was delayed until layer 25, leaving intermediate computations vulnerable to subtle attention weight shifts.

Furthermore, you can click any branching node along the generation timeline. Using in-memory context snapshots, the engine rewinds state to the moment before divergence occurred, resuming exploration from an alternative candidate. That capability provides an invaluable testbed for diagnosing sporadic hallucinations.

5. Technical Boundaries and Low-Spec Tradeoffs

While this tool is remarkably effective, several physical constraints demand consideration during practical deployment.

First is VRAM capacity. Do not attempt to run two 7B models concurrently on an 8GB GPU. During my initial test without adjusted arguments, the two models combined exceeded 10GB, immediately triggering a CUDA error: out of memory failure halting at ggml_cuda_compute_forward.

Can an 8GB card handle dual models?

Dropping layers via -ngl 18 allowed execution, but spilling layers into system RAM plummeted generation throughput from 28 tokens per second down to 3.8. A complete code trace comparison took forty minutes.

Who wants to endure that delay during interactive debugging?

The tool is not unusable on 8GB hardware, but interactive inspection becomes impractical when each token takes seconds. For 8GB setups, pairing two 3B models yields a much smoother inspection workflow.

Second is tokenizer alignment. Both models must share an identical model family and vocabulary. Comparing Llama-3 against Qwen2.5 side-by-side fails because disparate tokenizer encodings make token ID matching impossible, rendering divergence metrics meaningless.

Third is current text-only modality. While multimodal model files can be loaded by the backend, the web UI currently captures probabilities solely along text generation paths; visual attention projection remains unsupported.

Whenever I evaluate quantization releases now, I run them through inside-llm first. Passing identical prompts reveals the exact token index where outputs diverge. If divergence arrives early, the task is precision-sensitive and requires Q5_K_M or Q8_0; if divergence delays across hundreds of tokens, Q2_K suffices, freeing VRAM to double the context window.

The tool is not an all-powerful silver bullet. It stops if vocabularies mismatch, and multimodal models remain unsupported for now. The author noted in issue trackers that visual projection is underway. For text inspection today, it gets the job done cleanly.

How much usable VRAM remains on your GPU after desktop overhead? Calculate your headroom with nvidia-smi before pulling weights blindly.

💬 Discussion

GitHub Powered