Instructions to use amd/tiny-qwen3-moe-w4a8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/tiny-qwen3-moe-w4a8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amd/tiny-qwen3-moe-w4a8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amd/tiny-qwen3-moe-w4a8") model = AutoModelForCausalLM.from_pretrained("amd/tiny-qwen3-moe-w4a8", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amd/tiny-qwen3-moe-w4a8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/tiny-qwen3-moe-w4a8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/tiny-qwen3-moe-w4a8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/amd/tiny-qwen3-moe-w4a8
- SGLang
How to use amd/tiny-qwen3-moe-w4a8 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 "amd/tiny-qwen3-moe-w4a8" \ --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": "amd/tiny-qwen3-moe-w4a8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "amd/tiny-qwen3-moe-w4a8" \ --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": "amd/tiny-qwen3-moe-w4a8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use amd/tiny-qwen3-moe-w4a8 with Docker Model Runner:
docker model run hf.co/amd/tiny-qwen3-moe-w4a8
Add tiny Qwen3-MoE W4A8 (int4-fp8) reference model for vLLM CI
Browse files- .gitattributes +1 -0
- added_tokens.json +5 -0
- chat_template.jinja +6 -0
- config.json +118 -0
- generation_config.json +4 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- special_tokens_map.json +20 -0
- tokenizer.json +3 -0
- tokenizer_config.json +43 -0
- vocab.json +0 -0
.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
|
added_tokens.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<|endoftext|>": 151643,
|
| 3 |
+
"<|im_end|>": 151645,
|
| 4 |
+
"<|im_start|>": 151644
|
| 5 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
' }}{% endif %}{{'<|im_start|>' + message['role'] + '
|
| 4 |
+
' + message['content'] + '<|im_end|>' + '
|
| 5 |
+
'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
|
| 6 |
+
' }}{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3MoeForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"decoder_sparse_step": 1,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"head_dim": 64,
|
| 10 |
+
"hidden_act": "silu",
|
| 11 |
+
"hidden_size": 256,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 256,
|
| 14 |
+
"max_position_embeddings": 2048,
|
| 15 |
+
"mlp_only_layers": [],
|
| 16 |
+
"model_type": "qwen3_moe",
|
| 17 |
+
"moe_intermediate_size": 256,
|
| 18 |
+
"norm_topk_prob": false,
|
| 19 |
+
"num_attention_heads": 4,
|
| 20 |
+
"num_experts": 8,
|
| 21 |
+
"num_experts_per_tok": 2,
|
| 22 |
+
"num_hidden_layers": 2,
|
| 23 |
+
"num_key_value_heads": 2,
|
| 24 |
+
"output_router_logits": false,
|
| 25 |
+
"quantization_config": {
|
| 26 |
+
"algo_config": null,
|
| 27 |
+
"exclude": [
|
| 28 |
+
"model.layers.0.self_attn.q_proj",
|
| 29 |
+
"model.layers.0.self_attn.k_proj",
|
| 30 |
+
"model.layers.0.self_attn.v_proj",
|
| 31 |
+
"model.layers.0.self_attn.o_proj",
|
| 32 |
+
"model.layers.0.mlp.gate",
|
| 33 |
+
"model.layers.1.self_attn.q_proj",
|
| 34 |
+
"model.layers.1.self_attn.k_proj",
|
| 35 |
+
"model.layers.1.self_attn.v_proj",
|
| 36 |
+
"model.layers.1.self_attn.o_proj",
|
| 37 |
+
"model.layers.1.mlp.gate",
|
| 38 |
+
"lm_head"
|
| 39 |
+
],
|
| 40 |
+
"export": {
|
| 41 |
+
"kv_cache_group": [],
|
| 42 |
+
"min_kv_scale": 0.0,
|
| 43 |
+
"pack_method": "reorder",
|
| 44 |
+
"weight_format": "real_quantized",
|
| 45 |
+
"weight_merge_groups": null
|
| 46 |
+
},
|
| 47 |
+
"global_quant_config": {
|
| 48 |
+
"bias": null,
|
| 49 |
+
"input_tensors": {
|
| 50 |
+
"ch_axis": null,
|
| 51 |
+
"dtype": "fp8_e4m3",
|
| 52 |
+
"group_size": null,
|
| 53 |
+
"is_dynamic": true,
|
| 54 |
+
"is_scale_quant": false,
|
| 55 |
+
"mx_element_dtype": null,
|
| 56 |
+
"observer_cls": "PerTensorMinMaxObserver",
|
| 57 |
+
"qscheme": "per_tensor",
|
| 58 |
+
"round_method": "half_even",
|
| 59 |
+
"scale_calculation_mode": null,
|
| 60 |
+
"scale_format": null,
|
| 61 |
+
"scale_type": "float",
|
| 62 |
+
"symmetric": true
|
| 63 |
+
},
|
| 64 |
+
"output_tensors": null,
|
| 65 |
+
"target_device": null,
|
| 66 |
+
"weight": [
|
| 67 |
+
{
|
| 68 |
+
"ch_axis": null,
|
| 69 |
+
"dtype": "fp8_e4m3",
|
| 70 |
+
"group_size": null,
|
| 71 |
+
"is_dynamic": false,
|
| 72 |
+
"is_scale_quant": false,
|
| 73 |
+
"mx_element_dtype": null,
|
| 74 |
+
"observer_cls": "PerTensorMinMaxObserver",
|
| 75 |
+
"qscheme": "per_tensor",
|
| 76 |
+
"round_method": "half_even",
|
| 77 |
+
"scale_calculation_mode": null,
|
| 78 |
+
"scale_format": null,
|
| 79 |
+
"scale_type": "float",
|
| 80 |
+
"symmetric": true
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"ch_axis": 0,
|
| 84 |
+
"dtype": "int4",
|
| 85 |
+
"group_size": null,
|
| 86 |
+
"is_dynamic": false,
|
| 87 |
+
"is_scale_quant": false,
|
| 88 |
+
"mx_element_dtype": null,
|
| 89 |
+
"observer_cls": "PerChannelMinMaxObserver",
|
| 90 |
+
"qscheme": "per_channel",
|
| 91 |
+
"round_method": "half_even",
|
| 92 |
+
"scale_calculation_mode": null,
|
| 93 |
+
"scale_format": null,
|
| 94 |
+
"scale_type": "float",
|
| 95 |
+
"symmetric": true
|
| 96 |
+
}
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
"kv_cache_post_rope": false,
|
| 100 |
+
"kv_cache_quant_config": {},
|
| 101 |
+
"layer_quant_config": {},
|
| 102 |
+
"layer_type_quant_config": {},
|
| 103 |
+
"quant_method": "quark",
|
| 104 |
+
"quant_mode": "eager_mode",
|
| 105 |
+
"softmax_quant_spec": null,
|
| 106 |
+
"version": "0.11.2"
|
| 107 |
+
},
|
| 108 |
+
"rms_norm_eps": 1e-06,
|
| 109 |
+
"rope_scaling": null,
|
| 110 |
+
"rope_theta": 10000.0,
|
| 111 |
+
"router_aux_loss_coef": 0.001,
|
| 112 |
+
"sliding_window": null,
|
| 113 |
+
"tie_word_embeddings": false,
|
| 114 |
+
"transformers_version": "4.57.1",
|
| 115 |
+
"use_cache": true,
|
| 116 |
+
"use_sliding_window": false,
|
| 117 |
+
"vocab_size": 4096
|
| 118 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"transformers_version": "4.57.1"
|
| 4 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e6cbca11737d78db773e6530bbf61ae63575eb019b1563ca509f017e0b7dde25
|
| 3 |
+
size 6608352
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>"
|
| 5 |
+
],
|
| 6 |
+
"eos_token": {
|
| 7 |
+
"content": "<|im_end|>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false
|
| 12 |
+
},
|
| 13 |
+
"pad_token": {
|
| 14 |
+
"content": "<|endoftext|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false
|
| 19 |
+
}
|
| 20 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a360620a0c604a1bf14e11432524102a78c70ed293e1194063dc27a53fc9caf7
|
| 3 |
+
size 11418363
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"151643": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": false,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"151644": {
|
| 13 |
+
"content": "<|im_start|>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"151645": {
|
| 21 |
+
"content": "<|im_end|>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"additional_special_tokens": [
|
| 30 |
+
"<|im_start|>",
|
| 31 |
+
"<|im_end|>"
|
| 32 |
+
],
|
| 33 |
+
"bos_token": null,
|
| 34 |
+
"clean_up_tokenization_spaces": false,
|
| 35 |
+
"eos_token": "<|im_end|>",
|
| 36 |
+
"errors": "replace",
|
| 37 |
+
"extra_special_tokens": {},
|
| 38 |
+
"model_max_length": 32768,
|
| 39 |
+
"pad_token": "<|endoftext|>",
|
| 40 |
+
"split_special_tokens": false,
|
| 41 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 42 |
+
"unk_token": null
|
| 43 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|