Skip to content

China Tech & Products

Published: November 21, 2026FYZSXNB IntelligenceEN

Discover why quantized models output garbage or repeated tokens, how backend matmul regressions cause compute errors, and how to isolate hardware kernels.

Why Quantized Models Output Garbage Tokens After Loading

Introduction: Diagnosing Post-Load Garbage Token Generation

Deploying quantized Large Language Models (LLMs) to edge devices, specialized digital signal processors (DSPs), and neural processing units (NPUs) is a common strategy to maximize compute efficiency and reduce memory footprints. However, machine learning engineers occasionally encounter scenarios where a model loads into memory cleanly without syntax or file-read errors, but the generation phase immediately deteriorates into repetitive gibberish or nonsensical token loops.

When encountering degenerate model outputs, the initial assumption is frequently that the quantization process itself failed. Developers often suspect damaged scale parameters, zero-point offset miscalculations, or truncated vocabulary mappings. While data-level issues do happen, degenerate outputs can also be triggered at the execution layer. Specifically, low-level matrix multiplication (matmul) kernel regressions introduced in backend runtime updates can corrupt tensor operations during inference while leaving the underlying weight files completely intact.

Symptom Isolation: Hardware Regressions vs. Quantization Format Errors

To diagnose why an inference pipeline produces corrupted text, engineers must differentiate between weight representation errors and backend execution bugs. Quantization-specific errors typically stem from precision collapse, such as dequantization overflow or underflow in low-bit representations. When an issue is inherent to precision reduction, higher-bit formats often mitigate or completely resolve the defect.

In contrast, compute kernel regressions are often format-agnostic across quantized representations. For example, if both 4-bit (such as Q4_0) and 8-bit (such as Q8_0) quantized variants of a model produce the exact same repetitive garbage on a specific accelerator, the root cause is unlikely to be a 4-bit dequantization calculation error. When multiple quantization tiers exhibit identical failure modes, the computational logic executing the matrix multiplication on the target hardware becomes the primary suspect.

A definitive diagnostic test is host execution fallback. Quantized models that fail with repetitive, unparseable output on a specialized hardware accelerator may still execute correctly on standard CPU backends. If a model generates coherent, high-quality responses when executed on a CPU using the exact same weight file, the weights and embedded metadata are structurally sound, isolating the fault to accelerator-specific kernels or driver implementations.

Case Study: Repeated Tokens from the llama.cpp HMX Matmul Rewrite

A concrete example of hardware kernel execution failure is documented in llama.cpp issue #24365, which affected Hexagon Tensor Processor (HTP) v81 hardware (SM8845) on devices such as the DJI RC710 running Hexagon SDK 6.4.0.2. In this incident, a performance-oriented kernel update broke inference generation across multiple model architectures.

Following commit c9872a2 (PR #23368), which reworked the Hexagon Matrix Extensions (HMX) quantized matmul implementation, running models on HTP v81 produced repetitive garbage tokens instead of coherent responses. The failure manifested as repeating token sequences, including outputs like unused17, Us, Game, and OF.

The issue exhibited several key diagnostic characteristics:

  • Model Independence: The failure was not isolated to a single model architecture or size. It reproduced across Qwen3-4B, Qwen3.5-2B, and Gemma4-E2B.
  • Quantization Independence: Testing both Q4_0 and Q8_0 formats on Qwen3.5-2B yielded identical garbage token outputs, demonstrating that low-bit dequantization precision was not the point of failure.
  • Hardware Specificity: The exact same model files executed correctly on the CPU, and had previously functioned correctly on HTP v81 prior to commit c9872a2.
  • Kernel Root Cause: The commit rewrote the HMX matmul kernel, switching its operational structure from spatial mode to activation depth mode. This computational path rework introduced the regression on the HTP v81 accelerator.
Failure TypeCPU ExecutionFormat DependencyRoot Cause Layer
Quantization Precision LossOutputs garbage or degradesUsually format-specific (Q4 fails, Q8 succeeds)Weight conversion or scale calculation
Backend Matmul RegressionOutputs coherent textAffects multiple formats (both Q4_0 and Q8_0 fail)Accelerator compute kernel / execution logic

Evaluating General Quantization Failure Modes

While backend kernel rewrites provide a clear explanation for specific hardware failures, engineers must remain cautious not to generalize a single accelerator regression to all deployment errors. General quantization failures outside this specific case—such as missing chat templates, incorrect rotary position embedding (RoPE) frequency scaling, prompt truncation, or out-of-memory driver crashes—must be independently verified against broader runtime documentation.

Furthermore, hardware-specific kernel modifications, such as changing an HMX matmul from spatial mode to activation depth mode, do not automatically impact all hardware architectures or vendor backends. When debugging model corruption, engineers should verify the specific compute path utilized by their hardware rather than assuming a universal runtime bug.

Practical Verification Checklist: Debugging Accelerator Regressions

When a quantized model outputs repetitive or garbage tokens immediately after loading, apply the following systematic verification steps to isolate the fault:

  1. Execute on CPU: Force model inference onto the CPU backend. If the CPU produces expected, coherent text from the identical model file, rule out permanent weight conversion corruption.
  2. Test Higher-Bit Quantization: Run an 8-bit quantized variant (e.g., Q8_0) alongside the lower-bit model (e.g., Q4_0). If both formats yield identical nonsensical token strings, eliminate bit-width dequantization artifacts from your investigation.
  3. Test Multiple Model Architectures: Run a lightweight alternate model family on the target accelerator. If different model architectures produce identical repetitive token loops, the failure lies within the shared compute kernels.
  4. Perform Commit Bisecting: If running an open-source inference engine such as llama.cpp, bisect recent commits targeting your specific accelerator backend (such as recent matmul reworks or driver interface updates) to identify when the regression was introduced.
  5. Review Accelerator Kernel Modes: Inspect recent driver or runtime changes to matrix multiplication dispatch modes (for example, shifts between spatial and activation depth processing modes) on the target NPU or DSP architecture.

Sources and evidence status

Status: each page was opened once, without signing in and without bypassing access controls. Opening a page does not prove that it supports every sentence; unsettled points are flagged in the text.

Need to verify a part, model or supplier?

Send the model number, photos or documentation.

Contact us