Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
8.1 KiB
Markdown
157 lines
8.1 KiB
Markdown
---
|
||
license: other
|
||
license_name: lfm1.0
|
||
license_link: LICENSE
|
||
base_model: LiquidAI/LFM3-1.7B
|
||
base_model_relation: quantized
|
||
library_name: vllm
|
||
pipeline_tag: text-generation
|
||
tags:
|
||
- lfm3
|
||
- liquid
|
||
- gptq
|
||
- int4
|
||
- int8-embedding
|
||
- compressed-tensors
|
||
- intel-xpu
|
||
- quantized
|
||
---
|
||
|
||
# LFM3-1.7B — GPTQ INT4, baked INT4 lm_head + INT8 embedding
|
||
|
||
A 1.155 GB single-file quantization of [LiquidAI/LFM3-1.7B](https://huggingface.co/LiquidAI/LFM3-1.7B)
|
||
(BF16: 3.46 GB) for vLLM on Intel Arc (tested: one Arc Pro B65 32 GB, vLLM 0.32.0 XPU). Everything that is
|
||
quantized is quantized **on disk** ("baked"): nothing is re-quantized when the server starts.
|
||
|
||
| part | format | kernel in vLLM 0.32 XPU |
|
||
|---|---|---|
|
||
| 142 body linears (attn q/k/v/o, conv in/out, MLP w1/w2/w3) | GPTQ INT4, symmetric, group 128 | `XPUwNa16LinearKernel` (oneDNN `int4_gemm_w4a16`) |
|
||
| `lm_head` (untied, 128,000 × 2,048) | GPTQ INT4, symmetric, group 128, Hessian from the final-norm activations | same kernel |
|
||
| `embed_tokens` | INT8 symmetric, one BF16 scale per row | `CompressedTensorsEmbeddingWNA16Int` (gathers and dequantizes only the looked-up rows) |
|
||
| `self_attn.gate_proj` (11 × 16 × 2,048), conv kernels, norms | BF16 | — |
|
||
|
||
Format: compressed-tensors `pack-quantized` (one `model.safetensors`, `quantization_config` in `config.json`),
|
||
`tie_word_embeddings: false`. The body and the head use the same scheme, so they run on the same kernel.
|
||
|
||
**Runtime:** vLLM has no LFM3 support upstream yet. This checkpoint needs the out-of-tree LFM3 plugin from
|
||
`xpu-llm-ports` (`lfm3/`, image `lfm3-vllm-xpu:v0.32.0-lfm3-baked`). The plugin passes `quant_config` to the
|
||
token embedding; everything else is stock vLLM.
|
||
|
||
## Recipe
|
||
|
||
Recipe modelled on [Launch80/Qwen3.8-27B-GPTQ-Int4-baked](https://huggingface.co/Launch80/Qwen3.8-27B-GPTQ-Int4-baked)
|
||
and [Wrapzii/Swift-1.5-Qwen3.8-27b-GPTQ-Int4-baked-v1-embed-int8](https://huggingface.co/Wrapzii/Swift-1.5-Qwen3.8-27b-GPTQ-Int4-baked-v1-embed-int8):
|
||
GPTQ INT4 body, a calibrated GPTQ INT4 head stored on disk, INT8 embedding.
|
||
|
||
1. **Calibration set:** 256 × 2,048 tokens (524k), rendered with the model's own chat template and packed:
|
||
English chat 45% (ultrachat_200k), German 20% (oasst1 de), tool calls 15% (glaive-function-calling-v2,
|
||
converted to the template's tool format), Python code 20% (python_code_instructions_18k_alpaca).
|
||
2. **Body:** llm-compressor 0.15.0 `GPTQModifier`, W4A16, sym, group 128, `actorder=static` (no runtime
|
||
g_idx), damping 0.05, block 128, sequential pipeline per `Lfm3DecoderLayer`. Checked: the traced pipeline
|
||
reproduces the plain forward exactly (max |Δlogit| 0.0 over 1,000 tokens), so every layer is calibrated
|
||
with its own RoPE and sliding/full mask. 8.3 min on the B65.
|
||
3. **Head:** own GPTQ solver after the B65 head bake (launch80/B65, MIT).
|
||
- Hessian = Σ xᵀx over the lm_head input, i.e. the final norm output of the *INT4-body* model on the
|
||
calibration set (516,096 rows). Every 64th row held out (8,192).
|
||
- Grid of damping 0.1–10% × natural or static act-order × absmax or MSE-clipped scales. One half of the
|
||
held-out rows picks the setting, the other half is reported.
|
||
- Chosen: damp 0.3%, static act-order, MSE-clipped scales. Scales are rounded to BF16 before codes are
|
||
chosen.
|
||
4. **Embedding:** per-row absmax/127, BF16 scales, codes from the rounded scale.
|
||
|
||
Settings and all grid results: `BAKE.json`; body run info: `quant_run.json`.
|
||
|
||
## Sizes
|
||
|
||
| variant | model.safetensors | vLLM weight memory | read per decode step |
|
||
|---|--:|--:|--:|
|
||
| BF16 original | 3.458 GB | 3.24 GiB | 3.46 GB |
|
||
| FP8 per-channel (online, from BF16) | — | 1.88 GiB | 2.02 GB |
|
||
| GPTQ INT4 body, tied BF16 head | 1.282 GB | 1.24 GiB | 1.28 GB |
|
||
| **this checkpoint** | **1.155 GB** | **1.12 GiB** | **0.89 GB** |
|
||
|
||
## Quality gates
|
||
|
||
Wikitext-2 test perplexity (40,940 scored tokens, 20 × 2,048, via vLLM prompt_logprobs). Eight chat prompts:
|
||
math, factual, German e-mail, two tool calls, JSON extraction, 2k-token summary, needle at 700+ tokens.
|
||
|
||
| variant | PPL | vs BF16 | 8 prompts | completion tokens |
|
||
|---|--:|--:|---|--:|
|
||
| BF16 | 18.518 | — | 8/8 | 3,790 |
|
||
| FP8 per-channel | 18.523 | +0.03% | 8/8 | 3,803 |
|
||
| AutoRound INT4 (tied BF16 head) | 19.835 | +7.1% | 8/8 | 4,274 |
|
||
| GPTQ INT4 body (tied BF16 head) | 19.861 | +7.3% | 8/8 | 3,248 |
|
||
| GPTQ body + RTN INT4 head + INT8 embed | 20.286 | +9.5% | 8/8 | 3,330 |
|
||
| **this checkpoint** | **20.014** | **+8.1%** | **8/8** | 3,487 |
|
||
|
||
Both tool calls are byte-identical to BF16 in every variant.
|
||
|
||
Per-layer error on held-out activations (rows not used for the choice):
|
||
|
||
| tensor | GPTQ | RTN |
|
||
|---|--:|--:|
|
||
| lm_head, relative output L2 | **5.07%** | 7.49% |
|
||
| lm_head, top-1 agreement with BF16 | **96.4%** | 94.1% |
|
||
| embed_tokens INT8, relative L2 of the looked-up rows | 0.87% | — |
|
||
|
||
The GPTQ head adds +0.15 PPL to the body-only checkpoint, the RTN head +0.43. LFM3's 2,048-wide head gains
|
||
less from GPTQ than the 5,120-wide Qwen head in the reference cards (3.5% vs 7.6% there).
|
||
|
||
## Benchmarks (Arc Pro B65, vLLM 0.32.0 XPU, compile + graphs, bf16 KV, single GPU, thinking default)
|
||
|
||
BetterBench 0.6.1 `--quick`, bench-standard config, direct on the server:
|
||
|
||
| variant | decode t/s | ITL 1% low t/s | TTFT p50 | aggregate @8 t/s | prefill @32k t/s |
|
||
|---|--:|--:|--:|--:|--:|
|
||
| BF16 | 127.6 | 106.3 | 60 ms | 763.7 | 16,618 |
|
||
| FP8 per-channel | 189.9 | 117.4 | 61 ms | 1,082.2 | 16,514 |
|
||
| AutoRound INT4 | 227.7 | 163.1 | 59 ms | 1,139.2 | 14,125 |
|
||
| GPTQ INT4 body only | 217.6 | 134.2 | 62 ms | 1,134.9 | 14,098 |
|
||
| **this checkpoint** | **217.5** | 134.4 | 61 ms | **1,156.6** | 14,284 |
|
||
|
||
bench-standard 0.5.0 (`bench.sh`, unmodified), greedy output identical 3/3:
|
||
|
||
| run | decode t/s | TTFT p50 | concurrency 1 / 2 / 4 / 8 t/s | prefill 2k / 8k / 16k / 32k t/s | J per decoded token |
|
||
|---|--:|--:|---|---|--:|
|
||
| full | 217.2 | 64 ms | 209 / 392 / 695 / 1,119 | 14,155 / 15,743 / 15,170 / 14,050 | 0.66 |
|
||
| quick | 214.7 | 65 ms | 207 / 380 / 689 / 1,152 | 13,929 / 15,652 / 15,314 / 14,224 | 0.67 |
|
||
|
||
Against FP8 per-channel (round 5), decode is +8% to +16% in all 8 BetterBench categories.
|
||
|
||
Note: the smaller head and embedding did **not** make single-stream decode faster on this setup. In an
|
||
interleaved TPOT run, this checkpoint, an INT4-head + BF16-embedding build and the tied-BF16-head body all
|
||
measured 4.3–4.5 ms/token. The INT4 head is 0.57 ms faster than the BF16 head in isolation, so decode at
|
||
~220 t/s seems limited by something other than weight bytes.
|
||
|
||
## Serve
|
||
|
||
```bash
|
||
docker run -d --rm --name lfm3-int4-baked \
|
||
--device /dev/dri --group-add 991 --ipc=host --shm-size=16g \
|
||
-p 127.0.0.1:8000:8000 \
|
||
-v /dev/dri:/dev/dri -v /dev/dri/by-path:/dev/dri/by-path:ro \
|
||
-v /models/LFM3-1.7B-GPTQ-Int4-baked-v1-embed-int8:/model:ro \
|
||
-e HF_HUB_OFFLINE=1 -e TRANSFORMERS_OFFLINE=1 \
|
||
lfm3-vllm-xpu:v0.32.0-lfm3-baked /model --host=0.0.0.0 --port=8000 \
|
||
--served-model-name=lfm3-1.7b --gpu-memory-utilization=0.5 --dtype=bfloat16 \
|
||
--max-model-len=32768 --enable-auto-tool-choice --tool-call-parser=qwen3_coder --reasoning-parser=qwen3
|
||
```
|
||
|
||
No `--quantization` flag (read from `config.json`), no `--trust-remote-code`, no special env vars.
|
||
`generation_config.json` (Liquid's defaults: temperature 0.1, top_k 50, repetition_penalty 1.1) applies as
|
||
server-side default.
|
||
|
||
## Credits and license
|
||
|
||
- **LFM3-1.7B** by [Liquid AI](https://huggingface.co/LiquidAI), under the **LFM Open License v1.0**
|
||
(see `LICENSE`, retained unchanged). This is a quantized derivative. It is not an official Liquid AI
|
||
release, and Liquid AI does not endorse it.
|
||
- Recipe after **Launch80** ([B65](https://github.com/launch80/B65), MIT: in-engine Hessian head bake, GPTQ
|
||
vs RTN gate) and **Wrapzii** (INT8 embedding, GPTQ head bake on Swift 1.5).
|
||
- Body quantization: [llm-compressor](https://github.com/vllm-project/llm-compressor) (Apache-2.0).
|
||
- Modified files: `model.safetensors` (all weights quantized as above), `config.json`
|
||
(`quantization_config`, `tie_word_embeddings: false`); added `BAKE.json`, `quant_run.json`, `README.md`,
|
||
`SHA256SUMS`. All other files are from LiquidAI/LFM3-1.7B unchanged.
|
||
|
||
Checksums: `SHA256SUMS` (`sha256sum -c SHA256SUMS`).
|