GLM-OCR ยท FP8 (dynamic)
8-bit quantization of zai-org/GLM-OCR for vLLM serving. Quantized by axteam.
Revision 2026-11-02 (config fix): the earlier
config.jsonexcluded the vision tower from quantization with the patternre:model\.visual\..*, which does not match the names vLLM uses for these modules (visual.*). vLLM 0.32 therefore built the vision layers as FP8 and loaded the BF16 vision weights into them, so image input gave wrong answers; text input was not affected. Onlyconfig.jsonchanged (the pattern now also matches vLLM's names); the weights are the same. Checked with vLLM 0.32.0 on 2026-11-02: the vision weights now load as BF16, and the caption of a synthetic test image ("QWEN TEST 2026") is transcribed exactly. If you downloaded this repo before 2026-11-01 23:41:41 UTC (revision3d09e56), downloadconfig.jsonagain.
| Base model | zai-org/GLM-OCR |
| Method | FP8 (dynamic) |
| Format | compressed-tensors float-quantized (scheme FP8_DYNAMIC) |
| Weights / activations | W8A8 โ FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations |
| Architecture | Dense ยท GLM text backbone + vision encoder ยท MTP head ยท document/OCR VLM |
| Size on disk | ~2.2 GB |
| Calibration | None (data-free) |
| License | mit |
Quantization details
- Scheme โ W8A8 โ FP8 E4M3 weights (per-channel), dynamic per-token FP8 activations, stored as compressed-tensors
float-quantized(schemeFP8_DYNAMIC). - Kept in BF16 โ the vision tower (
model.visual.*), the multi-token-prediction layer, token embeddings, the LM head, and all RMSNorms (about 63% of all parameters in this build). Only the language-model backbone's attention & MLP projections are quantized, so the OCR/vision path is untouched. - Post-training quantization (no retraining). Tokenizer /
chat_template/ processor identical to the original.
Evaluation (measured)
Fidelity to the BF16 original on an internal mixed EN/KO set (100 prompts, text next-token scoring).
| Metric | This model | BF16 original |
|---|---|---|
| Perplexity (lower = closer) | 1.3726 | 1.3599 (+0.9%) |
| Top-1 next-token agreement | 96.5% | 99.4% |
Requirements
| Runtime | vLLM โ the architecture is in vLLM โฅ 0.16.0; 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, e.g. T4) or newer. FP8 math runs on Ada / Hopper / Blackwell (sm89+); on Turing and Ampere vLLM switches to weight-only FP8 automatically. V100 (sm70) is not supported. (Kernel choice per GPU from vLLM 0.32's selection code; only B200 was run here.) |
| Memory | Weights: 2.2 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>=5.1.0 + compressed-tensors>=0.15.0 (text path checked; image input not tested). |
| trust_remote_code | not needed |
Usage (vLLM)
Start an OpenAI-compatible server:
vllm serve axteam/GLM-OCR-FP8-dynamic --max-model-len 32768
Query it:
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "axteam/GLM-OCR-FP8-dynamic",
"messages": [{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://example.com/your-image.png"}},
{"type": "text", "text": "Extract all text from this image."}]}],
"max_tokens": 512
}'
Offline inference in Python:
from vllm import LLM, SamplingParams
llm = LLM(model="axteam/GLM-OCR-FP8-dynamic", max_model_len=32768)
params = SamplingParams(max_tokens=1024)
# image input (URL or data: URI)
messages = [{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://example.com/your-image.png"}},
{"type": "text", "text": "Extract all text from this image."},
]}]
out = llm.chat(messages, params)
print(out[0].outputs[0].text)
Thinking mode is on by default in the chat template; to turn it off pass
chat_template_kwargs={"enable_thinking": False}(Pythonllm.chat(..., chat_template_kwargs=...), or"chat_template_kwargs": {"enable_thinking": false}in the request body). For task-specific OCR prompts (tables, formulas, layout) see the original model card. This is an OCR model: send an image. Text-only chat is not its purpose โ in our vLLM check of this build it answered "๋ํ๋ฏผ๊ตญ์ ์๋๋ ์ด๋์ธ๊ฐ์? ํ ๋ฌธ์ฅ์ผ๋ก ๋ตํ์ธ์." by repeating the question.
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-OCR-FP8-dynamic --kv-cache-dtype fp8
License
Quantized derivative of zai-org/GLM-OCR (mit). Original weights & processor belong to the upstream authors.
ํ๊ตญ์ด ์์ฝ
zai-org/GLM-OCR์ FP8 (W8A8) ์์ํ ๋น๋ ยท ์ ์ axteam
๊ฐ์
| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| ์๋ณธ ๋ชจ๋ธ | zai-org/GLM-OCR |
| ์์ํ ๋ฐฉ์ | FP8 ๋์ ์์ํ (W8A8) |
| ์ ์ฅ ํ์ | compressed-tensors float-quantized (scheme FP8_DYNAMIC) |
| ๋ชจ๋ธ ๊ตฌ์กฐ | Dense ยท GLM ํ ์คํธ ๋ฐฑ๋ณธ + ๋น์ ํ์ ยท MTP ํค๋ ยท ๋ฌธ์ยทOCR์ฉ VLM |
| ์ฉ๋ | ์ฝ 2.2 GB |
| ๋ณด์ ๋ฐ์ดํฐ | ์์ (๊ฐ์ค์น ์ค์ผ์ผ์ ๊ฐ์ค์น๋ง์ผ๋ก ๊ณ์ฐ, ํ์ฑํ ์ค์ผ์ผ์ ์คํ ์ ๊ณ์ฐ) |
์์ํ ์์ธ
- ๊ฐ์ค์น: FP8(E4M3), ์ถ๋ ฅ ์ฑ๋๋ณ ์ค์ผ์ผ
- ํ์ฑํ: ์คํ ์ ํ ํฐ๋ณ ๋์ FP8
- ์์ํ ์ ์ฐจ: PTQ(ํ์ต ํ ์์ํ, ์ฌํ์ต ์์), ๊ฐ์ค์น ์ค์ผ์ผ์ ๋ฏธ๋ฆฌ ๊ณ์ฐํ๊ณ ํ์ฑํ ์ค์ผ์ผ์ ์คํ ์ ํ ํฐ๋ง๋ค ๊ณ์ฐ
- BF16 ์ ์ง: ๋น์ ํ์(
model.visual.*), MTP ํค๋(๋ค์ค ํ ํฐ ์์ธก ์ธต), ํ ํฐ ์๋ฒ ๋ฉ, LM ํค๋, ๋ชจ๋ RMSNorm โ ์ ์ฒด ํ๋ผ๋ฏธํฐ์ ์ฝ 63% - ์์ํ ๋์: ์ธ์ด๋ชจ๋ธ ๋ฐฑ๋ณธ์ ์ดํ ์ ยทMLP ์ ํ์ธต(projection) (OCRยท๋น์ ๊ฒฝ๋ก๋ ์๋ณธ ๊ทธ๋๋ก)
- ์๋ณธ ํ์ผ: ํ ํฌ๋์ด์ ยทchat templateยทprocessor๋ ์๋ณธ๊ณผ ๋์ผ
ํ์ง (์ค์ธก)
- ์๋ณธ ๋๋น ์ถฉ์ค๋: PPL 1.3726 (์๋ณธ 1.3599, +0.9%, ๋ฎ์์๋ก ์๋ณธ์ ๊ฐ๊น์), ๋ค์ ํ ํฐ top-1 ์ผ์น์จ 96.5% (์๋ณธ ์์ฒด ๊ธฐ์ค๊ฐ 99.4%) โ ๋ด๋ถ ์์ดยทํ๊ตญ์ด ํผํฉ ํ๋กฌํํธ 100๊ฐ, ํ ์คํธ ๋ค์ ํ ํฐ ๊ธฐ์ค์ผ๋ก ์ธก์
์๊ตฌ์ฌํญ
- ์คํ ์์ง: vLLM 0.16.0 ์ด์(์ด ๊ตฌ์กฐ๋ฅผ ์ง์ํ๋ ์ฒซ ๋ฒ์ ), ์ด ๋น๋๋ 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, ์: T4) ์ด์, V100(sm70) ๋ฏธ์ง์ โ FP8 ์ฐ์ฐ์ AdaยทHopperยทBlackwell(sm89 ์ด์)์์ ์ํ, TuringยทAmpere๋ vLLM์ด ๊ฐ์ค์น ์ ์ฉ FP8๋ก ์๋ ์ ํ (GPU๋ณ ์ง์ ์ฌ๋ถ๋ vLLM 0.32 ์ปค๋ ์ ํ ์ฝ๋ ๊ธฐ์ค, ์ค์ ์คํ์ B200์์๋ง ํ์ธ)
- ๋ฉ๋ชจ๋ฆฌ: ๊ฐ์ค์น 2.2 GB + KV ์บ์(์ปจํ
์คํธ ๊ธธ์ด ร ๋์ ์์ฒญ ์์ ๋น๋ก) + ํ์ฑํยทCUDA graph์ฉ ์ GB โ GPU ํ ์ฅ์ ๋ค ๋ค์ด๊ฐ์ง ์์ผ๋ฉด
--tensor-parallel-size N์ผ๋ก ๋ถ์ฐ - Transformers๋ก ์ง์ ์ฌ์ฉ: transformers 5.1.0 ์ด์ + compressed-tensors 0.15.0 ์ด์ (ํ ์คํธ ๊ฒฝ๋ก๋ง ํ์ธ, ์ด๋ฏธ์ง ์ ๋ ฅ์ ์คํ ๋ฏธํ์ธ)
- trust_remote_code: ๋ถํ์
์ฌ์ฉ๋ฒ
- ์๋ฒ ์คํ:
vllm serve axteam/GLM-OCR-FP8-dynamic --max-model-len 32768โ OpenAI ํธํ API - Python:
LLM(model="axteam/GLM-OCR-FP8-dynamic", max_model_len=32768).chat(...)โ ์ ์ฒด ์์๋ ์ ์์ด ๋ณธ๋ฌธ 'Usage (vLLM)' ์ ์ฐธ๊ณ - thinking ๋ชจ๋: ๊ธฐ๋ณธ ์ผ์ง โ ๋๋ ค๋ฉด
chat_template_kwargs={"enable_thinking": False}์ ๋ฌ(Python์llm.chat()์ธ์, HTTP๋ ์์ฒญ ๋ณธ๋ฌธ์"chat_template_kwargs": {"enable_thinking": false}) - ์ด๋ฏธ์ง ์
๋ ฅ: ๋ฉ์์ง์
image_urlํญ๋ชฉ ์ฌ์ฉ - OCR ํ๋กฌํํธ: ํยท์์ยท๋ ์ด์์ ๋ฑ ์์ ๋ณ ํ๋กฌํํธ๋ ์๋ณธ ์นด๋ ์ฐธ๊ณ
- ํ ์คํธ ์ ์ฉ ์ง๋ฌธ: ์ฉ๋ ์๋, ์ด๋ฏธ์ง ์ ๋ ฅ์ผ๋ก ์ฌ์ฉ โ ์ด ๋น๋์ vLLM ์ ๊ฒ์์ "๋ํ๋ฏผ๊ตญ์ ์๋๋ ์ด๋์ธ๊ฐ์? ํ ๋ฌธ์ฅ์ผ๋ก ๋ตํ์ธ์."์ ๋ต ๋์ ์ง๋ฌธ์ ๊ทธ๋๋ก ๋ํ์ด
- KV ์บ์ ์ ๊ฐ(์ ํ):
vllm serve์--kv-cache-dtype fp8์ถ๊ฐ โ ๊ธฐ๋ณธ BF16์ธ KV ์บ์๋ฅผ FP8๋ก ์ ์ฅํด KV ์บ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ ์ ๋ฐ์ผ๋ก ์ค์ (๊ธด ์ปจํ ์คํธยท๋์ ์์ฒญ์ด ๋ง์ ๋ ์ ๋ฆฌ, ๊ฐ์ค์น ์์ํ์ ๋ณ๊ฐ์ธ ์คํ ์ต์ )
์ฐธ๊ณ
- ์์ ์ด๋ ฅ (2026-11-02, ์ค์ ์์ ): ์ด์
config.json์ ๋น์ ํ์๋ฅผ ์์ํ์์ ๋นผ๋ ๊ท์น(re:model\.visual\..*)์ด vLLM์ด ์ฐ๋ ๋ชจ๋ ์ด๋ฆ(visual.*)๊ณผ ๋ง์ง ์์, vLLM 0.32๊ฐ ๋น์ ์ธต์ FP8๋ก ๋ง๋ค๊ณ BF16 ๋น์ ๊ฐ์ค์น๋ฅผ ๊ทธ๋๋ก ๋ฃ์์ โ ์ด๋ฏธ์ง ์ ๋ ฅ ๋ต์ด ํ๋ฆผ(ํ ์คํธ ์ ๋ ฅ์ ์ํฅ ์์) โconfig.json์ ๊ท์น๋ง vLLM ์ด๋ฆ๊น์ง ๋ง๊ฒ ๊ณ ์นจ(๊ฐ์ค์น ๋์ผ) โ vLLM 0.32.0 ํ์ธ(2026-11-02): ๋น์ ๊ฐ์ค์น๊ฐ BF16์ผ๋ก ๋ก๋๋จ, ๋ชจ๋ธ์ด ์ํ ๊ทธ๋ฆผ์ ๊ธ์("QWEN TEST 2026")๋ฅผ ์ ํํ ์ฎ๊ฒจ ์ ์ โ 2026-11-01 23:41:41 UTC(๋ฆฌ๋น์ 3d09e56) ์ด์ ์ ๋ฐ์๋ค๋ฉดconfig.json๋ง ๋ค์ ๋ฐ์ ๊ฒ
๋ผ์ด์ ์ค
- ๋ผ์ด์ ์ค: MIT โ ์๋ณธ ๋ชจ๋ธ์ ๋ผ์ด์ ์ค๋ฅผ ๊ทธ๋๋ก ๋ฐ๋ฆ
- ๊ถ๋ฆฌ: ์๋ณธ ๊ฐ์ค์นยทprocessor๋ Z.ai ์์ , ์ด ๋ฆฌํฌ๋ ์์ํ ํ์๋ฌผ