Image-Text-to-Text
Transformers
Safetensors
qwen3_5
nvfp4
fp8
kv-cache
mtp
speculative-decoding
vllm
llm-compressor
hybrid
gated-deltanet
conversational
8-bit precision
compressed-tensors
Instructions to use ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP") model = AutoModelForMultimodalLM.from_pretrained("ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP
- SGLang
How to use ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP with Docker Model Runner:
docker model run hf.co/ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen3.8-27B
|
| 4 |
+
tags:
|
| 5 |
+
- nvfp4
|
| 6 |
+
- fp8
|
| 7 |
+
- kv-cache
|
| 8 |
+
- mtp
|
| 9 |
+
- speculative-decoding
|
| 10 |
+
- vllm
|
| 11 |
+
- llm-compressor
|
| 12 |
+
- hybrid
|
| 13 |
+
- gated-deltanet
|
| 14 |
+
datasets:
|
| 15 |
+
- HuggingFaceH4/ultrachat_200k
|
| 16 |
+
- openai/gsm8k
|
| 17 |
+
- sahil2801/CodeAlpaca-20k
|
| 18 |
+
- CohereLabs/aya_dataset
|
| 19 |
+
pipeline_tag: image-text-to-text
|
| 20 |
+
library_name: transformers
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# Qwen3.8-27B-NVFP4-FP8KV-MTP by IG1
|
| 24 |
+
|
| 25 |
+
## Quantization
|
| 26 |
+
|
| 27 |
+
This model has been quantized using **llm-compressor v0.13.0** and **transformers v5.14.1**. It is based on the official example with a few modifications (see next section).
|
| 28 |
+
|
| 29 |
+
### Quantization particularities
|
| 30 |
+
|
| 31 |
+
The sequence length has been increased to 8192 and the number of samples to 1024.
|
| 32 |
+
The 1024 samples come from 4 different datasets:
|
| 33 |
+
|
| 34 |
+
- 256 general conversation samples (UltraChat)
|
| 35 |
+
- 256 math reasoning samples (GSM8K)
|
| 36 |
+
- 256 code samples (CodeAlpaca)
|
| 37 |
+
- 256 multilingual samples (Aya)
|
| 38 |
+
|
| 39 |
+
You can find the quantization script [here](nvfp4-kvfp8-mtp.py).
|
| 40 |
+
|
| 41 |
+
The recipe targets `Linear` layers with the `NVFP4` scheme, while excluding:
|
| 42 |
+
- `lm_head`
|
| 43 |
+
- `re:.*visual.*` (vision tower)
|
| 44 |
+
- `re:.*linear_attn.*` (Gated DeltaNet layers)
|
| 45 |
+
|
| 46 |
+
### About FP8 KV cache
|
| 47 |
+
|
| 48 |
+
Unlike our previous Qwen3.5/3.6 experiments, **FP8 KV cache works correctly on Qwen3.8** thanks to the observer fusion fix in llm-compressor 0.13.0.
|
| 49 |
+
|
| 50 |
+
The checkpoint contains **calibrated static FP8 scales** (`k_scale`/`v_scale`) for the 16 full-attention layers. These scales are **passive metadata**:
|
| 51 |
+
|
| 52 |
+
- **Without `--kv-cache-dtype fp8`**: vLLM ignores them and uses BF16 KV cache (default, recommended for maximum quality)
|
| 53 |
+
- **With `--kv-cache-dtype fp8`**: vLLM uses the calibrated scales for FP8 KV cache
|
| 54 |
+
|
| 55 |
+
**Important note on capacity**: On this hybrid architecture, FP8 KV cache does **not** significantly increase total KV cache capacity. The Gated DeltaNet state (48 layers) dominates memory usage and is not affected by `--kv-cache-dtype`. FP8 KV provides a modest decode speedup on the 16 attention layers, not more context length.
|
| 56 |
+
|
| 57 |
+
## Qwen3.8 Modes & Reverse Proxy
|
| 58 |
+
|
| 59 |
+
Qwen 3.8 natively supports several runtime modes (instruct, thinking, preserve thinking) and multiple reasoning effort levels. Activating them requires sending vendor-specific parameters such as `chat_template_kwargs`, which most standard OpenAI clients do not expose.
|
| 60 |
+
|
| 61 |
+
To solve this, we built a lightweight reverse proxy that exposes each official mode as a distinct virtual model name. Your client simply picks the model — the proxy automatically injects the correct `chat_template_kwargs`, sampling parameters, and reasoning effort:
|
| 62 |
+
|
| 63 |
+
- `qwen38-instruct` — Native instruct mode (no reasoning)
|
| 64 |
+
- `qwen38-thinking` — Thinking mode, `reasoning_effort` controllable by the client
|
| 65 |
+
- `qwen38-thinking-preserve` — Thinking mode with historical thinking preservation
|
| 66 |
+
- Optional pre-configured variants: `-low`, `-medium`, `-xhigh` for each thinking mode
|
| 67 |
+
|
| 68 |
+
View the project on our GitHub: [iguanesolutions/qwen38-rp](https://github.com/iguanesolutions/qwen38-rp)
|
| 69 |
+
|
| 70 |
+
## Inference
|
| 71 |
+
|
| 72 |
+
We run this model with vLLM, here is a sample execution command (from the official [vllm's recipe](https://recipes.vllm.ai/Qwen/Qwen3.8-27B)):
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
docker run --rm --name 'Qwen3.8' --gpus all --privileged --ipc=host -p 8000:8000 \
|
| 76 |
+
-v /srv/cache:/root/.cache \
|
| 77 |
+
vllm/vllm-openai:qwen38 ig1/Qwen3.8-27B-NVFP4-FP8KV-MTP \
|
| 78 |
+
--served-model-name 'Qwen3.8-27B' \
|
| 79 |
+
--max-model-len auto \
|
| 80 |
+
--enable-auto-tool-choice \
|
| 81 |
+
--tool-call-parser qwen3_coder \
|
| 82 |
+
--reasoning-parser qwen3 \
|
| 83 |
+
--speculative-config '{"method":"mtp","num_speculative_tokens":2}'
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
> **Note**: The `vllm/vllm-openai:qwen38` image is a temporary build with Qwen3.8 support. Once the next official vLLM release is out, use the standard `vllm/vllm-openai:latest` (or the release tag) instead.
|
| 87 |
+
|
| 88 |
+
A few notes about some of the parameters:
|
| 89 |
+
|
| 90 |
+
- Adapt the `/srv/cache:/root/.cache` mount point to your liking. It contains files you want to keep between multiple runs (dynamo bytecode and AOT with torch compile but most importantly the huggingface folder for the model).
|
| 91 |
+
- `--reasoning-parser qwen3` and `--tool-call-parser qwen3_coder` are required for the reverse proxy's thinking modes and tool calls.
|
| 92 |
+
- `--speculative-config '{"method":"mtp","num_speculative_tokens":2}'` enables Multi-Token Prediction for lower latency. We recommend `2` over `3` based on acceptance rate measurements (~56% average draft acceptance with 3 tokens, better efficiency with 2).
|
| 93 |
+
|
| 94 |
+
### Optional: FP8 KV cache
|
| 95 |
+
|
| 96 |
+
To enable FP8 KV cache with the calibrated scales, add:
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
--kv-cache-dtype fp8
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
Expected effects:
|
| 103 |
+
- ~10-20% decode speedup on attention layers
|
| 104 |
+
- No significant change in total KV cache capacity (see note above)
|
| 105 |
+
- Quality preserved thanks to calibrated scales
|
| 106 |
+
|
| 107 |
+
### Speculative Decoding (MTP)
|
| 108 |
+
|
| 109 |
+
The layers responsible for Multi-Token Prediction have not been quantized and are available separately in the `model_mtp.safetensors` file. vLLM loads them automatically when `--speculative-config` is provided.
|
| 110 |
+
|
| 111 |
+
This is recommended for latency-focused serving scenarios (not total throughput/massive concurrent requests).
|
| 112 |
+
|
| 113 |
+
## License
|
| 114 |
+
|
| 115 |
+
This model is a quantized version of [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B). Please refer to the original model card for license and usage terms.
|