--- license: apache-2.0 base_model: openbmb/MiniCPM5-2B base_model_relation: quantized library_name: transformers pipeline_tag: text-generation tags: - nvfp4 - 4-bit - w4a4 - compressed-tensors - llm-compressor - gptq - distillation - qad - quantized - vllm --- # MiniCPM5-2B NVFP4 (W4A4, GPTQ + short distillation) NVFP4 quantization of [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B), made by PureTensor from the official BF16 weights. Weights and activations are both 4-bit (W4A4), so vLLM runs it on its native FP4 kernel. The file is 2.18 GB against 5.03 GB for BF16. This is a test release. It is not affiliated with or endorsed by OpenBMB. **Read this first:** full 4-bit costs this model real quality. This checkpoint is 3.1 points below BF16 on MMLU and 7.3 below on GSM8K when served. A short quantization-aware distillation recovered about half of what plain 4-bit quantization lost. If quality matters more than throughput under load, use the weights-only sibling [PureTensorAI/MiniCPM5-2B-NVFP4A16](https://huggingface.co/PureTensorAI/MiniCPM5-2B-NVFP4A16). ## What was done | | | |---|---| | Source | `openbmb/MiniCPM5-2B`, BF16 | | Format | compressed-tensors `nvfp4-pack-quantized`, scheme `NVFP4`: 4-bit E2M1 weights and input activations, FP8 E4M3 scales per group of 16 | | Quantized | every `Linear` layer in the 42 transformer blocks | | Kept in BF16 | token embeddings, output head, all norms | | Step 1 | GPTQ (`dampening_frac` 0.01, `actorder` static), first 512 samples of `mlabonne/open-perfectblend`, up to 2,048 tokens each | | Step 2 | Quantization-aware distillation: the BF16 model is the teacher, the loss is KL divergence on next-token distributions, only the quantized weights train, scales stay fixed, gradients pass straight through the 4-bit rounding | | Distillation budget | 1,451 steps, 1.69M tokens, AdamW, learning rate 5e-6 with warm-up and cosine decay | | Distillation data | chat-formatted `mlabonne/open-perfectblend` from row 20,000 on, with the math sources (MetaMathQA, Orca-Math) left out so GSM8K stays a fair test | | Tools | llm-compressor 0.15.0, compressed-tensors 0.20.1, transformers 5.21.0, torch 2.14.1 | After training, the weights are snapped to the 4-bit grid, saved, and reloaded. Every number below was measured on the reloaded file. ## Measured quality One harness, BF16 as reference. | | BF16 | 4-bit, no distillation | This checkpoint | |---|---:|---:|---:| | MMLU, accuracy (14,042 questions, offline) | 57.29 | 51.03 | **54.17** | | GSM8K, exact match (1,319 problems, offline) | 72.48 | 59.89 | **66.03** | | GSM8K served by vLLM on its native FP4 kernel | 72.10 | 58.15 | **64.82** | | Mean KL divergence from BF16, WikiText-2 (131,072 tokens) | 0 | 0.164 | **0.154** | | Mean KL divergence from BF16, chat (224,534 tokens) | 0 | 0.201 | **0.164** | | Same top token as BF16, WikiText-2 / chat | 100% | 80.1% / 83.1% | 80.7% / 84.0% | - Distillation against no distillation, paired McNemar test on per-question correctness: MMLU p = 1e-14, GSM8K p = 2e-5. Both gains are significant. - This checkpoint against BF16: still significantly worse on both (MMLU p = 2e-16, GSM8K p = 6e-7). - MMLU and GSM8K: default `mmlu` and `gsm8k` configurations of lm-evaluation-harness 0.4.13, no chat template, GSM8K flexible-extract. "Offline" means Transformers with the 4-bit arithmetic emulated. Emulation is optimistic for 4-bit activations: the served GSM8K score is about 1 to 3 points lower in our tests, so trust the served row. MMLU was not measured on the served model. - KL divergence: full next-token distribution, teacher-forced, windows of 1,024 tokens. The chat set comes from the same dataset family as part of the distillation data, so the WikiText row is the cleaner one. ### Against the weights-only sibling Served with vLLM 0.34.0 on one NVIDIA Blackwell workstation GPU (compute capability 12.0), fixed 256-token greedy generations. | | BF16 | Weights-only sibling | This checkpoint | |---|---:|---:|---:| | vLLM kernel | | weight-only FP4 (Marlin) | native FP4 (FlashInfer CUTLASS) | | MMLU (offline) | 57.29 | 54.60 | 54.17 | | GSM8K (served) | 72.10 | 68.23 | 64.82 | | Throughput, single stream | 1.00x | 1.40x | 1.36x | | Throughput, 8 concurrent | 1.00x | 1.53x | 1.55x | | Throughput, 32 concurrent | 1.00x | 1.28x | 1.50x | The case for this checkpoint is throughput under heavy concurrency. Otherwise the sibling is the better trade. ## Usage vLLM: ```bash vllm serve PureTensorAI/MiniCPM5-2B-NVFP4-QAD ``` Transformers (requires `pip install compressed-tensors`; the 4-bit arithmetic is emulated, so this path is for checking, not speed): ```python import torch from transformers import AutoModelForCausalLM, AutoTokenizer repo = "PureTensorAI/MiniCPM5-2B-NVFP4-QAD" tok = AutoTokenizer.from_pretrained(repo) model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).to("cuda") msgs = [{"role": "user", "content": "Summarise the water cycle in two sentences."}] ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True).to("cuda") out = model.generate(**ids, max_new_tokens=256) print(tok.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True)) ``` ## Limitations - Quality is below BF16 and below the weights-only sibling, as measured above. - The distillation was short: about 20 minutes on one GPU. A longer run would likely recover more; we have not done it yet. - One training run, one calibration draw, no repeated seeds. English-language benchmarks only. No safety, multilingual, or long-context evaluation was run on the quantized model. - Throughput ratios are from one GPU and one workload and will differ elsewhere. ## License Apache-2.0, as the base model. Changes from the base release: the `Linear` weights are quantized to NVFP4 after GPTQ and a short distillation, activation quantization parameters are added, and `config.json` gains a `quantization_config` block.