Image-Text-to-Text
Transformers
Safetensors
English
Chinese
Korean
internvl
internvl3.5
vision-language
multimodal
vllm
compressed-tensors
fp8
w8a16
ampere
wsl2
conversational
Instructions to use hsmin92/internvl35-fp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hsmin92/internvl35-fp8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="hsmin92/internvl35-fp8") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("hsmin92/internvl35-fp8") model = AutoModelForMultimodalLM.from_pretrained("hsmin92/internvl35-fp8", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hsmin92/internvl35-fp8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hsmin92/internvl35-fp8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hsmin92/internvl35-fp8", "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/hsmin92/internvl35-fp8
- SGLang
How to use hsmin92/internvl35-fp8 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 "hsmin92/internvl35-fp8" \ --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": "hsmin92/internvl35-fp8", "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 "hsmin92/internvl35-fp8" \ --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": "hsmin92/internvl35-fp8", "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 hsmin92/internvl35-fp8 with Docker Model Runner:
docker model run hf.co/hsmin92/internvl35-fp8
Update model card: dtype half warning, right-sized 8 GB config, AWQ cross-reference
Browse files
README.md
CHANGED
|
@@ -23,17 +23,45 @@ tags:
|
|
| 23 |
|
| 24 |
# InternVL3.5-4B-HF FP8 Dynamic
|
| 25 |
|
| 26 |
-
|
| 27 |
[OpenGVLab/InternVL3_5-4B-HF](https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF),
|
| 28 |
prepared for memory-conscious vLLM serving.
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
## Important runtime note
|
| 31 |
|
| 32 |
The checkpoint stores the language decoder Linear weights in FP8 E4M3 format.
|
| 33 |
-
On an NVIDIA Ampere GPU such as the RTX 3070, vLLM
|
| 34 |
-
through its W8A16 FP8 path
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
## Quantization scope
|
| 39 |
|
|
@@ -43,7 +71,8 @@ Quantized:
|
|
| 43 |
- Scheme: `FP8_DYNAMIC`
|
| 44 |
- Weight format: FP8 E4M3
|
| 45 |
- Activation scaling: dynamic per token at runtime
|
| 46 |
-
- Calibration dataset: not required
|
|
|
|
| 47 |
|
| 48 |
Kept in BF16:
|
| 49 |
|
|
@@ -53,7 +82,7 @@ Kept in BF16:
|
|
| 53 |
- `lm_head`
|
| 54 |
- Normalization layers and other protected parameters
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
```text
|
| 59 |
6bd4487402110ef9889ba50eb7aefeb302526fed
|
|
@@ -63,204 +92,320 @@ See [`quantization/recipe.py`](./quantization/recipe.py) for the compression rec
|
|
| 63 |
|
| 64 |
## Verified environment
|
| 65 |
|
| 66 |
-
The following setup was used for the initial serving validation:
|
| 67 |
-
|
| 68 |
| Component | Version / value |
|
| 69 |
|---|---|
|
| 70 |
-
| GPU | NVIDIA GeForce RTX 3070
|
| 71 |
-
| Host | Windows + WSL2 |
|
| 72 |
-
| WSL distribution | Ubuntu 24.04 |
|
| 73 |
| NVIDIA driver | 591.86 |
|
| 74 |
-
|
|
|
|
|
| 75 |
| PyTorch | 2.11.0+cu130 |
|
| 76 |
| Transformers | 5.14.1 |
|
| 77 |
-
| Quantization backend | compressed-tensors |
|
| 78 |
-
|
|
| 79 |
-
| Attention | FlashAttention 2 |
|
| 80 |
-
| Max context used in validation | 2,048 tokens |
|
| 81 |
-
| Maximum images per request | 4 |
|
| 82 |
-
|
| 83 |
-
Observed during startup with the verified preset:
|
| 84 |
|
| 85 |
-
|
| 86 |
-
- Available KV-cache memory: approximately **0.59 GiB**
|
| 87 |
-
- GPU KV-cache capacity: **4,288 tokens**
|
| 88 |
-
- Validated RTX 3070 profile: `--gpu-memory-utilization 0.80` with `--kv-cache-memory-bytes 384M`, using approximately **6.3-6.4 GiB** for the vLLM process
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
> **RTX 3070 runtime profile:** The included startup script disables the V2
|
| 96 |
-
> model runner, FlashInfer sampling JIT, and DeepGEMM. It uses the Ampere-compatible
|
| 97 |
-
> Humming W8A16 kernel for the FP8 checkpoint.
|
| 98 |
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
##
|
| 101 |
-
|
| 102 |
-
Humming compiles a small runtime extension on first use.
|
| 103 |
|
| 104 |
```bash
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
```
|
| 108 |
|
| 109 |
-
|
| 110 |
-
driver exposes `libcuda.so` under `/usr/lib/wsl/lib`.
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
```
|
| 121 |
|
| 122 |
-
|
| 123 |
|
| 124 |
-
``
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
```
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
``
|
| 131 |
-
|
| 132 |
-
./scripts/start_vllm_wsl_rtx3070.sh
|
| 133 |
-
```
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
```text
|
| 138 |
-
|
|
|
|
| 139 |
```
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
```text
|
| 144 |
-
|
|
|
|
| 145 |
```
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
```text
|
| 150 |
-
|
|
|
|
| 151 |
```
|
| 152 |
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
```bash
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
./scripts/start_vllm_wsl_rtx3070.sh
|
| 162 |
```
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
Windows desktop and browser processes also consume VRAM.
|
| 167 |
|
| 168 |
-
##
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
| `PORT` | `8000` | Listen port |
|
| 178 |
-
| `MAX_MODEL_LEN` | `2048` | Total context budget, including image and output tokens |
|
| 179 |
-
| `MAX_NUM_SEQS` | `1` | Maximum concurrent sequences |
|
| 180 |
-
| `MAX_IMAGES` | `4` | Maximum images in one request |
|
| 181 |
-
| `GPU_MEMORY_UTILIZATION` | `0.80` | RTX 3070 GPU-memory safety target |
|
| 182 |
-
| `KV_CACHE_MEMORY_BYTES` | `384M` | Fixed KV-cache size for the RTX 3070 8GB profile |
|
| 183 |
|
| 184 |
-
|
| 185 |
|
| 186 |
```bash
|
| 187 |
-
|
| 188 |
-
./scripts/start_vllm_wsl_rtx3070.sh
|
| 189 |
```
|
| 190 |
|
| 191 |
-
##
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
| 198 |
```
|
| 199 |
|
| 200 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
```bash
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
```
|
| 205 |
|
| 206 |
-
##
|
| 207 |
|
| 208 |
```bash
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
```
|
| 212 |
|
| 213 |
The image client sends the local image as a base64 data URL and uses only the
|
| 214 |
Python standard library.
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
## Native Linux and other GPUs
|
| 217 |
|
| 218 |
-
The WSL2 script
|
| 219 |
-
|
| 220 |
|
| 221 |
- `VLLM_USE_V2_MODEL_RUNNER=0` because the V2 runner required UVA in this WSL setup.
|
| 222 |
- `VLLM_USE_FLASHINFER_SAMPLER=0` because FlashInfer sampling JIT required `nvcc`.
|
|
|
|
| 223 |
- `/usr/lib/wsl/lib` is added to the compile and runtime linker paths.
|
| 224 |
- pip-installed CUDA NVRTC libraries are added to `LD_LIBRARY_PATH`.
|
| 225 |
-
- `--enforce-eager` disables CUDA graphs and `torch.compile` for compatibility.
|
| 226 |
|
| 227 |
-
Native Linux systems with a full CUDA Toolkit or newer GPUs may not need
|
| 228 |
-
|
| 229 |
-
one at a time and validate output quality, memory, and stability
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
## Intended use
|
| 232 |
|
| 233 |
-
This model is suitable for experimentation with:
|
| 234 |
-
|
| 235 |
- Image understanding
|
| 236 |
-
- Multi-image comparison
|
| 237 |
- CCTV frame summarization
|
| 238 |
- Visual question answering
|
| 239 |
- OpenAI-compatible multimodal API integration
|
| 240 |
|
| 241 |
-
For video
|
| 242 |
-
|
| 243 |
-
|
| 244 |
|
| 245 |
## Limitations
|
| 246 |
|
| 247 |
-
-
|
| 248 |
-
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
|
|
|
| 255 |
- VRAM figures depend on driver, desktop applications, context length,
|
| 256 |
multimodal limits, and vLLM version.
|
| 257 |
|
| 258 |
## Attribution and license
|
| 259 |
|
| 260 |
-
|
| 261 |
[OpenGVLab/InternVL3_5-4B-HF](https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF).
|
| 262 |
The original project and this derivative are distributed under the Apache-2.0
|
| 263 |
-
license. Review the upstream model card for
|
| 264 |
limitations, and citation information.
|
| 265 |
|
| 266 |
## Citation
|
|
|
|
| 23 |
|
| 24 |
# InternVL3.5-4B-HF FP8 Dynamic
|
| 25 |
|
| 26 |
+
A compressed-tensors **FP8 Dynamic** quantization of
|
| 27 |
[OpenGVLab/InternVL3_5-4B-HF](https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF),
|
| 28 |
prepared for memory-conscious vLLM serving.
|
| 29 |
|
| 30 |
+
A companion AWQ W4A16 build of the same base model is at
|
| 31 |
+
[hsmin92/internvl35-4b-awq-w4a16-g128](https://huggingface.co/hsmin92/internvl35-4b-awq-w4a16-g128).
|
| 32 |
+
On an 8 GB card the AWQ build is the better fit — see
|
| 33 |
+
[Choosing between the FP8 and AWQ builds](#choosing-between-the-fp8-and-awq-builds).
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## ⚠️ Do not use `--dtype half`
|
| 38 |
+
|
| 39 |
+
`--dtype half` produces a server that starts normally, returns HTTP 200 from
|
| 40 |
+
`/health`, reports a healthy container health check — and answers **every
|
| 41 |
+
request with `!!!!!!!!`**. Dequantizing FP8 E4M3 weights into FP16 overflows
|
| 42 |
+
the FP16 range, the logits become NaN, and argmax selects token 0.
|
| 43 |
+
|
| 44 |
+
It fails silently, so a liveness probe will not catch it. Always send a real
|
| 45 |
+
request after a configuration change, not just a health check.
|
| 46 |
+
|
| 47 |
+
Use `--dtype bfloat16`. The checkpoint declares `bfloat16` in `config.json`,
|
| 48 |
+
Ampere supports BF16 natively, and the memory cost is identical to FP16.
|
| 49 |
+
|
| 50 |
+
> **The bundled `scripts/start_vllm_wsl_rtx3070.sh` in this repository still
|
| 51 |
+
> passes `--dtype half` and is affected.** Change that line to
|
| 52 |
+
> `--dtype bfloat16` before using the script, or use the `vllm serve` command
|
| 53 |
+
> in [Serving with vLLM](#serving-with-vllm) instead.
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
## Important runtime note
|
| 58 |
|
| 59 |
The checkpoint stores the language decoder Linear weights in FP8 E4M3 format.
|
| 60 |
+
On an NVIDIA Ampere GPU such as the RTX 3070, vLLM serves these weights
|
| 61 |
+
through its **W8A16** FP8 path: weights stay compressed to 8-bit while
|
| 62 |
+
activations run in 16-bit. This is a VRAM-saving configuration; **a speedup is
|
| 63 |
+
not guaranteed on Ampere**, and in practice this build is 2–4× slower than the
|
| 64 |
+
AWQ build on the same card.
|
| 65 |
|
| 66 |
## Quantization scope
|
| 67 |
|
|
|
|
| 71 |
- Scheme: `FP8_DYNAMIC`
|
| 72 |
- Weight format: FP8 E4M3
|
| 73 |
- Activation scaling: dynamic per token at runtime
|
| 74 |
+
- **Calibration dataset: not required** — unlike AWQ, this build carries no
|
| 75 |
+
calibration-domain risk
|
| 76 |
|
| 77 |
Kept in BF16:
|
| 78 |
|
|
|
|
| 82 |
- `lm_head`
|
| 83 |
- Normalization layers and other protected parameters
|
| 84 |
|
| 85 |
+
Generated from the base-model revision:
|
| 86 |
|
| 87 |
```text
|
| 88 |
6bd4487402110ef9889ba50eb7aefeb302526fed
|
|
|
|
| 92 |
|
| 93 |
## Verified environment
|
| 94 |
|
|
|
|
|
|
|
| 95 |
| Component | Version / value |
|
| 96 |
|---|---|
|
| 97 |
+
| GPU | NVIDIA GeForce RTX 3070 8 GB (Ampere, SM 8.6) |
|
| 98 |
+
| Host | Windows 11 + WSL2 (Ubuntu 24.04), Docker Desktop |
|
|
|
|
| 99 |
| NVIDIA driver | 591.86 |
|
| 100 |
+
| Serving image | `vllm/vllm-openai:v0.26.0` |
|
| 101 |
+
| vLLM | 0.26.0 (V1 engine) |
|
| 102 |
| PyTorch | 2.11.0+cu130 |
|
| 103 |
| Transformers | 5.14.1 |
|
| 104 |
+
| Quantization backend | compressed-tensors 0.17.0 |
|
| 105 |
+
| Attention backend | FlashInfer with fp8 KV, FlashAttention with fp16 KV |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
Startup with the command below:
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
```text
|
| 110 |
+
Model loading took 5.51 GiB memory and 7.46 seconds
|
| 111 |
+
GPU KV cache size: 9,088 tokens
|
| 112 |
+
Maximum concurrency for 8,192 tokens per request: 1.11x
|
| 113 |
+
```
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
Total process footprint is about **7.8 GB** on an 8 GB card that is also
|
| 116 |
+
driving a desktop. This build uses essentially the whole card; see
|
| 117 |
+
[VRAM budget](#vram-budget).
|
| 118 |
|
| 119 |
+
## Serving with vLLM
|
|
|
|
|
|
|
| 120 |
|
| 121 |
```bash
|
| 122 |
+
vllm serve hsmin92/internvl35-fp8 \
|
| 123 |
+
--served-model-name internvl35-fp8 \
|
| 124 |
+
--dtype bfloat16 \
|
| 125 |
+
--max-model-len 8192 \
|
| 126 |
+
--max-num-seqs 8 \
|
| 127 |
+
--max-num-batched-tokens 4096 \
|
| 128 |
+
--limit-mm-per-prompt '{"image":2,"video":0}' \
|
| 129 |
+
--gpu-memory-utilization 0.85 \
|
| 130 |
+
--kv-cache-memory-bytes 640M \
|
| 131 |
+
--kv-cache-dtype fp8 \
|
| 132 |
+
--enforce-eager \
|
| 133 |
+
--trust-remote-code \
|
| 134 |
+
--enable-auto-tool-choice \
|
| 135 |
+
--tool-call-parser hermes
|
| 136 |
```
|
| 137 |
|
| 138 |
+
Then use the OpenAI-compatible endpoint at `http://127.0.0.1:8000/v1`.
|
|
|
|
| 139 |
|
| 140 |
+
Each non-obvious flag is explained below.
|
| 141 |
|
| 142 |
+
### VRAM budget
|
| 143 |
|
| 144 |
+
Measured, all figures reported by vLLM itself:
|
| 145 |
+
|
| 146 |
+
```text
|
| 147 |
+
weights 5,642 MiB
|
| 148 |
+
context + activation peak 604 MiB
|
| 149 |
+
KV cache (pinned, fp8) 640 MiB -> 9,088 tokens
|
| 150 |
+
────────────────────────────────────────
|
| 151 |
+
vLLM process ~6,886 MiB -> --gpu-memory-utilization 0.841
|
| 152 |
```
|
| 153 |
|
| 154 |
+
There is almost no slack. Two consequences:
|
| 155 |
|
| 156 |
+
**`--kv-cache-dtype fp8` is required to reach an 8,192-token context.** With
|
| 157 |
+
FP16 KV, vLLM reports that only **5,680 tokens** fit:
|
| 158 |
+
|
| 159 |
+
```text
|
| 160 |
+
To serve at least one request with the model's max seq len (8192),
|
| 161 |
+
1.12 GiB KV cache is needed, which is larger than the available
|
| 162 |
+
KV cache memory (0.78 GiB). Based on the available memory, the
|
| 163 |
+
estimated maximum model length is 5680.
|
| 164 |
```
|
| 165 |
|
| 166 |
+
FP8 KV halves the per-token cost from 144 KiB to 72 KiB. It was validated on
|
| 167 |
+
Ampere through the auto-selected FlashInfer backend; text, a 7k-token context,
|
| 168 |
+
and two-image requests all produce correct output.
|
| 169 |
|
| 170 |
+
**`--enforce-eager` is required.** CUDA graphs need roughly another 0.5–1 GiB
|
| 171 |
+
that this build does not have. The AWQ build does capture them.
|
|
|
|
|
|
|
| 172 |
|
| 173 |
+
**`--gpu-memory-utilization` is a fraction of the free memory the process can
|
| 174 |
+
see, which is not what host `nvidia-smi` reports.** Under WSL2 the container
|
| 175 |
+
saw 6.93 GiB while the Windows host reported 7.48 GiB free, so the effective
|
| 176 |
+
ceiling was 0.866. Setting 0.87 was rejected outright:
|
| 177 |
|
| 178 |
```text
|
| 179 |
+
Free memory on device cuda:0 (6.93/8.0 GiB) on startup is less than
|
| 180 |
+
desired GPU memory utilization (0.87, 6.96 GiB)
|
| 181 |
```
|
| 182 |
|
| 183 |
+
### Pin the KV cache rather than letting utilization decide
|
| 184 |
+
|
| 185 |
+
Without `--kv-cache-memory-bytes`, vLLM expands the KV cache to fill whatever
|
| 186 |
+
`--gpu-memory-utilization` allows, so the cache size drifts between restarts
|
| 187 |
+
with whatever the desktop happens to be using — observed swings of several
|
| 188 |
+
thousand tokens on an otherwise identical configuration. Pinning it makes
|
| 189 |
+
startup deterministic, which matters here because the margin above the
|
| 190 |
+
8,192-token requirement is thin.
|
| 191 |
+
|
| 192 |
+
### `--max-num-seqs`: leaving it at the default costs throughput
|
| 193 |
+
|
| 194 |
+
The vLLM default is 128. When more concurrent requests arrive than the KV
|
| 195 |
+
cache can hold, vLLM preempts and recomputes, and throughput collapses below
|
| 196 |
+
what a smaller limit achieves. With a 640 MiB fp8 cache (9,088 tokens) and
|
| 197 |
+
typical requests of ~1,084 prompt tokens, about 8 requests fit; use that as
|
| 198 |
+
the limit.
|
| 199 |
+
|
| 200 |
+
Do **not** derive the limit from the `Maximum concurrency for 8,192 tokens per
|
| 201 |
+
request` line in the startup log — that figure assumes every request fills the
|
| 202 |
+
full context window, which real requests rarely do.
|
| 203 |
+
|
| 204 |
+
### `--max-num-batched-tokens` also sizes the multimodal encoder cache
|
| 205 |
+
|
| 206 |
+
This is not a VRAM tuning knob. The vLLM default of 2048 rejects large images
|
| 207 |
+
outright, on any card:
|
| 208 |
|
| 209 |
```text
|
| 210 |
+
image item with 2816 embedding tokens, which exceeds the
|
| 211 |
+
pre-allocated encoder cache size 2048
|
| 212 |
```
|
| 213 |
|
| 214 |
+
InternVL dynamic tiling allows up to 12 patches plus a thumbnail, so a single
|
| 215 |
+
image can reach **3,329 embedding tokens**. Use at least 4096.
|
| 216 |
+
|
| 217 |
+
### Tool-call flags are needed even without tool calling
|
| 218 |
+
|
| 219 |
+
`--enable-auto-tool-choice` and `--tool-call-parser` are required for the
|
| 220 |
+
server to *accept* requests that carry a `tool_choice` field. Open WebUI sends
|
| 221 |
+
`tool_choice: "auto"` by default, so omitting the flags makes it fail with:
|
| 222 |
|
| 223 |
```text
|
| 224 |
+
"auto" tool choice requires --enable-auto-tool-choice and
|
| 225 |
+
--tool-call-parser to be set
|
| 226 |
```
|
| 227 |
|
| 228 |
+
Actual tool calling still does not work: the bundled `chat_template.jinja` has
|
| 229 |
+
no tool rendering, so `tools=[...]` is silently ignored.
|
| 230 |
+
|
| 231 |
+
### Image token cost is driven by aspect ratio, not size
|
| 232 |
+
|
| 233 |
+
Tile count is chosen from the aspect ratio, so token cost is not monotonic in
|
| 234 |
+
resolution. Measured on this model family:
|
| 235 |
+
|
| 236 |
+
| Input size | Image tokens | Tiles |
|
| 237 |
+
|---|---|---|
|
| 238 |
+
| 448×448 | 257 | 1 |
|
| 239 |
+
| 896×448 | 769 | 3 |
|
| 240 |
+
| 960×544 | 769 | 3 |
|
| 241 |
+
| 800×450 | 769 | 3 |
|
| 242 |
+
| 2048×2048 | 2,561 | 10 |
|
| 243 |
+
| **200×150** | **3,329** | **13** |
|
| 244 |
+
| 4000×300 | 3,329 | 13 |
|
| 245 |
|
| 246 |
+
A 200×150 crop costs **4.3× more** than an 800×450 image, because 4:3 maps
|
| 247 |
+
exactly onto a 4×3 tile grid and the crop is upscaled to 1792×1344 for no
|
| 248 |
+
added information. Across randomly sized crops of a 960×544 frame, total
|
| 249 |
+
prompt cost swung between 1,040 and 4,112 tokens.
|
| 250 |
+
|
| 251 |
+
When sending region crops, letterbox them into a fixed 448×448 canvas
|
| 252 |
+
(preserving aspect ratio, no upscaling) to make cost constant. On a small-text
|
| 253 |
+
reading task this was several times faster than sending the raw crop, with no
|
| 254 |
+
loss of accuracy down to 14 px glyphs.
|
| 255 |
+
|
| 256 |
+
## Quick start: WSL2 + RTX 3070
|
| 257 |
+
|
| 258 |
+
> The bundled startup script disables the V2 model runner, FlashInfer sampling
|
| 259 |
+
> JIT, and DeepGEMM for Ampere/WSL2 compatibility.
|
| 260 |
+
> **It also passes `--dtype half`, which must be changed to `--dtype bfloat16`
|
| 261 |
+
> — see the warning at the top of this card.**
|
| 262 |
+
|
| 263 |
+
### 1. Install system build requirements
|
| 264 |
|
| 265 |
```bash
|
| 266 |
+
sudo apt update
|
| 267 |
+
sudo apt install -y build-essential python3.12-dev
|
|
|
|
| 268 |
```
|
| 269 |
|
| 270 |
+
Do not install a Linux NVIDIA display driver inside WSL2. The Windows NVIDIA
|
| 271 |
+
driver exposes `libcuda.so` under `/usr/lib/wsl/lib`.
|
|
|
|
| 272 |
|
| 273 |
+
### 2. Create the Python environment
|
| 274 |
|
| 275 |
+
Install [`uv`](https://docs.astral.sh/uv/) first when it is not already available.
|
| 276 |
|
| 277 |
+
```bash
|
| 278 |
+
uv venv --python 3.12 .venv-vllm
|
| 279 |
+
source .venv-vllm/bin/activate
|
| 280 |
+
uv pip install "vllm==0.26.0" hf_xet
|
| 281 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
+
### 3. Validate the environment
|
| 284 |
|
| 285 |
```bash
|
| 286 |
+
./scripts/check_wsl_runtime.sh
|
|
|
|
| 287 |
```
|
| 288 |
|
| 289 |
+
### 4. Start the server
|
| 290 |
|
| 291 |
+
Prefer the `vllm serve` command in [Serving with vLLM](#serving-with-vllm).
|
| 292 |
+
The bundled script is kept for the originally validated conservative profile
|
| 293 |
+
(2,048-token context, single sequence) and still needs the `--dtype` fix.
|
| 294 |
|
| 295 |
+
Successful startup ends with:
|
| 296 |
+
|
| 297 |
+
```text
|
| 298 |
+
Application startup complete.
|
| 299 |
```
|
| 300 |
|
| 301 |
+
### Running in Docker instead
|
| 302 |
+
|
| 303 |
+
The native script exists to work around WSL2 CUDA/NVRTC linking. Those
|
| 304 |
+
workarounds are unnecessary in a container: the official image ships CUDA and
|
| 305 |
+
NVRTC, and the NVIDIA container runtime injects `libcuda.so`.
|
| 306 |
|
| 307 |
```bash
|
| 308 |
+
docker run --rm --gpus all --ipc host -p 8000:8000 \
|
| 309 |
+
vllm/vllm-openai:v0.26.0 \
|
| 310 |
+
--model hsmin92/internvl35-fp8 \
|
| 311 |
+
--dtype bfloat16 --max-model-len 8192 --max-num-seqs 8 \
|
| 312 |
+
--max-num-batched-tokens 4096 --gpu-memory-utilization 0.85 \
|
| 313 |
+
--kv-cache-memory-bytes 640M --kv-cache-dtype fp8 --enforce-eager \
|
| 314 |
+
--limit-mm-per-prompt '{"image":2,"video":0}' --trust-remote-code \
|
| 315 |
+
--enable-auto-tool-choice --tool-call-parser hermes
|
| 316 |
```
|
| 317 |
|
| 318 |
+
## API tests
|
| 319 |
|
| 320 |
```bash
|
| 321 |
+
curl -s http://127.0.0.1:8000/health
|
| 322 |
+
curl -s http://127.0.0.1:8000/v1/models | python3 -m json.tool
|
| 323 |
+
./examples/chat_text.sh
|
| 324 |
+
python examples/chat_image.py /path/to/image.jpg "Describe the scene."
|
| 325 |
```
|
| 326 |
|
| 327 |
The image client sends the local image as a base64 data URL and uses only the
|
| 328 |
Python standard library.
|
| 329 |
|
| 330 |
+
## Choosing between the FP8 and AWQ builds
|
| 331 |
+
|
| 332 |
+
Measured on the same RTX 3070, same vLLM version, each tuned to its own best
|
| 333 |
+
settings on this card:
|
| 334 |
+
|
| 335 |
+
| | **FP8 Dynamic** | AWQ W4A16 G128 |
|
| 336 |
+
|---|---|---|
|
| 337 |
+
| Weights on GPU | 5.51 GiB | **3.84 GiB** |
|
| 338 |
+
| KV cache | 9,088 tokens (fp8 KV) | **12,288 tokens (fp16 KV)** |
|
| 339 |
+
| KV dtype needed for 8192 ctx | fp8 (compromise) | **fp16** |
|
| 340 |
+
| CUDA graphs on 8 GB | not possible | **yes** |
|
| 341 |
+
| `--gpu-memory-utilization` needed | 0.85 (near the 0.866 ceiling) | **0.79** |
|
| 342 |
+
| Process VRAM | 7.8 GB | **6.6 GB** |
|
| 343 |
+
| Text generation, single request | 12–18 tok/s | **~2–4× faster** |
|
| 344 |
+
| Calibration data required | **no** | yes |
|
| 345 |
+
| Weight precision | **8-bit** | 4-bit |
|
| 346 |
+
|
| 347 |
+
**On an 8 GB card the AWQ build is the better choice** — it is faster, leaves
|
| 348 |
+
1.2 GB free, and needs no precision compromises on the KV cache or CUDA graphs.
|
| 349 |
+
|
| 350 |
+
This FP8 build remains preferable when weight precision matters more than
|
| 351 |
+
memory: it is 8-bit rather than 4-bit, and it required no calibration data, so
|
| 352 |
+
it carries no risk of a calibration set that does not match your domain. It is
|
| 353 |
+
also the better starting point on a larger card where VRAM is not the
|
| 354 |
+
constraint.
|
| 355 |
+
|
| 356 |
+
**Accuracy has not been compared between the two builds, or against the BF16
|
| 357 |
+
base model.** Benchmark both on your own data before choosing.
|
| 358 |
+
|
| 359 |
## Native Linux and other GPUs
|
| 360 |
|
| 361 |
+
The WSL2 script applies compatibility settings required by the validated
|
| 362 |
+
RTX 3070 environment:
|
| 363 |
|
| 364 |
- `VLLM_USE_V2_MODEL_RUNNER=0` because the V2 runner required UVA in this WSL setup.
|
| 365 |
- `VLLM_USE_FLASHINFER_SAMPLER=0` because FlashInfer sampling JIT required `nvcc`.
|
| 366 |
+
- `VLLM_USE_DEEP_GEMM=0` because DeepGEMM targets Hopper.
|
| 367 |
- `/usr/lib/wsl/lib` is added to the compile and runtime linker paths.
|
| 368 |
- pip-installed CUDA NVRTC libraries are added to `LD_LIBRARY_PATH`.
|
|
|
|
| 369 |
|
| 370 |
+
Native Linux systems with a full CUDA Toolkit, or newer GPUs, may not need
|
| 371 |
+
these. Start from the documented configuration, then remove compatibility
|
| 372 |
+
flags one at a time and validate output quality, memory, and stability after
|
| 373 |
+
each change. On a card with native FP8 Tensor Cores (Ada/Hopper) this
|
| 374 |
+
checkpoint runs on the true FP8 path rather than the W8A16 compatibility path,
|
| 375 |
+
and the performance picture changes completely.
|
| 376 |
|
| 377 |
## Intended use
|
| 378 |
|
|
|
|
|
|
|
| 379 |
- Image understanding
|
| 380 |
+
- Multi-image comparison (for example a full frame plus a zoomed crop)
|
| 381 |
- CCTV frame summarization
|
| 382 |
- Visual question answering
|
| 383 |
- OpenAI-compatible multimodal API integration
|
| 384 |
|
| 385 |
+
For video on an 8 GB GPU, sample a small number of frames externally, resize
|
| 386 |
+
them appropriately, and send them as multiple images rather than passing a
|
| 387 |
+
video.
|
| 388 |
|
| 389 |
## Limitations
|
| 390 |
|
| 391 |
+
- A quantized derivative, not an independently trained model.
|
| 392 |
+
- **No accuracy benchmark has been published for this checkpoint.** Functional
|
| 393 |
+
validation only: text generation, a 7k-token context, and multi-image
|
| 394 |
+
requests all produce coherent, correct answers on simple synthetic probes.
|
| 395 |
+
- The vision tower and output head remain BF16 and are a meaningful share of
|
| 396 |
+
the loaded weights.
|
| 397 |
+
- FP8 on Ampere is served through a W8A16 compatibility path, not native FP8
|
| 398 |
+
Tensor Core execution.
|
| 399 |
+
- The bundled `chat_template.jinja` has no tool-calling support.
|
| 400 |
- VRAM figures depend on driver, desktop applications, context length,
|
| 401 |
multimodal limits, and vLLM version.
|
| 402 |
|
| 403 |
## Attribution and license
|
| 404 |
|
| 405 |
+
A quantized derivative of
|
| 406 |
[OpenGVLab/InternVL3_5-4B-HF](https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF).
|
| 407 |
The original project and this derivative are distributed under the Apache-2.0
|
| 408 |
+
license. Review the upstream model card for original training details,
|
| 409 |
limitations, and citation information.
|
| 410 |
|
| 411 |
## Citation
|