Image-Text-to-Text
Transformers
Safetensors
qwen3_5_moe
fp4
qwen
nvfp4
vllm
llm-compressor
compressed-tensors
conversational
8-bit precision
Instructions to use RedHatAI/Qwen3.6-35B-A3B-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/Qwen3.6-35B-A3B-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="RedHatAI/Qwen3.6-35B-A3B-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("RedHatAI/Qwen3.6-35B-A3B-NVFP4") model = AutoModelForMultimodalLM.from_pretrained("RedHatAI/Qwen3.6-35B-A3B-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 RedHatAI/Qwen3.6-35B-A3B-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/Qwen3.6-35B-A3B-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": "RedHatAI/Qwen3.6-35B-A3B-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/RedHatAI/Qwen3.6-35B-A3B-NVFP4
- SGLang
How to use RedHatAI/Qwen3.6-35B-A3B-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 "RedHatAI/Qwen3.6-35B-A3B-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": "RedHatAI/Qwen3.6-35B-A3B-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 "RedHatAI/Qwen3.6-35B-A3B-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": "RedHatAI/Qwen3.6-35B-A3B-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 RedHatAI/Qwen3.6-35B-A3B-NVFP4 with Docker Model Runner:
docker model run hf.co/RedHatAI/Qwen3.6-35B-A3B-NVFP4
Update README.md
Browse files
README.md
CHANGED
|
@@ -16,6 +16,108 @@ The model has both weights and activations quantized to NVFP4 format with [vllm-
|
|
| 16 |
|
| 17 |
It is compatible and tested against vllm main. Deploy it with: `vllm serve RedHatAI/Qwen3.6-35B-A3B-NVFP4 --reasoning-parser qwen3 --moe_backend flashinfer_cutlass`
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Preliminary Evaluations
|
| 20 |
|
| 21 |
1) GSM8K Platinum:
|
|
@@ -38,4 +140,6 @@ Recovery:
|
|
| 38 |
| Recovery | \- | 100.69% |
|
| 39 |
|
| 40 |
|
| 41 |
-
**Note**: More rigorous evaluations are currently in progress and will be available soon.
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
It is compatible and tested against vllm main. Deploy it with: `vllm serve RedHatAI/Qwen3.6-35B-A3B-NVFP4 --reasoning-parser qwen3 --moe_backend flashinfer_cutlass`
|
| 18 |
|
| 19 |
+
# Creation Script:
|
| 20 |
+
|
| 21 |
+
Run this script with LLM Compressor main and latest transformers.
|
| 22 |
+
|
| 23 |
+
<details>
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
import torch
|
| 27 |
+
from compressed_tensors.utils import save_mtp_tensors_to_checkpoint
|
| 28 |
+
from datasets import load_dataset
|
| 29 |
+
from transformers import AutoProcessor, Qwen3_5MoeForConditionalGeneration
|
| 30 |
+
|
| 31 |
+
from llmcompressor import oneshot
|
| 32 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 33 |
+
|
| 34 |
+
# NOTE: This example requires transformers >= v5
|
| 35 |
+
|
| 36 |
+
MODEL_ID = "Qwen/Qwen3.6-35B-A3B"
|
| 37 |
+
|
| 38 |
+
# Load model.
|
| 39 |
+
model = Qwen3_5MoeForConditionalGeneration.from_pretrained(MODEL_ID, dtype="auto")
|
| 40 |
+
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
| 41 |
+
|
| 42 |
+
# No need to include mtp layers as they are not loaded
|
| 43 |
+
# through Qwen3_5MoeForConditionalGeneration
|
| 44 |
+
recipe = QuantizationModifier(
|
| 45 |
+
targets="Linear",
|
| 46 |
+
scheme="NVFP4",
|
| 47 |
+
ignore=[
|
| 48 |
+
"re:.*lm_head",
|
| 49 |
+
"re:visual.*",
|
| 50 |
+
"re:model.visual.*",
|
| 51 |
+
"re:.*mlp.gate$",
|
| 52 |
+
"re:.*embed_tokens$",
|
| 53 |
+
"re:.*shared_expert_gate$",
|
| 54 |
+
"re:.*linear_attn.*",
|
| 55 |
+
],
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
NUM_CALIBRATION_SAMPLES = 256
|
| 59 |
+
MAX_SEQUENCE_LENGTH = 4096
|
| 60 |
+
|
| 61 |
+
ds = load_dataset(
|
| 62 |
+
"HuggingFaceH4/ultrachat_200k",
|
| 63 |
+
split=f"train_sft[:{NUM_CALIBRATION_SAMPLES}]",
|
| 64 |
+
)
|
| 65 |
+
ds = ds.select_columns(["messages"])
|
| 66 |
+
ds = ds.shuffle(seed=42)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def preprocess_function(example):
|
| 70 |
+
messages = [
|
| 71 |
+
{"role": m["role"], "content": [{"type": "text", "text": m["content"]}]}
|
| 72 |
+
for m in example["messages"]
|
| 73 |
+
]
|
| 74 |
+
return processor.apply_chat_template(
|
| 75 |
+
messages,
|
| 76 |
+
tokenize=True,
|
| 77 |
+
return_dict=True,
|
| 78 |
+
add_generation_prompt=False,
|
| 79 |
+
processor_kwargs={
|
| 80 |
+
"return_tensors": "pt",
|
| 81 |
+
"padding": False,
|
| 82 |
+
"truncation": True,
|
| 83 |
+
"max_length": MAX_SEQUENCE_LENGTH,
|
| 84 |
+
"add_special_tokens": False,
|
| 85 |
+
},
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
ds = ds.map(preprocess_function, batched=False, remove_columns=ds.column_names)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def data_collator(batch):
|
| 93 |
+
assert len(batch) == 1
|
| 94 |
+
return {key: torch.tensor(value) for key, value in batch[0].items()}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
# Apply quantization.
|
| 98 |
+
oneshot(
|
| 99 |
+
model=model,
|
| 100 |
+
recipe=recipe,
|
| 101 |
+
dataset=ds,
|
| 102 |
+
max_seq_length=MAX_SEQUENCE_LENGTH,
|
| 103 |
+
num_calibration_samples=NUM_CALIBRATION_SAMPLES,
|
| 104 |
+
moe_calibrate_all_experts=True,
|
| 105 |
+
data_collator=data_collator,
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
# Save to disk in compressed-tensors format.
|
| 109 |
+
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-NVFP4"
|
| 110 |
+
model.save_pretrained(SAVE_DIR)
|
| 111 |
+
processor.save_pretrained(SAVE_DIR)
|
| 112 |
+
|
| 113 |
+
# MTP layers are excluded from the model through Qwen3_5MoeForConditionalGeneration
|
| 114 |
+
# Save them as-is from the original checkpoint into the quantized output.
|
| 115 |
+
save_mtp_tensors_to_checkpoint(source_model=MODEL_ID, dest_dir=SAVE_DIR)
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
</details>
|
| 119 |
+
|
| 120 |
+
|
| 121 |
# Preliminary Evaluations
|
| 122 |
|
| 123 |
1) GSM8K Platinum:
|
|
|
|
| 140 |
| Recovery | \- | 100.69% |
|
| 141 |
|
| 142 |
|
| 143 |
+
**Note**: More rigorous evaluations are currently in progress and will be available soon.
|
| 144 |
+
|
| 145 |
+
|