Image-Text-to-Text
Transformers
Safetensors
gemma4
quantization
nvfp4
conversational
8-bit precision
compressed-tensors
Instructions to use yasu-oh/gemma-4-31B-it-qat-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasu-oh/gemma-4-31B-it-qat-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="yasu-oh/gemma-4-31B-it-qat-NVFP4") 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("yasu-oh/gemma-4-31B-it-qat-NVFP4") model = AutoModelForMultimodalLM.from_pretrained("yasu-oh/gemma-4-31B-it-qat-NVFP4", 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 yasu-oh/gemma-4-31B-it-qat-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yasu-oh/gemma-4-31B-it-qat-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yasu-oh/gemma-4-31B-it-qat-NVFP4", "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/yasu-oh/gemma-4-31B-it-qat-NVFP4
- SGLang
How to use yasu-oh/gemma-4-31B-it-qat-NVFP4 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 "yasu-oh/gemma-4-31B-it-qat-NVFP4" \ --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": "yasu-oh/gemma-4-31B-it-qat-NVFP4", "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 "yasu-oh/gemma-4-31B-it-qat-NVFP4" \ --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": "yasu-oh/gemma-4-31B-it-qat-NVFP4", "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 yasu-oh/gemma-4-31B-it-qat-NVFP4 with Docker Model Runner:
docker model run hf.co/yasu-oh/gemma-4-31B-it-qat-NVFP4
yasu-oh commited on
Commit ·
28413b5
1
Parent(s): f4dfe67
v3
Browse files- README.md +38 -5
- config.json +5 -3
- model.safetensors.index.json +0 -0
- recipe.yaml +36 -2
- tokenizer_config.json +46 -0
README.md
CHANGED
|
@@ -46,10 +46,44 @@ The calibration dataset consists of:
|
|
| 46 |
```yaml
|
| 47 |
default_stage:
|
| 48 |
default_modifiers:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
QuantizationModifier:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
targets: [Linear]
|
| 51 |
-
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*']
|
| 52 |
-
scheme: NVFP4
|
| 53 |
kv_cache_scheme:
|
| 54 |
num_bits: 8
|
| 55 |
type: float
|
|
@@ -70,13 +104,12 @@ default_stage:
|
|
| 70 |
|
| 71 |
The quantization code and calibration preprocessing are available at:
|
| 72 |
|
| 73 |
-
[
|
| 74 |
|
| 75 |
The quantization run used:
|
| 76 |
|
| 77 |
```text
|
| 78 |
transformers: 5.12.1
|
| 79 |
-
|
| 80 |
-
llmcompressor: 0.12.1.dev63+g57ed2be4
|
| 81 |
```
|
| 82 |
|
|
|
|
| 46 |
```yaml
|
| 47 |
default_stage:
|
| 48 |
default_modifiers:
|
| 49 |
+
IMatrixGatherer:
|
| 50 |
+
targets: [Linear]
|
| 51 |
+
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*', 're:.*router.*']
|
| 52 |
+
weight_observer: imatrix_mse
|
| 53 |
QuantizationModifier:
|
| 54 |
+
config_groups:
|
| 55 |
+
group_0:
|
| 56 |
+
targets: [Linear]
|
| 57 |
+
weights:
|
| 58 |
+
num_bits: 4
|
| 59 |
+
type: float
|
| 60 |
+
symmetric: true
|
| 61 |
+
group_size: 16
|
| 62 |
+
strategy: tensor_group
|
| 63 |
+
block_structure: null
|
| 64 |
+
dynamic: false
|
| 65 |
+
actorder: null
|
| 66 |
+
scale_dtype: torch.float8_e4m3fn
|
| 67 |
+
zp_dtype: null
|
| 68 |
+
observer: imatrix_mse
|
| 69 |
+
observer_kwargs: {strict: true}
|
| 70 |
+
input_activations:
|
| 71 |
+
num_bits: 4
|
| 72 |
+
type: float
|
| 73 |
+
symmetric: true
|
| 74 |
+
group_size: 16
|
| 75 |
+
strategy: tensor_group
|
| 76 |
+
block_structure: null
|
| 77 |
+
dynamic: local
|
| 78 |
+
actorder: null
|
| 79 |
+
scale_dtype: torch.float8_e4m3fn
|
| 80 |
+
zp_dtype: null
|
| 81 |
+
observer: static_minmax
|
| 82 |
+
observer_kwargs: {}
|
| 83 |
+
output_activations: null
|
| 84 |
+
format: null
|
| 85 |
targets: [Linear]
|
| 86 |
+
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*', 're:.*router.*']
|
|
|
|
| 87 |
kv_cache_scheme:
|
| 88 |
num_bits: 8
|
| 89 |
type: float
|
|
|
|
| 104 |
|
| 105 |
The quantization code and calibration preprocessing are available at:
|
| 106 |
|
| 107 |
+
[gemma4-nvfp4-quantization](https://github.com/yasu-oh/gemma4-nvfp4-quantization)
|
| 108 |
|
| 109 |
The quantization run used:
|
| 110 |
|
| 111 |
```text
|
| 112 |
transformers: 5.12.1
|
| 113 |
+
llmcompressor: 0.12.1.dev87+g9bbfd9564
|
|
|
|
| 114 |
```
|
| 115 |
|
config.json
CHANGED
|
@@ -45,8 +45,10 @@
|
|
| 45 |
"dynamic": false,
|
| 46 |
"group_size": 16,
|
| 47 |
"num_bits": 4,
|
| 48 |
-
"observer": "
|
| 49 |
-
"observer_kwargs": {
|
|
|
|
|
|
|
| 50 |
"scale_dtype": "torch.float8_e4m3fn",
|
| 51 |
"strategy": "tensor_group",
|
| 52 |
"symmetric": true,
|
|
@@ -269,7 +271,7 @@
|
|
| 269 |
"quantization_status": "compressed",
|
| 270 |
"sparsity_config": {},
|
| 271 |
"transform_config": {},
|
| 272 |
-
"version": "0.
|
| 273 |
},
|
| 274 |
"text_config": {
|
| 275 |
"attention_bias": false,
|
|
|
|
| 45 |
"dynamic": false,
|
| 46 |
"group_size": 16,
|
| 47 |
"num_bits": 4,
|
| 48 |
+
"observer": "imatrix_mse",
|
| 49 |
+
"observer_kwargs": {
|
| 50 |
+
"strict": true
|
| 51 |
+
},
|
| 52 |
"scale_dtype": "torch.float8_e4m3fn",
|
| 53 |
"strategy": "tensor_group",
|
| 54 |
"symmetric": true,
|
|
|
|
| 271 |
"quantization_status": "compressed",
|
| 272 |
"sparsity_config": {},
|
| 273 |
"transform_config": {},
|
| 274 |
+
"version": "0.1.dev546+g4ed496d"
|
| 275 |
},
|
| 276 |
"text_config": {
|
| 277 |
"attention_bias": false,
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
recipe.yaml
CHANGED
|
@@ -1,9 +1,43 @@
|
|
| 1 |
default_stage:
|
| 2 |
default_modifiers:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
QuantizationModifier:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
targets: [Linear]
|
| 5 |
-
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*']
|
| 6 |
-
scheme: NVFP4
|
| 7 |
kv_cache_scheme:
|
| 8 |
num_bits: 8
|
| 9 |
type: float
|
|
|
|
| 1 |
default_stage:
|
| 2 |
default_modifiers:
|
| 3 |
+
IMatrixGatherer:
|
| 4 |
+
targets: [Linear]
|
| 5 |
+
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*', 're:.*router.*']
|
| 6 |
+
weight_observer: imatrix_mse
|
| 7 |
QuantizationModifier:
|
| 8 |
+
config_groups:
|
| 9 |
+
group_0:
|
| 10 |
+
targets: [Linear]
|
| 11 |
+
weights:
|
| 12 |
+
num_bits: 4
|
| 13 |
+
type: float
|
| 14 |
+
symmetric: true
|
| 15 |
+
group_size: 16
|
| 16 |
+
strategy: tensor_group
|
| 17 |
+
block_structure: null
|
| 18 |
+
dynamic: false
|
| 19 |
+
actorder: null
|
| 20 |
+
scale_dtype: torch.float8_e4m3fn
|
| 21 |
+
zp_dtype: null
|
| 22 |
+
observer: imatrix_mse
|
| 23 |
+
observer_kwargs: {strict: true}
|
| 24 |
+
input_activations:
|
| 25 |
+
num_bits: 4
|
| 26 |
+
type: float
|
| 27 |
+
symmetric: true
|
| 28 |
+
group_size: 16
|
| 29 |
+
strategy: tensor_group
|
| 30 |
+
block_structure: null
|
| 31 |
+
dynamic: local
|
| 32 |
+
actorder: null
|
| 33 |
+
scale_dtype: torch.float8_e4m3fn
|
| 34 |
+
zp_dtype: null
|
| 35 |
+
observer: static_minmax
|
| 36 |
+
observer_kwargs: {}
|
| 37 |
+
output_activations: null
|
| 38 |
+
format: null
|
| 39 |
targets: [Linear]
|
| 40 |
+
ignore: ['re:.*vision.*', 're:.*audio.*', lm_head, 're:.*embed.*', 're:.*router.*']
|
|
|
|
| 41 |
kv_cache_scheme:
|
| 42 |
num_bits: 8
|
| 43 |
type: float
|
tokenizer_config.json
CHANGED
|
@@ -85,6 +85,52 @@
|
|
| 85 |
"type": "object",
|
| 86 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
"soc_token": "<|channel>",
|
| 89 |
"sot_token": "<|turn>",
|
| 90 |
"stc_token": "<|tool_call>",
|
|
|
|
| 85 |
"type": "object",
|
| 86 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
},
|
| 88 |
+
"response_template": {
|
| 89 |
+
"defaults": {
|
| 90 |
+
"role": "assistant"
|
| 91 |
+
},
|
| 92 |
+
"fields": {
|
| 93 |
+
"content": {
|
| 94 |
+
"close": [
|
| 95 |
+
"<turn|>",
|
| 96 |
+
"<|tool_response>",
|
| 97 |
+
"<eos>"
|
| 98 |
+
],
|
| 99 |
+
"content": "text"
|
| 100 |
+
},
|
| 101 |
+
"thinking": {
|
| 102 |
+
"close": "<channel|>",
|
| 103 |
+
"content": "text",
|
| 104 |
+
"open": "<|channel>thought\n"
|
| 105 |
+
},
|
| 106 |
+
"tool_calls": {
|
| 107 |
+
"close": "<tool_call|>",
|
| 108 |
+
"content": "json",
|
| 109 |
+
"content_args": {
|
| 110 |
+
"string_delims": [
|
| 111 |
+
[
|
| 112 |
+
"<|\"|>",
|
| 113 |
+
"<|\"|>"
|
| 114 |
+
]
|
| 115 |
+
],
|
| 116 |
+
"unquoted_keys": true
|
| 117 |
+
},
|
| 118 |
+
"open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
|
| 119 |
+
"repeats": true,
|
| 120 |
+
"transform": {
|
| 121 |
+
"function": {
|
| 122 |
+
"arguments": "{content}",
|
| 123 |
+
"name": "{name}"
|
| 124 |
+
},
|
| 125 |
+
"type": "function"
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"start_anchor": [
|
| 130 |
+
"<|turn>model\n",
|
| 131 |
+
"<tool_response|>"
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
"soc_token": "<|channel>",
|
| 135 |
"sot_token": "<|turn>",
|
| 136 |
"stc_token": "<|tool_call>",
|