GLM-4-9B-0414 ยท NVFP4A16 (W4A16, FP4 weights)
4-bit quantization of zai-org/GLM-4-9B-0414 for vLLM serving. Quantized by axteam.
| Base model | zai-org/GLM-4-9B-0414 |
| Method | NVFP4A16 (W4A16, FP4 weights) |
| Format | compressed-tensors nvfp4-pack-quantized |
| Weights / activations | W4A16 โ FP4 (E2M1) weights group 16 + FP8 scale, BF16 activations |
| Architecture | Dense (GLM-4 ยท Glm4ForCausalLM) ยท 9.4B ยท text-only |
| Size on disk | ~7.1 GB |
| Calibration | None (data-free, name-based model_free_ptq) |
| License | mit |
Quantization details
- Scheme โ W4A16 โ FP4 (E2M1) weights group 16 + FP8 scale, BF16 activations, stored as compressed-tensors
nvfp4-pack-quantized. - Kept in BF16 โ token embeddings, the LM head, and all RMSNorms. Only attention & MLP projections are quantized.
- Post-training quantization (no retraining). Tokenizer /
chat_templateidentical to the original.
Benchmarks (measured)
Every column was measured with the same harness and settings โ lm-evaluation-harness on vLLM, greedy, completion-style prompts without a chat template (0- or 5-shot, as listed in each row). MMLU here is lm-eval's generative variant (mmlu_generative: the model writes the answer letter and only an exact match on the first line counts), so it is not directly comparable with MMLU scores measured another way (e.g. log-likelihood scoring). Percentages are recovery vs. the BF16 original.
| Benchmark | BF16 (original) | FP8-dynamic | NVFP4A16 (this repo) |
|---|---|---|---|
| MMLU (5-shot, generative) | 73.99 | 74.01 (100.0%) | 73.23 (99.0%) |
| GSM8K (5-shot, strict) | 80.21 | 80.89 (100.9%) | 78.17 (97.4%) |
| ARC-Challenge (0-shot) | 60.15 | 59.64 (99.1%) | 58.36 (97.0%) |
| Winogrande (5-shot) | 78.85 | 79.24 (100.5%) | 77.82 (98.7%) |
| KMMLU (5-shot, direct) | 48.34 | 48.26 (99.8%) | 48.05 (99.4%) |
| HAE-RAE (0-shot) | 55.36 | 55.18 (99.7%) | 56.10 (101.3%) |
| Average | 66.15 | 66.21 (100.1%) | 65.29 (98.7%) |
Requirements
| Runtime | vLLM โ the architecture is in vLLM โฅ 0.8.4; tested here with vLLM 0.32.0. |
| vLLM install | vLLM 0.32 itself needs Python 3.11โ3.14, torch 2.13 (CUDA 13.0 build, so an NVIDIA driver with CUDA 13 support), transformers โฅ5.16.1,<5.20 and compressed-tensors 0.17.0 (both pinned by vLLM; 0.17.0 reads this checkpoint, which was saved with 0.19.0 โ do not upgrade it separately). |
| GPU | NVIDIA Turing (sm75) or newer โ weight-only FP4, no FP4 tensor cores needed. GLM-4-0414 runs in bf16 only (float16 is disabled for this architecture), so Ampere (sm80) or newer in practice. V100 (sm70) is not supported. (Kernel choice per GPU from vLLM 0.32's selection code; only B200 was run here.) |
| Memory | Weights: 7.1 GB. Add KV cache (grows with context length ร concurrent requests) and a few GB for activations / CUDA graphs; use --tensor-parallel-size N when the weights do not fit one GPU. |
| Transformers (without vLLM) | transformers>=4.56.0 + compressed-tensors>=0.15.0 (the architecture exists from 4.51.3, but these compressed-tensors checkpoints cannot load before 4.56). |
| trust_remote_code | not needed |
Usage (vLLM)
Start an OpenAI-compatible server:
vllm serve axteam/GLM-4-9B-0414-NVFP4A16 --max-model-len 32768
Query it:
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "axteam/GLM-4-9B-0414-NVFP4A16",
"messages": [{"role": "user", "content": "๋ํ๋ฏผ๊ตญ์ ์๋๋ ์ด๋์ธ๊ฐ์?"}],
"max_tokens": 512
}'
Offline inference in Python:
from vllm import LLM, SamplingParams
llm = LLM(model="axteam/GLM-4-9B-0414-NVFP4A16", max_model_len=32768)
params = SamplingParams(max_tokens=1024)
out = llm.chat([{"role": "user", "content": "Explain model quantization in two sentences."}], params)
print(out[0].outputs[0].text)
Reducing KV-cache memory (optional, serve-time)
The KV cache is kept in BF16 by default. KV-cache precision is a runtime choice, independent of the weight quantization above; for long contexts or large batches FP8 roughly halves KV-cache memory:
vllm serve axteam/GLM-4-9B-0414-NVFP4A16 --kv-cache-dtype fp8
License
Quantized derivative of zai-org/GLM-4-9B-0414 (mit).
ํ๊ตญ์ด ์์ฝ
zai-org/GLM-4-9B-0414์ NVFP4A16 (W4A16) ์์ํ ๋น๋ ยท ์ ์ axteam
๊ฐ์
| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| ์๋ณธ ๋ชจ๋ธ | zai-org/GLM-4-9B-0414 |
| ์์ํ ๋ฐฉ์ | NVFP4A16 (W4A16, FP4 ๊ฐ์ค์น) |
| ์ ์ฅ ํ์ | compressed-tensors nvfp4-pack-quantized |
| ๋ชจ๋ธ ๊ตฌ์กฐ | Dense (GLM-4, Glm4ForCausalLM) ยท 9.4B ยท ํ
์คํธ ์ ์ฉ |
| ์ฉ๋ | ์ฝ 7.1 GB |
| ๋ณด์ ๋ฐ์ดํฐ | ์์ (๊ฐ์ค์น๋ง์ผ๋ก ์ค์ผ์ผ ๊ณ์ฐ, ์ด๋ฆ ๊ธฐ๋ฐ model_free_ptq) |
์์ํ ์์ธ
- ๊ฐ์ค์น: FP4(E2M1), ๊ทธ๋ฃน ํฌ๊ธฐ 16 + ๊ทธ๋ฃน๋ณ FP8 ์ค์ผ์ผ
- ํ์ฑํ: BF16 (์์ํํ์ง ์์)
- ์์ํ ์ ์ฐจ: PTQ(ํ์ต ํ ์์ํ, ์ฌํ์ต ์์), ๋ณด์ ๋ฐ์ดํฐ ์์ด ๊ฐ์ค์น๋ง์ผ๋ก ์ค์ผ์ผ์ ์ ํด ๋ฐ์ฌ๋ฆผ(RTN)
- BF16 ์ ์ง: ํ ํฐ ์๋ฒ ๋ฉ, LM ํค๋, ๋ชจ๋ RMSNorm
- ์์ํ ๋์: ์ดํ ์ ยทMLP ์ ํ์ธต(projection)
- ์๋ณธ ํ์ผ: ํ ํฌ๋์ด์ ยทchat template์ ์๋ณธ๊ณผ ๋์ผ
ํ์ง (์ค์ธก)
- ๋ฒค์น๋งํฌ ํ๊ท : 65.29 (์๋ณธ 66.15, 98.7%) โ MMLU(์์ฑํ)ยทGSM8KยทARC-ChallengeยทWinograndeยทKMMLUยทHAE-RAE 6์ข ํ๊ท , lm-evaluation-harness + vLLM, chat template ์๋ ์์ฑํ ํ๋กฌํํธ(๊ณผ์ ๋ณ 0ยท5-shot, ํ ์ฐธ๊ณ )ยทgreedy, ๋ชจ๋ ๋น๋๋ฅผ ๊ฐ์ ์ค์ ์ผ๋ก ์ธก์
- ํ๊ตญ์ด ๋ฒค์น๋งํฌ: KMMLU 48.05 (์๋ณธ 48.34, 99.4%) ยท HAE-RAE 56.10 (์๋ณธ 55.36, 101.3%)
- MMLU ๋ฐฉ์: lm-eval ์์ฑํ ๋ณํ(
mmlu_generative) โ ๋ชจ๋ธ์ด ๋ต ๊ธ์๋ฅผ ์์ฑํ๊ณ ์ฒซ ์ค์ด ์ ํํ ์ผ์นํด์ผ ์ ๋ต์ผ๋ก ์ฑ์ ํ๋ฏ๋ก, ๋ค๋ฅธ ๋ฐฉ์(์: log-likelihood ์ฑ์ )์ผ๋ก ์ฐ MMLU ์ ์์ ์ง์ ๋น๊ต ๋ถ๊ฐ
์๊ตฌ์ฌํญ
- ์คํ ์์ง: vLLM 0.8.4 ์ด์(์ด ๊ตฌ์กฐ๋ฅผ ์ง์ํ๋ ์ฒซ ๋ฒ์ ), ์ด ๋น๋๋ vLLM 0.32.0์์ ์คํ ํ์ธ
- vLLM 0.32 ์ค์น ์กฐ๊ฑด: Python 3.11~3.14, torch 2.13(CUDA 13.0 ๋น๋, CUDA 13 ์ง์ ๋๋ผ์ด๋ฒ ํ์), transformers 5.16.1 ์ด์ 5.20 ๋ฏธ๋ง, compressed-tensors 0.17.0 โ transformersยทcompressed-tensors๋ vLLM์ด ๋ฒ์ ์ ๊ณ ์ ํ๋ฏ๋ก compressed-tensors๋ฅผ ๋ฐ๋ก ์ ๊ทธ๋ ์ด๋ํ์ง ๋ง ๊ฒ (์ด ์ฒดํฌํฌ์ธํธ๋ 0.19.0์ผ๋ก ์ ์ฅ๋์ง๋ง 0.17.0์์๋ ๋ก๋๋จ)
- GPU: NVIDIA Turing(sm75) ์ด์, GLM-4-0414๋ bf16 ์ ์ฉ(float16 ๋นํ์ฑ)์ด๋ผ ์ค์ง์ ์ผ๋ก Ampere(sm80) ์ด์, V100(sm70) ๋ฏธ์ง์ โ ๊ฐ์ค์น ์ ์ฉ FP4๋ผ FP4 ์ ์ฉ ํ ์์ฝ์ด ๋ถํ์ (GPU๋ณ ์ง์ ์ฌ๋ถ๋ vLLM 0.32 ์ปค๋ ์ ํ ์ฝ๋ ๊ธฐ์ค, ์ค์ ์คํ์ B200์์๋ง ํ์ธ)
- ๋ฉ๋ชจ๋ฆฌ: ๊ฐ์ค์น 7.1 GB + KV ์บ์(์ปจํ
์คํธ ๊ธธ์ด ร ๋์ ์์ฒญ ์์ ๋น๋ก) + ํ์ฑํยทCUDA graph์ฉ ์ GB โ GPU ํ ์ฅ์ ๋ค ๋ค์ด๊ฐ์ง ์์ผ๋ฉด
--tensor-parallel-size N์ผ๋ก ๋ถ์ฐ - Transformers๋ก ์ง์ ์ฌ์ฉ: transformers 4.56.0 ์ด์ + compressed-tensors 0.15.0 ์ด์ (๊ตฌ์กฐ ์์ฒด๋ 4.51.3๋ถํฐ ์์ผ๋ ์ด compressed-tensors ์ฒดํฌํฌ์ธํธ๋ 4.56 ์ด์์์๋ง ๋ก๋ ๊ฐ๋ฅ)
- trust_remote_code: ๋ถํ์
์ฌ์ฉ๋ฒ
- ์๋ฒ ์คํ:
vllm serve axteam/GLM-4-9B-0414-NVFP4A16 --max-model-len 32768โ OpenAI ํธํ API - Python:
LLM(model="axteam/GLM-4-9B-0414-NVFP4A16", max_model_len=32768).chat(...)โ ์ ์ฒด ์์๋ ์ ์์ด ๋ณธ๋ฌธ 'Usage (vLLM)' ์ ์ฐธ๊ณ - KV ์บ์ ์ ๊ฐ(์ ํ):
vllm serve์--kv-cache-dtype fp8์ถ๊ฐ โ ๊ธฐ๋ณธ BF16์ธ KV ์บ์๋ฅผ FP8๋ก ์ ์ฅํด KV ์บ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ ์ ๋ฐ์ผ๋ก ์ค์ (๊ธด ์ปจํ ์คํธยท๋์ ์์ฒญ์ด ๋ง์ ๋ ์ ๋ฆฌ, ๊ฐ์ค์น ์์ํ์ ๋ณ๊ฐ์ธ ์คํ ์ต์ )
๋ผ์ด์ ์ค
- ๋ผ์ด์ ์ค: MIT โ ์๋ณธ ๋ชจ๋ธ์ ๋ผ์ด์ ์ค๋ฅผ ๊ทธ๋๋ก ๋ฐ๋ฆ
- ๊ถ๋ฆฌ: ์๋ณธ ๋ชจ๋ธ์ ๊ถ๋ฆฌ๋ Z.ai์๊ฒ ์์, ์ด ๋ฆฌํฌ๋ ์์ํ ํ์๋ฌผ