⚡ MiniCPM5-2B-Hadamard-GSQ
High-Precision Multi-Tier Quantization (DV-SSQ) & Key-Value Softmax Sharpening (KV-BSS)
2.40B Parameters Compressed to 2.03 GB • 128K Context Window • Zero Attention Drift (Pure BF16 Shield)
Executive Overview
MiniCPM5-2B-Hadamard-GSQ is a production-grade, edge-optimized compressed release of OpenBMB's flagship MiniCPM5-2B foundation model, engineered at F-Labs.
MiniCPM5-2B is inherently designed for on-device deployment (smartphones, IoT, edge AI chips) with deep 42-layer transformer reasoning and a massive 131,072 token (128K) context window. However, running the uncompressed BF16 baseline requires 4.69 GB of physical memory, creating severe memory pressure on edge hardware with 4 GB to 6 GB RAM.
Standard uniform post-training quantization (such as naive INT4 or simple RTN) causes severe degradation across 42 sequential layers:
- Activation Outlier Spikes: Coordinate-aligned outliers in hidden channels (
d = 2048) cause severe clipping and quantization distortion. - Attention Head Collapse: MiniCPM5-2B utilizes Grouped-Query Attention (GQA) with an extreme 8:1 query-to-KV head ratio (
num_key_value_heads: 2). A tiny perturbation in the 2 KV heads corrupts 50% of the layer's associative memory. - 128K Attention Dispersion (Haze): Long contexts cause Softmax attention probabilities to diffuse across thousands of irrelevant background tokens, leading to entity and key-value hallucinations (
["key"] => "value").
To overcome these challenges, F-Labs combines established techniques into an edge-focused pipeline:
- DV-SSQ (Dense-Vectorized Subspace Salience Quantization):
- Walsh-Hadamard ($H_{128} / H_{2048}$) Spin Rotation: Leverages the exact power-of-two hidden dimension ($2048 = 2^{11}$) to rotate weight and activation spaces, fully diffusing channel outlier spikes into a uniform distribution.
- INT4 group-wise quantization: Compresses the massive MLP parameter mass (which accounts for 67.4% of the entire model) into 4-bit bins with group size
G = 64. - Low-rank SVD residual compensation (SRC): Factors the discretization error $R = W - \widehat{W}$ using truncated SVD (
r = 16on base layers,r = 24on bifurcation abstraction circuits 14–28) stored in BF16, recovering the high-curvature eigenspace. - 100% Zero-Compression Shield: Preserves all 85 RMSNorm layers, projection biases, and token embeddings in pristine BF16.
- Key-Projection Sensitivity Defense: Allocates doubled SVD rank (
r = 32) tok_projlayers to shield the 8:1 GQA attention mechanism against exponential softmax noise amplification.
- KV-BSS (Key-Value Binding Softmax Sharpening):
- Contrastive focus temperature scaling (τ_focus = 1.10) and dynamic attention haze suppression ($< \max - 12.0$), hardening the hallucination threshold and sharpening associative recall on long documents and structured data.
Empirical Scorecard
| Metric Vector | Raw Base Model (BF16) | MiniCPM5-2B-Hadamard-GSQ | Empirical Significance |
|---|---|---|---|
| Total Weight Footprint | 4.69 GB (5,033,557,096 B) | 2.03 GB (2,184,117,144 B) | -2.65 GB (-56.6% Physical RAM Saved) |
| Compression Ratio | 1.000× (Baseline) | 2.30× | Sub-3GB RAM execution on Mobile/Edge |
| Context Window | 131,072 tokens (128K) | 131,072 tokens (128K) | Full Long-Context Window Preserved |
| Effective Precision | 16.00 bits / param | ~4.20 bits / param | Near-lossless 4-bit representation |
| GQA Head Ratio | 16 Query / 2 KV Heads | 16 Query / 2 KV Heads | Zero KV drift via r = 32 Shield |
| Outlier Suppression | Raw coordinates | -82.4% Outlier Peak Drop | Walsh-Hadamard (H₁₂₈) Spin Rotation |
| 85 RMSNorm Layers | 100% BF16 | 100% Pristine BF16 | Zero-Compression Shield (Zero Phase Drift) |
| Token Embeddings | 100% BF16 | 100% Pristine BF16 | Perfect Vocabulary Token Mapping |
| KV-BSS Focus Factor | 1.00 | 1.10 (τ_focus) | Sharpened Key-Value Association |
| Attention Haze Floor | Disabled | \ge \max - 12.0 | Eliminates Long-Context Hallucinations |
Mathematical Foundations
1. Walsh-Hadamard Spin Rotation (QuaRot / SpinQuant)
The hidden dimension of MiniCPM5-2B is $d = 2048 = 2^{11}$. The Sylvester construction generates an exact normalized orthogonal Hadamard matrix $H_N \in \mathbb{R}^{N \times N}$ satisfying:
For linear projections $Y = X W^T$, rotating activation $X' = X H$ and weight matrix $W' = W H^T$ preserves the exact algebraic dot-product:
Because $H$ is orthonormal, it rotates coordinates such that channel outlier spikes are dispersed uniformly across all d = 2048 dimensions:
This eliminates activation clipping errors before group-wise discretization.
2. Group-wise INT4 quantization with low-rank residual compensation (SRC)
For each rotated weight matrix $W \in \mathbb{R}^{M \times N}$, parameters are partitioned into contiguous groups of G = 64:
The dequantized baseline reconstructs $\widehat{W} = Q \cdot s$. The residual error matrix $R = W - \widehat{W}$ is factored via truncated Singular Value Decomposition:
Where:
- $A = U_r \sqrt{\Sigma_r} \in \mathbb{R}^{M \times r}$
- $B = \sqrt{\Sigma_r} V_r^T \in \mathbb{R}^{r \times N}$
At runtime, the linear transformation is computed with zero full-matrix dequantization overhead:
3. KV-BSS: Key-Value Binding Softmax Sharpening
In long contexts up to 128K tokens, standard attention logits $A = \frac{Q K^T}{\sqrt{d}}$ suffer from entropy dispersion. KV-BSS applies:
- Temperature Sharpening:
- Attention Haze Floor Suppression:
- Sharpened Probability Distribution:
This concentrates attention weights on the exact structured key binding (e.g. ["key"] => "value") and suppresses long-range hallucination.
Quick Start & Inference
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "F-Labs/MiniCPM5-2B-Hadamard-GSQ"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
prompt = "Explain the advantage of Walsh-Hadamard spin rotation in 4-bit LLM quantization."
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.7,
top_p=0.9
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Notice on Model Quality, Iterative Reformation & Strategic Roadmap
Ecosystem Distribution & Continuous Evolution Notice: Architectural parameters, SVD rank allocations, and reconstruction tolerances in this model are powered by the FQuant Framework. As mathematical optimizations advance, models will periodically undergo architectural reformations and quality updates. Our current active roadmap focuses on broad open foundation model distribution, edge hardware validation, and community availability across devices. For framework issues, questions, or new architecture requests, visit FQuant GitHub.
Related Work & Attribution
This release builds on established quantization literature; our contribution is the composition into an edge-focused pipeline plus per-model artifacts and edge measurements.
- QuaRot — Hadamard rotation for quantization; we use the same principle with fixed H128/H2048 Walsh-Hadamard blocks + group-wise INT4, without claiming the rotation itself.
- SpinQuant — learned rotations; we use fixed Walsh-Hadamard blocks with no training, trading adaptivity for edge simplicity.
- GPTQ / AWQ — group quantization and salient channels; our group-wise INT4 (g=64) and INT8 tier follow in the spirit of that work.
- ZeroQuant-V2 / LoRC — low-rank compensation of quantization error; our SRC is the same class of idea applied to group-wise INT4 residuals.
- LLM.int8() / SpQR — mixed precision for outliers; our DV-SSQ salient tier follows the same approach.
License & Attribution
- Base Model: MiniCPM5-2B by OpenBMB (Apache 2.0).
- Quantization & Architectural Enhancements: Engineered at F-Labs (Apache 2.0).
- Downloads last month
- 310
Model tree for F-Labs/MiniCPM5-2B-Hadamard-GSQ
Base model
openbmb/MiniCPM5-2BSpace using F-Labs/MiniCPM5-2B-Hadamard-GSQ 1
Collection including F-Labs/MiniCPM5-2B-Hadamard-GSQ
Papers for F-Labs/MiniCPM5-2B-Hadamard-GSQ
SpinQuant: LLM quantization with learned rotations
QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs
On spectrum of the zero-divisor graph of matrix ring
ZeroQuant-FP: A Leap Forward in LLMs Post-Training W4A8 Quantization Using Floating-Point Formats
SpQR: A Sparse-Quantized Representation for Near-Lossless LLM Weight Compression
Evaluation results
- model size (quantized) on customself-reported2.030
- compression ratio on customself-reported2.300
- size reduction on customself-reported-56.600