hsmin92 commited on
Commit
e8805c1
·
verified ·
1 Parent(s): 7388ef0

Upload InternVL3.5-4B FP8 Dynamic checkpoint and vLLM guide

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ InternVL3.5-4B-HF FP8 Dynamic
2
+
3
+ This model is a quantized derivative of:
4
+ OpenGVLab/InternVL3_5-4B-HF
5
+ https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF
6
+
7
+ The upstream project is licensed under the Apache License 2.0.
8
+ The quantized checkpoint preserves the upstream model architecture and files,
9
+ with selected language decoder Linear weights compressed using FP8_DYNAMIC.
QUANTIZATION_INFO.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_directory": "/home/bellock/projects/internvl35-fp8/models/InternVL3_5-4B-HF",
3
+ "output_directory": "/home/bellock/projects/internvl35-fp8/models/InternVL3_5-4B-FP8-Dynamic",
4
+ "source_revision": "model_id=OpenGVLab/InternVL3_5-4B-HF\nrevision=6bd4487402110ef9889ba50eb7aefeb302526fed",
5
+ "quantization_scheme": "FP8_DYNAMIC",
6
+ "target_module_type": "Linear",
7
+ "target_linear_count": 252,
8
+ "protected_linear_count": 147,
9
+ "ignored_patterns": [
10
+ ".*vision_tower.*",
11
+ ".*multi_modal_projector.*",
12
+ ".*lm_head.*"
13
+ ],
14
+ "source_dtype": "torch.bfloat16",
15
+ "calibration_dataset": null,
16
+ "load_seconds": 0.8194205139998303,
17
+ "quantization_and_save_seconds": 17.089425016999485,
18
+ "python_version": "3.12.3",
19
+ "torch_version": "2.12.0+cu132",
20
+ "transformers_version": "5.10.1",
21
+ "llmcompressor_version": "0.12.0.1"
22
+ }
README.md ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: image-text-to-text
5
+ base_model: OpenGVLab/InternVL3_5-4B-HF
6
+ base_model_relation: quantized
7
+ language:
8
+ - en
9
+ - zh
10
+ - ko
11
+ tags:
12
+ - internvl
13
+ - internvl3.5
14
+ - vision-language
15
+ - multimodal
16
+ - vllm
17
+ - compressed-tensors
18
+ - fp8
19
+ - w8a16
20
+ - ampere
21
+ - wsl2
22
+ ---
23
+
24
+ # InternVL3.5-4B-HF FP8 Dynamic
25
+
26
+ This repository contains 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
+ ## 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 0.26.0 serves these weights
34
+ through its W8A16 FP8 path (Humming kernel): weights are compressed to 8-bit,
35
+ while activations run in FP16. This is primarily a VRAM-saving configuration;
36
+ a speedup is not guaranteed on Ampere.
37
+
38
+ ## Quantization scope
39
+
40
+ Quantized:
41
+
42
+ - 252 language decoder `Linear` modules
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
+
50
+ - Vision tower
51
+ - Multimodal projector
52
+ - Input embeddings
53
+ - `lm_head`
54
+ - Normalization layers and other protected parameters
55
+
56
+ The checkpoint was generated from the base-model revision:
57
+
58
+ ```text
59
+ 6bd4487402110ef9889ba50eb7aefeb302526fed
60
+ ```
61
+
62
+ See [`quantization/recipe.py`](./quantization/recipe.py) for the compression recipe.
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 8GB |
71
+ | Host | Windows + WSL2 |
72
+ | WSL distribution | Ubuntu 24.04 |
73
+ | NVIDIA driver | 591.86 |
74
+ | vLLM | 0.26.0 |
75
+ | PyTorch | 2.11.0+cu130 |
76
+ | Transformers | 5.14.1 |
77
+ | Quantization backend | compressed-tensors |
78
+ | vLLM runner | V1 |
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
+ - Model weight memory: approximately **5.51 GiB**
86
+ - Available KV-cache memory: approximately **0.59 GiB**
87
+ - GPU KV-cache capacity: **4,288 tokens**
88
+ - vLLM target memory at `--gpu-memory-utilization 0.82`: approximately **6.56 GiB**
89
+
90
+ Windows graphics applications consume additional VRAM outside the vLLM process.
91
+ The total value shown by Windows `nvidia-smi` can therefore be higher.
92
+
93
+ ## Quick start: WSL2 + RTX 3070
94
+
95
+ ### 1. Install system build requirements
96
+
97
+ Humming compiles a small runtime extension on first use.
98
+
99
+ ```bash
100
+ sudo apt update
101
+ sudo apt install -y build-essential python3.12-dev
102
+ ```
103
+
104
+ Do not install a Linux NVIDIA display driver inside WSL2. The Windows NVIDIA
105
+ driver exposes `libcuda.so` under `/usr/lib/wsl/lib`.
106
+
107
+ ### 2. Create the Python environment
108
+
109
+ Install [`uv`](https://docs.astral.sh/uv/) first when it is not already available.
110
+
111
+ ```bash
112
+ uv venv --python 3.12 .venv-vllm
113
+ source .venv-vllm/bin/activate
114
+ uv pip install "vllm==0.26.0" hf_xet
115
+ ```
116
+
117
+ ### 3. Validate the environment
118
+
119
+ ```bash
120
+ ./scripts/check_wsl_runtime.sh
121
+ ```
122
+
123
+ ### 4. Start the server directly from Hugging Face
124
+
125
+ ```bash
126
+ source .venv-vllm/bin/activate
127
+ ./scripts/start_vllm_wsl_rtx3070.sh
128
+ ```
129
+
130
+ The default model ID is:
131
+
132
+ ```text
133
+ hsmin92/internvl35-fp8
134
+ ```
135
+
136
+ Successful startup ends with:
137
+
138
+ ```text
139
+ Application startup complete.
140
+ ```
141
+
142
+ The OpenAI-compatible endpoint is then available at:
143
+
144
+ ```text
145
+ http://127.0.0.1:8000/v1
146
+ ```
147
+
148
+ ### Optional: lower KV-cache preset
149
+
150
+ The default script uses the startup configuration that was validated first.
151
+ To reduce the fixed KV-cache allocation, set both values together:
152
+
153
+ ```bash
154
+ GPU_MEMORY_UTILIZATION=0.80 \
155
+ KV_CACHE_MEMORY_BYTES=384M \
156
+ ./scripts/start_vllm_wsl_rtx3070.sh
157
+ ```
158
+
159
+ The fixed KV-cache option does not replace `GPU_MEMORY_UTILIZATION`; both are
160
+ needed by vLLM 0.26.0. Validate this preset on the target machine because the
161
+ Windows desktop and browser processes also consume VRAM.
162
+
163
+ ## Runtime options
164
+
165
+ The startup script accepts environment variables:
166
+
167
+ | Variable | Default | Description |
168
+ |---|---:|---|
169
+ | `MODEL_ID` | `hsmin92/internvl35-fp8` | Hub model ID or local model path |
170
+ | `SERVED_MODEL_NAME` | `internvl35-fp8` | Name exposed by the API |
171
+ | `HOST` | `127.0.0.1` | Listen address |
172
+ | `PORT` | `8000` | Listen port |
173
+ | `MAX_MODEL_LEN` | `2048` | Total context budget, including image and output tokens |
174
+ | `MAX_NUM_SEQS` | `1` | Maximum concurrent sequences |
175
+ | `MAX_IMAGES` | `4` | Maximum images in one request |
176
+ | `GPU_MEMORY_UTILIZATION` | `0.82` | vLLM GPU-memory target |
177
+ | `KV_CACHE_MEMORY_BYTES` | unset | Optional fixed KV-cache size such as `384M` |
178
+
179
+ Example:
180
+
181
+ ```bash
182
+ PORT=8100 MAX_IMAGES=1 MAX_MODEL_LEN=1024 \
183
+ ./scripts/start_vllm_wsl_rtx3070.sh
184
+ ```
185
+
186
+ ## API tests
187
+
188
+ ### Health and model list
189
+
190
+ ```bash
191
+ curl -s http://127.0.0.1:8000/health
192
+ curl -s http://127.0.0.1:8000/v1/models | python3 -m json.tool
193
+ ```
194
+
195
+ ### Text request
196
+
197
+ ```bash
198
+ ./examples/chat_text.sh
199
+ ```
200
+
201
+ ### Local image request
202
+
203
+ ```bash
204
+ python examples/chat_image.py /path/to/image.jpg \
205
+ "Describe the scene and list any safety-relevant events."
206
+ ```
207
+
208
+ The image client sends the local image as a base64 data URL and uses only the
209
+ Python standard library.
210
+
211
+ ## Native Linux and other GPUs
212
+
213
+ The WSL2 script deliberately applies compatibility settings required by the
214
+ validated RTX 3070 environment:
215
+
216
+ - `VLLM_USE_V2_MODEL_RUNNER=0` because the V2 runner required UVA in this WSL setup.
217
+ - `VLLM_USE_FLASHINFER_SAMPLER=0` because FlashInfer sampling JIT required `nvcc`.
218
+ - `/usr/lib/wsl/lib` is added to the compile and runtime linker paths.
219
+ - pip-installed CUDA NVRTC libraries are added to `LD_LIBRARY_PATH`.
220
+ - `--enforce-eager` disables CUDA graphs and `torch.compile` for compatibility.
221
+
222
+ Native Linux systems with a full CUDA Toolkit or newer GPUs may not need these
223
+ workarounds. Start from the documented script, then remove compatibility flags
224
+ one at a time and validate output quality, memory, and stability.
225
+
226
+ ## Intended use
227
+
228
+ This model is suitable for experimentation with:
229
+
230
+ - Image understanding
231
+ - Multi-image comparison
232
+ - CCTV frame summarization
233
+ - Visual question answering
234
+ - OpenAI-compatible multimodal API integration
235
+
236
+ For video analysis on an 8GB GPU, sample a small number of frames externally,
237
+ resize them appropriately, and send the frames as multiple images rather than
238
+ passing every frame of a video.
239
+
240
+ ## Limitations
241
+
242
+ - This is a quantized derivative, not an independently trained model.
243
+ - The vision tower and output head remain BF16 and account for a meaningful
244
+ portion of the loaded weights.
245
+ - FP8 on Ampere is served through a W8A16 compatibility kernel rather than
246
+ native FP8 Tensor Core execution.
247
+ - A comprehensive quality benchmark against the BF16 base model has not yet
248
+ been published in this repository.
249
+ - The first server start may compile and cache Humming runtime components.
250
+ - VRAM figures depend on driver, desktop applications, context length,
251
+ multimodal limits, and vLLM version.
252
+
253
+ ## Attribution and license
254
+
255
+ This repository is a quantized derivative of
256
+ [OpenGVLab/InternVL3_5-4B-HF](https://huggingface.co/OpenGVLab/InternVL3_5-4B-HF).
257
+ The original project and this derivative are distributed under the Apache-2.0
258
+ license. Review the upstream model card for the original training details,
259
+ limitations, and citation information.
260
+
261
+ ## Citation
262
+
263
+ ```bibtex
264
+ @article{wang2025internvl3_5,
265
+ title={InternVL3.5: Advancing Open-Source Multimodal Models in Versatility, Reasoning, and Efficiency},
266
+ author={Wang, Weiyun and Gao, Zhangwei and Gu, Lixin and Pu, Hengjun and Cui, Long and Wei, Xingguang and Liu, Zhaoyang and Jing, Linglin and Ye, Shenglong and Shao, Jie and others},
267
+ journal={arXiv preprint arXiv:2508.18265},
268
+ year={2025}
269
+ }
270
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {% for message in messages %}{{'<|im_start|>' + message['role'] + '
2
+ '}}{% if message['content'] is string %}{{ message['content'] }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<IMG_CONTEXT>
3
+ ' }}{% elif content['type'] == 'video' %}{{ '<video>
4
+ ' }}{% elif content['type'] == 'text' %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}{{'<|im_end|>
5
+ '}}{% endfor %}{% if add_generation_prompt %}{{'<|im_start|>assistant
6
+ ' }}{% endif %}
config.json ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "InternVLForConditionalGeneration"
4
+ ],
5
+ "downsample_ratio": 0.5,
6
+ "dtype": "bfloat16",
7
+ "image_seq_length": 256,
8
+ "image_token_id": 151671,
9
+ "model_type": "internvl",
10
+ "projector_hidden_act": "gelu",
11
+ "quantization_config": {
12
+ "config_groups": {
13
+ "group_0": {
14
+ "format": "float-quantized",
15
+ "input_activations": {
16
+ "actorder": null,
17
+ "block_structure": null,
18
+ "dynamic": true,
19
+ "group_size": null,
20
+ "num_bits": 8,
21
+ "observer": null,
22
+ "observer_kwargs": {},
23
+ "scale_dtype": null,
24
+ "strategy": "token",
25
+ "symmetric": true,
26
+ "type": "float",
27
+ "zp_dtype": null
28
+ },
29
+ "output_activations": null,
30
+ "targets": [
31
+ "Linear"
32
+ ],
33
+ "weights": {
34
+ "actorder": null,
35
+ "block_structure": null,
36
+ "dynamic": false,
37
+ "group_size": null,
38
+ "num_bits": 8,
39
+ "observer": "memoryless_minmax",
40
+ "observer_kwargs": {},
41
+ "scale_dtype": null,
42
+ "strategy": "channel",
43
+ "symmetric": true,
44
+ "type": "float",
45
+ "zp_dtype": null
46
+ }
47
+ }
48
+ },
49
+ "format": "float-quantized",
50
+ "global_compression_ratio": null,
51
+ "ignore": [
52
+ "model.vision_tower.encoder.layer.0.attention.q_proj",
53
+ "model.vision_tower.encoder.layer.0.attention.k_proj",
54
+ "model.vision_tower.encoder.layer.0.attention.v_proj",
55
+ "model.vision_tower.encoder.layer.0.attention.projection_layer",
56
+ "model.vision_tower.encoder.layer.0.mlp.fc1",
57
+ "model.vision_tower.encoder.layer.0.mlp.fc2",
58
+ "model.vision_tower.encoder.layer.1.attention.q_proj",
59
+ "model.vision_tower.encoder.layer.1.attention.k_proj",
60
+ "model.vision_tower.encoder.layer.1.attention.v_proj",
61
+ "model.vision_tower.encoder.layer.1.attention.projection_layer",
62
+ "model.vision_tower.encoder.layer.1.mlp.fc1",
63
+ "model.vision_tower.encoder.layer.1.mlp.fc2",
64
+ "model.vision_tower.encoder.layer.2.attention.q_proj",
65
+ "model.vision_tower.encoder.layer.2.attention.k_proj",
66
+ "model.vision_tower.encoder.layer.2.attention.v_proj",
67
+ "model.vision_tower.encoder.layer.2.attention.projection_layer",
68
+ "model.vision_tower.encoder.layer.2.mlp.fc1",
69
+ "model.vision_tower.encoder.layer.2.mlp.fc2",
70
+ "model.vision_tower.encoder.layer.3.attention.q_proj",
71
+ "model.vision_tower.encoder.layer.3.attention.k_proj",
72
+ "model.vision_tower.encoder.layer.3.attention.v_proj",
73
+ "model.vision_tower.encoder.layer.3.attention.projection_layer",
74
+ "model.vision_tower.encoder.layer.3.mlp.fc1",
75
+ "model.vision_tower.encoder.layer.3.mlp.fc2",
76
+ "model.vision_tower.encoder.layer.4.attention.q_proj",
77
+ "model.vision_tower.encoder.layer.4.attention.k_proj",
78
+ "model.vision_tower.encoder.layer.4.attention.v_proj",
79
+ "model.vision_tower.encoder.layer.4.attention.projection_layer",
80
+ "model.vision_tower.encoder.layer.4.mlp.fc1",
81
+ "model.vision_tower.encoder.layer.4.mlp.fc2",
82
+ "model.vision_tower.encoder.layer.5.attention.q_proj",
83
+ "model.vision_tower.encoder.layer.5.attention.k_proj",
84
+ "model.vision_tower.encoder.layer.5.attention.v_proj",
85
+ "model.vision_tower.encoder.layer.5.attention.projection_layer",
86
+ "model.vision_tower.encoder.layer.5.mlp.fc1",
87
+ "model.vision_tower.encoder.layer.5.mlp.fc2",
88
+ "model.vision_tower.encoder.layer.6.attention.q_proj",
89
+ "model.vision_tower.encoder.layer.6.attention.k_proj",
90
+ "model.vision_tower.encoder.layer.6.attention.v_proj",
91
+ "model.vision_tower.encoder.layer.6.attention.projection_layer",
92
+ "model.vision_tower.encoder.layer.6.mlp.fc1",
93
+ "model.vision_tower.encoder.layer.6.mlp.fc2",
94
+ "model.vision_tower.encoder.layer.7.attention.q_proj",
95
+ "model.vision_tower.encoder.layer.7.attention.k_proj",
96
+ "model.vision_tower.encoder.layer.7.attention.v_proj",
97
+ "model.vision_tower.encoder.layer.7.attention.projection_layer",
98
+ "model.vision_tower.encoder.layer.7.mlp.fc1",
99
+ "model.vision_tower.encoder.layer.7.mlp.fc2",
100
+ "model.vision_tower.encoder.layer.8.attention.q_proj",
101
+ "model.vision_tower.encoder.layer.8.attention.k_proj",
102
+ "model.vision_tower.encoder.layer.8.attention.v_proj",
103
+ "model.vision_tower.encoder.layer.8.attention.projection_layer",
104
+ "model.vision_tower.encoder.layer.8.mlp.fc1",
105
+ "model.vision_tower.encoder.layer.8.mlp.fc2",
106
+ "model.vision_tower.encoder.layer.9.attention.q_proj",
107
+ "model.vision_tower.encoder.layer.9.attention.k_proj",
108
+ "model.vision_tower.encoder.layer.9.attention.v_proj",
109
+ "model.vision_tower.encoder.layer.9.attention.projection_layer",
110
+ "model.vision_tower.encoder.layer.9.mlp.fc1",
111
+ "model.vision_tower.encoder.layer.9.mlp.fc2",
112
+ "model.vision_tower.encoder.layer.10.attention.q_proj",
113
+ "model.vision_tower.encoder.layer.10.attention.k_proj",
114
+ "model.vision_tower.encoder.layer.10.attention.v_proj",
115
+ "model.vision_tower.encoder.layer.10.attention.projection_layer",
116
+ "model.vision_tower.encoder.layer.10.mlp.fc1",
117
+ "model.vision_tower.encoder.layer.10.mlp.fc2",
118
+ "model.vision_tower.encoder.layer.11.attention.q_proj",
119
+ "model.vision_tower.encoder.layer.11.attention.k_proj",
120
+ "model.vision_tower.encoder.layer.11.attention.v_proj",
121
+ "model.vision_tower.encoder.layer.11.attention.projection_layer",
122
+ "model.vision_tower.encoder.layer.11.mlp.fc1",
123
+ "model.vision_tower.encoder.layer.11.mlp.fc2",
124
+ "model.vision_tower.encoder.layer.12.attention.q_proj",
125
+ "model.vision_tower.encoder.layer.12.attention.k_proj",
126
+ "model.vision_tower.encoder.layer.12.attention.v_proj",
127
+ "model.vision_tower.encoder.layer.12.attention.projection_layer",
128
+ "model.vision_tower.encoder.layer.12.mlp.fc1",
129
+ "model.vision_tower.encoder.layer.12.mlp.fc2",
130
+ "model.vision_tower.encoder.layer.13.attention.q_proj",
131
+ "model.vision_tower.encoder.layer.13.attention.k_proj",
132
+ "model.vision_tower.encoder.layer.13.attention.v_proj",
133
+ "model.vision_tower.encoder.layer.13.attention.projection_layer",
134
+ "model.vision_tower.encoder.layer.13.mlp.fc1",
135
+ "model.vision_tower.encoder.layer.13.mlp.fc2",
136
+ "model.vision_tower.encoder.layer.14.attention.q_proj",
137
+ "model.vision_tower.encoder.layer.14.attention.k_proj",
138
+ "model.vision_tower.encoder.layer.14.attention.v_proj",
139
+ "model.vision_tower.encoder.layer.14.attention.projection_layer",
140
+ "model.vision_tower.encoder.layer.14.mlp.fc1",
141
+ "model.vision_tower.encoder.layer.14.mlp.fc2",
142
+ "model.vision_tower.encoder.layer.15.attention.q_proj",
143
+ "model.vision_tower.encoder.layer.15.attention.k_proj",
144
+ "model.vision_tower.encoder.layer.15.attention.v_proj",
145
+ "model.vision_tower.encoder.layer.15.attention.projection_layer",
146
+ "model.vision_tower.encoder.layer.15.mlp.fc1",
147
+ "model.vision_tower.encoder.layer.15.mlp.fc2",
148
+ "model.vision_tower.encoder.layer.16.attention.q_proj",
149
+ "model.vision_tower.encoder.layer.16.attention.k_proj",
150
+ "model.vision_tower.encoder.layer.16.attention.v_proj",
151
+ "model.vision_tower.encoder.layer.16.attention.projection_layer",
152
+ "model.vision_tower.encoder.layer.16.mlp.fc1",
153
+ "model.vision_tower.encoder.layer.16.mlp.fc2",
154
+ "model.vision_tower.encoder.layer.17.attention.q_proj",
155
+ "model.vision_tower.encoder.layer.17.attention.k_proj",
156
+ "model.vision_tower.encoder.layer.17.attention.v_proj",
157
+ "model.vision_tower.encoder.layer.17.attention.projection_layer",
158
+ "model.vision_tower.encoder.layer.17.mlp.fc1",
159
+ "model.vision_tower.encoder.layer.17.mlp.fc2",
160
+ "model.vision_tower.encoder.layer.18.attention.q_proj",
161
+ "model.vision_tower.encoder.layer.18.attention.k_proj",
162
+ "model.vision_tower.encoder.layer.18.attention.v_proj",
163
+ "model.vision_tower.encoder.layer.18.attention.projection_layer",
164
+ "model.vision_tower.encoder.layer.18.mlp.fc1",
165
+ "model.vision_tower.encoder.layer.18.mlp.fc2",
166
+ "model.vision_tower.encoder.layer.19.attention.q_proj",
167
+ "model.vision_tower.encoder.layer.19.attention.k_proj",
168
+ "model.vision_tower.encoder.layer.19.attention.v_proj",
169
+ "model.vision_tower.encoder.layer.19.attention.projection_layer",
170
+ "model.vision_tower.encoder.layer.19.mlp.fc1",
171
+ "model.vision_tower.encoder.layer.19.mlp.fc2",
172
+ "model.vision_tower.encoder.layer.20.attention.q_proj",
173
+ "model.vision_tower.encoder.layer.20.attention.k_proj",
174
+ "model.vision_tower.encoder.layer.20.attention.v_proj",
175
+ "model.vision_tower.encoder.layer.20.attention.projection_layer",
176
+ "model.vision_tower.encoder.layer.20.mlp.fc1",
177
+ "model.vision_tower.encoder.layer.20.mlp.fc2",
178
+ "model.vision_tower.encoder.layer.21.attention.q_proj",
179
+ "model.vision_tower.encoder.layer.21.attention.k_proj",
180
+ "model.vision_tower.encoder.layer.21.attention.v_proj",
181
+ "model.vision_tower.encoder.layer.21.attention.projection_layer",
182
+ "model.vision_tower.encoder.layer.21.mlp.fc1",
183
+ "model.vision_tower.encoder.layer.21.mlp.fc2",
184
+ "model.vision_tower.encoder.layer.22.attention.q_proj",
185
+ "model.vision_tower.encoder.layer.22.attention.k_proj",
186
+ "model.vision_tower.encoder.layer.22.attention.v_proj",
187
+ "model.vision_tower.encoder.layer.22.attention.projection_layer",
188
+ "model.vision_tower.encoder.layer.22.mlp.fc1",
189
+ "model.vision_tower.encoder.layer.22.mlp.fc2",
190
+ "model.vision_tower.encoder.layer.23.attention.q_proj",
191
+ "model.vision_tower.encoder.layer.23.attention.k_proj",
192
+ "model.vision_tower.encoder.layer.23.attention.v_proj",
193
+ "model.vision_tower.encoder.layer.23.attention.projection_layer",
194
+ "model.vision_tower.encoder.layer.23.mlp.fc1",
195
+ "model.vision_tower.encoder.layer.23.mlp.fc2",
196
+ "model.multi_modal_projector.linear_1",
197
+ "model.multi_modal_projector.linear_2",
198
+ "lm_head"
199
+ ],
200
+ "kv_cache_scheme": null,
201
+ "quant_method": "compressed-tensors",
202
+ "quantization_status": "compressed",
203
+ "sparsity_config": {},
204
+ "transform_config": {},
205
+ "version": "0.17.1"
206
+ },
207
+ "text_config": {
208
+ "_name_or_path": "/root/codespace/checkpoints/Qwen3-4B",
209
+ "architectures": [
210
+ "Qwen3ForCausalLM"
211
+ ],
212
+ "attention_bias": false,
213
+ "attention_dropout": 0.0,
214
+ "bos_token_id": 151643,
215
+ "debug": false,
216
+ "dtype": "bfloat16",
217
+ "eos_token_id": 151645,
218
+ "ep_size": 1,
219
+ "head_dim": 128,
220
+ "hidden_act": "silu",
221
+ "hidden_size": 2560,
222
+ "initializer_range": 0.02,
223
+ "intermediate_size": 9728,
224
+ "layer_types": [
225
+ "full_attention",
226
+ "full_attention",
227
+ "full_attention",
228
+ "full_attention",
229
+ "full_attention",
230
+ "full_attention",
231
+ "full_attention",
232
+ "full_attention",
233
+ "full_attention",
234
+ "full_attention",
235
+ "full_attention",
236
+ "full_attention",
237
+ "full_attention",
238
+ "full_attention",
239
+ "full_attention",
240
+ "full_attention",
241
+ "full_attention",
242
+ "full_attention",
243
+ "full_attention",
244
+ "full_attention",
245
+ "full_attention",
246
+ "full_attention",
247
+ "full_attention",
248
+ "full_attention",
249
+ "full_attention",
250
+ "full_attention",
251
+ "full_attention",
252
+ "full_attention",
253
+ "full_attention",
254
+ "full_attention",
255
+ "full_attention",
256
+ "full_attention",
257
+ "full_attention",
258
+ "full_attention",
259
+ "full_attention",
260
+ "full_attention"
261
+ ],
262
+ "max_position_embeddings": 40960,
263
+ "max_window_layers": 36,
264
+ "micro_forward": false,
265
+ "model_type": "qwen3",
266
+ "num_attention_heads": 32,
267
+ "num_hidden_layers": 36,
268
+ "num_key_value_heads": 8,
269
+ "pad_token_id": null,
270
+ "rms_norm_eps": 1e-06,
271
+ "rope_parameters": {
272
+ "rope_theta": 1000000,
273
+ "rope_type": "default"
274
+ },
275
+ "skip_checkpoint": false,
276
+ "sliding_window": null,
277
+ "tie_word_embeddings": false,
278
+ "use_cache": true,
279
+ "use_deepep": false,
280
+ "use_sliding_window": false,
281
+ "vocab_size": 151936
282
+ },
283
+ "tie_word_embeddings": false,
284
+ "transformers_version": "5.10.1",
285
+ "vision_config": {
286
+ "architectures": [
287
+ "InternVisionModel"
288
+ ],
289
+ "attention_bias": true,
290
+ "attention_dropout": 0.0,
291
+ "dropout": 0.0,
292
+ "dtype": "bfloat16",
293
+ "hidden_act": "gelu",
294
+ "hidden_dropout_prob": 0.0,
295
+ "hidden_size": 1024,
296
+ "image_size": [
297
+ 448,
298
+ 448
299
+ ],
300
+ "initializer_factor": 0.1,
301
+ "initializer_range": 1e-10,
302
+ "intermediate_size": 4096,
303
+ "layer_norm_eps": 1e-06,
304
+ "layer_scale_init_value": 0.1,
305
+ "model_type": "internvl_vision",
306
+ "norm_type": "layer_norm",
307
+ "num_attention_heads": 16,
308
+ "num_channels": 3,
309
+ "num_hidden_layers": 24,
310
+ "patch_size": [
311
+ 14,
312
+ 14
313
+ ],
314
+ "projection_dropout": 0.0,
315
+ "use_absolute_position_embeddings": true,
316
+ "use_mask_token": false,
317
+ "use_mean_pooling": true,
318
+ "use_qk_norm": false
319
+ },
320
+ "vision_feature_layer": -1,
321
+ "vision_feature_select_strategy": "default"
322
+ }
examples/chat_image.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import base64
7
+ import json
8
+ import mimetypes
9
+ import sys
10
+ import urllib.error
11
+ import urllib.request
12
+ from pathlib import Path
13
+
14
+
15
+ def build_data_url(image_path: Path) -> str:
16
+ mime_type, _ = mimetypes.guess_type(image_path.name)
17
+ if mime_type is None or not mime_type.startswith("image/"):
18
+ mime_type = "image/jpeg"
19
+ encoded = base64.b64encode(image_path.read_bytes()).decode("ascii")
20
+ return f"data:{mime_type};base64,{encoded}"
21
+
22
+
23
+ def main() -> int:
24
+ parser = argparse.ArgumentParser(description="Send a local image to the vLLM OpenAI API.")
25
+ parser.add_argument("image", type=Path, help="Path to a local image")
26
+ parser.add_argument("prompt", nargs="?", default="Describe this image in detail.")
27
+ parser.add_argument("--api-base", default="http://127.0.0.1:8000/v1")
28
+ parser.add_argument("--model", default="internvl35-fp8")
29
+ parser.add_argument("--max-tokens", type=int, default=256)
30
+ args = parser.parse_args()
31
+
32
+ if not args.image.is_file():
33
+ print(f"Image not found: {args.image}", file=sys.stderr)
34
+ return 2
35
+
36
+ payload = {
37
+ "model": args.model,
38
+ "messages": [
39
+ {
40
+ "role": "user",
41
+ "content": [
42
+ {"type": "image_url", "image_url": {"url": build_data_url(args.image)}},
43
+ {"type": "text", "text": args.prompt},
44
+ ],
45
+ }
46
+ ],
47
+ "temperature": 0.0,
48
+ "max_tokens": args.max_tokens,
49
+ }
50
+
51
+ request = urllib.request.Request(
52
+ f"{args.api_base.rstrip('/')}/chat/completions",
53
+ data=json.dumps(payload).encode("utf-8"),
54
+ headers={"Content-Type": "application/json"},
55
+ method="POST",
56
+ )
57
+
58
+ try:
59
+ with urllib.request.urlopen(request, timeout=300) as response:
60
+ result = json.load(response)
61
+ except urllib.error.HTTPError as exc:
62
+ print(exc.read().decode("utf-8", errors="replace"), file=sys.stderr)
63
+ return 1
64
+ except urllib.error.URLError as exc:
65
+ print(f"Request failed: {exc}", file=sys.stderr)
66
+ return 1
67
+
68
+ print(result["choices"][0]["message"]["content"])
69
+ return 0
70
+
71
+
72
+ if __name__ == "__main__":
73
+ raise SystemExit(main())
examples/chat_text.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ API_BASE="${API_BASE:-http://127.0.0.1:8000/v1}"
6
+ MODEL="${MODEL:-internvl35-fp8}"
7
+
8
+ curl -sS "$API_BASE/chat/completions" \
9
+ -H 'Content-Type: application/json' \
10
+ -d @- <<JSON | python3 -m json.tool
11
+ {
12
+ "model": "$MODEL",
13
+ "messages": [
14
+ {
15
+ "role": "user",
16
+ "content": [
17
+ {
18
+ "type": "text",
19
+ "text": "Which number is larger, 9.11 or 9.8? Explain briefly."
20
+ }
21
+ ]
22
+ }
23
+ ],
24
+ "temperature": 0.0,
25
+ "max_tokens": 96
26
+ }
27
+ JSON
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151645,
5
+ "transformers_version": "5.10.1"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c94c1d649e21e763fb440ca4fbcd685169499f01b6e808c5c3618ac54ef92ee
3
+ size 5834016032
processor_config.json ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "crop_to_patches": false,
4
+ "data_format": "channels_first",
5
+ "default_to_square": true,
6
+ "do_convert_rgb": true,
7
+ "do_normalize": true,
8
+ "do_rescale": true,
9
+ "do_resize": true,
10
+ "image_mean": [
11
+ 0.485,
12
+ 0.456,
13
+ 0.406
14
+ ],
15
+ "image_processor_type": "GotOcr2ImageProcessor",
16
+ "image_std": [
17
+ 0.229,
18
+ 0.224,
19
+ 0.225
20
+ ],
21
+ "max_patches": 12,
22
+ "min_patches": 1,
23
+ "resample": 3,
24
+ "rescale_factor": 0.00392156862745098,
25
+ "size": {
26
+ "height": 448,
27
+ "width": 448
28
+ }
29
+ },
30
+ "image_seq_length": 256,
31
+ "processor_class": "InternVLProcessor",
32
+ "video_processor": {
33
+ "data_format": "channels_first",
34
+ "default_to_square": true,
35
+ "do_convert_rgb": true,
36
+ "do_normalize": true,
37
+ "do_rescale": true,
38
+ "do_resize": true,
39
+ "do_sample_frames": false,
40
+ "image_mean": [
41
+ 0.48145466,
42
+ 0.4578275,
43
+ 0.40821073
44
+ ],
45
+ "image_std": [
46
+ 0.26862954,
47
+ 0.26130258,
48
+ 0.27577711
49
+ ],
50
+ "initial_shift": true,
51
+ "model_valid_processing_keys": [
52
+ "do_convert_rgb",
53
+ "do_resize",
54
+ "size",
55
+ "size_divisor",
56
+ "default_to_square",
57
+ "resample",
58
+ "do_rescale",
59
+ "rescale_factor",
60
+ "do_normalize",
61
+ "image_mean",
62
+ "image_std",
63
+ "do_pad",
64
+ "do_center_crop",
65
+ "crop_size",
66
+ "data_format",
67
+ "input_data_format",
68
+ "device"
69
+ ],
70
+ "resample": 3,
71
+ "rescale_factor": 0.00392156862745098,
72
+ "return_metadata": false,
73
+ "size": {
74
+ "height": 384,
75
+ "width": 384
76
+ },
77
+ "video_processor_type": "InternVLVideoProcessor"
78
+ }
79
+ }
quantization/recipe.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compression recipe used to create this checkpoint.
2
+
3
+ Run quantization from the original BF16 checkpoint, not from an already
4
+ quantized checkpoint.
5
+ """
6
+
7
+ from llmcompressor.modifiers.quantization import QuantizationModifier
8
+
9
+
10
+ RECIPE = QuantizationModifier(
11
+ targets="Linear",
12
+ scheme="FP8_DYNAMIC",
13
+ ignore=[
14
+ "re:.*vision_tower.*",
15
+ "re:.*multi_modal_projector.*",
16
+ "re:.*lm_head.*",
17
+ ],
18
+ )
recipe.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ default_stage:
2
+ default_modifiers:
3
+ QuantizationModifier:
4
+ targets: [Linear]
5
+ ignore: ['re:.*vision_tower.*', 're:.*multi_modal_projector.*', 're:.*lm_head.*']
6
+ scheme: FP8_DYNAMIC
7
+ bypass_divisibility_checks: false
scripts/check_wsl_runtime.sh ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ failures=0
6
+
7
+ check_command() {
8
+ local name="$1"
9
+ if command -v "$name" >/dev/null 2>&1; then
10
+ echo "OK command: $name -> $(command -v "$name")"
11
+ else
12
+ echo "FAIL command: $name"
13
+ failures=$((failures + 1))
14
+ fi
15
+ }
16
+
17
+ check_file() {
18
+ local path="$1"
19
+ if [[ -f "$path" ]]; then
20
+ echo "OK file: $path"
21
+ else
22
+ echo "FAIL file: $path"
23
+ failures=$((failures + 1))
24
+ fi
25
+ }
26
+
27
+ echo "===== COMMANDS ====="
28
+ check_command python
29
+ check_command vllm
30
+ check_command gcc
31
+ check_command g++
32
+ check_command ninja
33
+ check_command nvidia-smi
34
+
35
+ echo
36
+ echo "===== SYSTEM FILES ====="
37
+ check_file /usr/include/python3.12/Python.h
38
+ check_file /usr/lib/wsl/lib/libcuda.so
39
+
40
+ echo
41
+ echo "===== PYTHON PACKAGES ====="
42
+ python - <<'PY'
43
+ import importlib.metadata
44
+
45
+ for package in ("vllm", "torch", "transformers", "compressed-tensors", "nvidia-cuda-nvrtc"):
46
+ try:
47
+ print(f"OK {package}: {importlib.metadata.version(package)}")
48
+ except importlib.metadata.PackageNotFoundError:
49
+ print(f"MISS {package}")
50
+ PY
51
+
52
+ echo
53
+ echo "===== NVRTC FILES ====="
54
+ python - <<'PY'
55
+ import site
56
+ from pathlib import Path
57
+
58
+ found = []
59
+ for site_dir in site.getsitepackages():
60
+ for path in (Path(site_dir) / "nvidia").glob("cu*/lib/libnvrtc*.so*"):
61
+ found.append(path)
62
+
63
+ for path in sorted(found):
64
+ print(path)
65
+
66
+ if not found:
67
+ raise SystemExit("No NVRTC libraries found")
68
+ PY
69
+
70
+ echo
71
+ echo "===== CUDA DRIVER LINK ====="
72
+ cat >/tmp/internvl_cuda_link_test.cpp <<'CPP'
73
+ extern "C" int cuInit(unsigned int flags);
74
+ int main() { return 0; }
75
+ CPP
76
+
77
+ LIBRARY_PATH="/usr/lib/wsl/lib:${LIBRARY_PATH:-}" \
78
+ g++ /tmp/internvl_cuda_link_test.cpp -Wl,--no-as-needed -lcuda \
79
+ -o /tmp/internvl_cuda_link_test
80
+
81
+ echo "OK CUDA driver link"
82
+
83
+ if [[ "$failures" -ne 0 ]]; then
84
+ echo "Runtime check failed: $failures required item(s) missing." >&2
85
+ exit 1
86
+ fi
87
+
88
+ echo
89
+ echo "WSL RUNTIME CHECK: SUCCESS"
scripts/start_vllm_wsl_rtx3070.sh ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ MODEL_ID="${MODEL_ID:-hsmin92/internvl35-fp8}"
6
+ SERVED_MODEL_NAME="${SERVED_MODEL_NAME:-internvl35-fp8}"
7
+ HOST="${HOST:-127.0.0.1}"
8
+ PORT="${PORT:-8000}"
9
+ MAX_MODEL_LEN="${MAX_MODEL_LEN:-2048}"
10
+ MAX_NUM_SEQS="${MAX_NUM_SEQS:-1}"
11
+ MAX_IMAGES="${MAX_IMAGES:-4}"
12
+ GPU_MEMORY_UTILIZATION="${GPU_MEMORY_UTILIZATION:-0.82}"
13
+ KV_CACHE_MEMORY_BYTES="${KV_CACHE_MEMORY_BYTES:-}"
14
+
15
+ if [[ -z "${VIRTUAL_ENV:-}" ]]; then
16
+ echo "ERROR: Activate the vLLM virtual environment first." >&2
17
+ exit 1
18
+ fi
19
+
20
+ if ! command -v vllm >/dev/null 2>&1; then
21
+ echo "ERROR: vllm is not installed in the active environment." >&2
22
+ exit 1
23
+ fi
24
+
25
+ if [[ ! -f /usr/lib/wsl/lib/libcuda.so ]]; then
26
+ echo "ERROR: /usr/lib/wsl/lib/libcuda.so was not found." >&2
27
+ echo "This script is intended for NVIDIA GPU passthrough in WSL2." >&2
28
+ exit 1
29
+ fi
30
+
31
+ NVRTC_LIB_DIR="$({ python - <<'PY'
32
+ import site
33
+ from pathlib import Path
34
+
35
+ candidates = []
36
+ for site_dir in site.getsitepackages():
37
+ nvidia_dir = Path(site_dir) / "nvidia"
38
+ if not nvidia_dir.exists():
39
+ continue
40
+ for lib_dir in nvidia_dir.glob("cu*/lib"):
41
+ if any(lib_dir.glob("libnvrtc-builtins.so*")) and any(lib_dir.glob("libnvrtc.so*")):
42
+ candidates.append(lib_dir)
43
+
44
+ if not candidates:
45
+ raise SystemExit(1)
46
+
47
+ print(sorted(candidates)[-1])
48
+ PY
49
+ } 2>/dev/null)" || {
50
+ echo "ERROR: pip-installed NVRTC libraries were not found." >&2
51
+ exit 1
52
+ }
53
+
54
+ CUDA_DRIVER_LIB_DIR="/usr/lib/wsl/lib"
55
+
56
+ # WSL2 compatibility settings validated on RTX 3070.
57
+ export VLLM_USE_V2_MODEL_RUNNER=0
58
+ export VLLM_USE_FLASHINFER_SAMPLER=0
59
+ export TOKENIZERS_PARALLELISM=false
60
+
61
+ # Compile-time linker path for -lcuda.
62
+ export LIBRARY_PATH="$CUDA_DRIVER_LIB_DIR:${LIBRARY_PATH:-}"
63
+
64
+ # Runtime paths for the WSL CUDA driver and pip-installed NVRTC.
65
+ export LD_LIBRARY_PATH="$CUDA_DRIVER_LIB_DIR:$NVRTC_LIB_DIR:${LD_LIBRARY_PATH:-}"
66
+
67
+ ARGS=(
68
+ "$MODEL_ID"
69
+ --served-model-name "$SERVED_MODEL_NAME"
70
+ --host "$HOST"
71
+ --port "$PORT"
72
+ --trust-remote-code
73
+ --dtype half
74
+ --max-model-len "$MAX_MODEL_LEN"
75
+ --max-num-seqs "$MAX_NUM_SEQS"
76
+ --gpu-memory-utilization "$GPU_MEMORY_UTILIZATION"
77
+ --enforce-eager
78
+ --limit-mm-per-prompt "{\"image\":$MAX_IMAGES,\"video\":0}"
79
+ )
80
+
81
+ if [[ -n "$KV_CACHE_MEMORY_BYTES" ]]; then
82
+ ARGS+=(--kv-cache-memory-bytes "$KV_CACHE_MEMORY_BYTES")
83
+ fi
84
+
85
+ echo "Model: $MODEL_ID"
86
+ echo "NVRTC: $NVRTC_LIB_DIR"
87
+ echo "GPU memory utilization: $GPU_MEMORY_UTILIZATION"
88
+ echo "KV cache bytes: ${KV_CACHE_MEMORY_BYTES:-automatic}"
89
+
90
+ exec vllm serve "${ARGS[@]}"
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b9d18660f656ae5a87df2d5d6ed990e80f292d3473c1a35cae8259a5d28cd67
3
+ size 11424484
tokenizer_config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "context_image_token": "<IMG_CONTEXT>",
7
+ "end_image_token": "</img>",
8
+ "eos_token": "<|im_end|>",
9
+ "errors": "replace",
10
+ "is_local": true,
11
+ "local_files_only": true,
12
+ "model_max_length": 40960,
13
+ "model_specific_special_tokens": {
14
+ "context_image_token": "<IMG_CONTEXT>",
15
+ "end_image_token": "</img>",
16
+ "start_image_token": "<img>",
17
+ "video_token": "<video>"
18
+ },
19
+ "pad_token": "<|endoftext|>",
20
+ "processor_class": "InternVLProcessor",
21
+ "split_special_tokens": false,
22
+ "start_image_token": "<img>",
23
+ "tokenizer_class": "Qwen2Tokenizer",
24
+ "unk_token": null,
25
+ "video_token": "<video>"
26
+ }