Instructions to use unsloth/Qwen3.5-397B-A17B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Qwen3.5-397B-A17B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/Qwen3.5-397B-A17B") 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("unsloth/Qwen3.5-397B-A17B") model = AutoModelForMultimodalLM.from_pretrained("unsloth/Qwen3.5-397B-A17B", 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 unsloth/Qwen3.5-397B-A17B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Qwen3.5-397B-A17B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Qwen3.5-397B-A17B", "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/unsloth/Qwen3.5-397B-A17B
- SGLang
How to use unsloth/Qwen3.5-397B-A17B 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 "unsloth/Qwen3.5-397B-A17B" \ --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": "unsloth/Qwen3.5-397B-A17B", "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 "unsloth/Qwen3.5-397B-A17B" \ --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": "unsloth/Qwen3.5-397B-A17B", "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" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use unsloth/Qwen3.5-397B-A17B with Docker Model Runner:
docker model run hf.co/unsloth/Qwen3.5-397B-A17B
Upload folder using huggingface_hub
Browse files- README.md +8 -11
- generation_config.json +13 -0
README.md
CHANGED
|
@@ -931,7 +931,7 @@ For more details, please refer to our blog post [Qwen3.5](https://qwen.ai/blog?i
|
|
| 931 |
> To disable thinking content and obtain direct response, refer to the examples [here](#instruct-or-non-thinking-mode).
|
| 932 |
|
| 933 |
|
| 934 |
-
For streamlined integration, we recommend using Qwen3.5 via APIs. Below is a guide to use Qwen3.5 via OpenAI-compatible API.
|
| 935 |
|
| 936 |
### Serving Qwen3.5
|
| 937 |
|
|
@@ -963,19 +963,19 @@ The following will create API endpoints at `http://localhost:8000/v1`:
|
|
| 963 |
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
|
| 964 |
|
| 965 |
```shell
|
| 966 |
-
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --
|
| 967 |
```
|
| 968 |
|
| 969 |
- **Tool Use**: To support tool use, you can use the following command.
|
| 970 |
|
| 971 |
```shell
|
| 972 |
-
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --
|
| 973 |
```
|
| 974 |
|
| 975 |
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
|
| 976 |
|
| 977 |
```shell
|
| 978 |
-
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --
|
| 979 |
```
|
| 980 |
|
| 981 |
#### vLLM
|
|
@@ -994,30 +994,27 @@ The following will create API endpoints at `http://localhost:8000/v1`:
|
|
| 994 |
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
|
| 995 |
|
| 996 |
```shell
|
| 997 |
-
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --
|
| 998 |
```
|
| 999 |
|
| 1000 |
- **Tool Call**: To support tool use, you can use the following command.
|
| 1001 |
|
| 1002 |
```shell
|
| 1003 |
-
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --
|
| 1004 |
```
|
| 1005 |
|
| 1006 |
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
|
| 1007 |
|
| 1008 |
```shell
|
| 1009 |
-
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --
|
| 1010 |
```
|
| 1011 |
|
| 1012 |
- **Text-Only**: The following command skips the vision encoder and multimodal profiling to free up memory for additional KV cache:
|
| 1013 |
|
| 1014 |
```shell
|
| 1015 |
-
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --
|
| 1016 |
```
|
| 1017 |
|
| 1018 |
-
> [!Tip]
|
| 1019 |
-
> Because vLLM defaults to `--mamba-ssm-cache-dtype auto`, which resolves to `bfloat16` for Qwen3.5, the model's generation quality may suffer unless you explicitly set it to higher precision, i.e., `--mamba-ssm-cache-dtype float32`.
|
| 1020 |
-
|
| 1021 |
#### Hugging Face Transformers
|
| 1022 |
|
| 1023 |
Hugging Face Transformers contains a _lightweight_ server which can be used for quick testing and moderate load deployment.
|
|
|
|
| 931 |
> To disable thinking content and obtain direct response, refer to the examples [here](#instruct-or-non-thinking-mode).
|
| 932 |
|
| 933 |
|
| 934 |
+
For streamlined integration, we recommend using Qwen3.5 via APIs. Below is a guide to use Qwen3.5 via OpenAI-compatible API.
|
| 935 |
|
| 936 |
### Serving Qwen3.5
|
| 937 |
|
|
|
|
| 963 |
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
|
| 964 |
|
| 965 |
```shell
|
| 966 |
+
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3
|
| 967 |
```
|
| 968 |
|
| 969 |
- **Tool Use**: To support tool use, you can use the following command.
|
| 970 |
|
| 971 |
```shell
|
| 972 |
+
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3 --tool-call-parser qwen3_coder
|
| 973 |
```
|
| 974 |
|
| 975 |
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
|
| 976 |
|
| 977 |
```shell
|
| 978 |
+
python -m sglang.launch_server --model-path Qwen/Qwen3.5-397B-A17B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3 --speculative-algo NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
|
| 979 |
```
|
| 980 |
|
| 981 |
#### vLLM
|
|
|
|
| 994 |
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
|
| 995 |
|
| 996 |
```shell
|
| 997 |
+
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3
|
| 998 |
```
|
| 999 |
|
| 1000 |
- **Tool Call**: To support tool use, you can use the following command.
|
| 1001 |
|
| 1002 |
```shell
|
| 1003 |
+
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --enable-auto-tool-choice --tool-call-parser qwen3_coder
|
| 1004 |
```
|
| 1005 |
|
| 1006 |
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
|
| 1007 |
|
| 1008 |
```shell
|
| 1009 |
+
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --speculative-config '{"method":"qwen3_next_mtp","num_speculative_tokens":2}'
|
| 1010 |
```
|
| 1011 |
|
| 1012 |
- **Text-Only**: The following command skips the vision encoder and multimodal profiling to free up memory for additional KV cache:
|
| 1013 |
|
| 1014 |
```shell
|
| 1015 |
+
vllm serve Qwen/Qwen3.5-397B-A17B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --language-model-only
|
| 1016 |
```
|
| 1017 |
|
|
|
|
|
|
|
|
|
|
| 1018 |
#### Hugging Face Transformers
|
| 1019 |
|
| 1020 |
Hugging Face Transformers contains a _lightweight_ server which can be used for quick testing and moderate load deployment.
|
generation_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 248044,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
248046,
|
| 6 |
+
248044
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 248044,
|
| 9 |
+
"temperature": 0.6,
|
| 10 |
+
"top_k": 20,
|
| 11 |
+
"top_p": 0.95,
|
| 12 |
+
"transformers_version": "4.57.0.dev0"
|
| 13 |
+
}
|