Instructions to use tiny-random/qwen3.8-moe with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/qwen3.8-moe with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/qwen3.8-moe") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/qwen3.8-moe") model = AutoModelForCausalLM.from_pretrained("tiny-random/qwen3.8-moe", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/qwen3.8-moe with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/qwen3.8-moe" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/qwen3.8-moe", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/qwen3.8-moe
- SGLang
How to use tiny-random/qwen3.8-moe 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 "tiny-random/qwen3.8-moe" \ --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": "tiny-random/qwen3.8-moe", "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 "tiny-random/qwen3.8-moe" \ --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": "tiny-random/qwen3.8-moe", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/qwen3.8-moe with Docker Model Runner:
docker model run hf.co/tiny-random/qwen3.8-moe
Upload folder using huggingface_hub
Browse files- README.md +12 -7
- config.json +1 -1
- model.safetensors +2 -2
- tokenizer.json +2 -2
README.md
CHANGED
|
@@ -13,7 +13,7 @@ Structural comparison with `Qwen/Qwen3.8-2.4T-A95B`:
|
|
| 13 |
| Input modalities | Text | Same |
|
| 14 |
| Vocabulary | 248,320 | Same; special-token IDs preserved |
|
| 15 |
| Backbone layers | 92 | 8 |
|
| 16 |
-
| Hidden size | 8,192 |
|
| 17 |
| Attention Q/KV heads; head dim | 64/4; 256 | 32/2; 128 |
|
| 18 |
| Attention cycle | 3 linear + 1 full | Same; two complete cycles |
|
| 19 |
| Linear-attention key/value heads | 16/128 | 2/16 |
|
|
@@ -26,7 +26,7 @@ Structural comparison with `Qwen/Qwen3.8-2.4T-A95B`:
|
|
| 26 |
|
| 27 |
| File path | Size |
|
| 28 |
|------|------|
|
| 29 |
-
| model.safetensors |
|
| 30 |
|
| 31 |
|
| 32 |
### Example usage:
|
|
@@ -39,9 +39,11 @@ Structural comparison with `Qwen/Qwen3.8-2.4T-A95B`:
|
|
| 39 |
|
| 40 |
```bash
|
| 41 |
model_id=tiny-random/qwen3.8-moe
|
| 42 |
-
|
| 43 |
--model-path $model_id \
|
| 44 |
--tp-size 2 \
|
|
|
|
|
|
|
| 45 |
--speculative-algorithm NEXTN \
|
| 46 |
--speculative-num-steps 3 \
|
| 47 |
--speculative-eagle-topk 1 \
|
|
@@ -83,7 +85,7 @@ import torch
|
|
| 83 |
from huggingface_hub import hf_hub_download
|
| 84 |
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GenerationConfig, set_seed
|
| 85 |
# Creation helpers: pip install git+https://github.com/yujiepan/tiny-random.git
|
| 86 |
-
from tiny_random.qwen_utils import add_qwen_mtp, save_random_qwen_checkpoint
|
| 87 |
|
| 88 |
source_model_id = "Qwen/Qwen3.8-2.4T-A95B"
|
| 89 |
save_folder = "/tmp/tiny-random/qwen38-moe"
|
|
@@ -93,7 +95,7 @@ folder = Path(save_folder)
|
|
| 93 |
folder.mkdir(parents=True, exist_ok=True)
|
| 94 |
raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 95 |
raw.update(
|
| 96 |
-
hidden_size=
|
| 97 |
layer_types=(["linear_attention"] * 3 + ["full_attention"]) * 2,
|
| 98 |
num_attention_heads=32, num_key_value_heads=2,
|
| 99 |
linear_num_key_heads=2, linear_num_value_heads=16,
|
|
@@ -107,6 +109,8 @@ add_qwen_mtp(model, model.model)
|
|
| 107 |
save_random_qwen_checkpoint(model, folder)
|
| 108 |
AutoTokenizer.from_pretrained(source_model_id, revision=source_revision).save_pretrained(folder)
|
| 109 |
GenerationConfig.from_pretrained(source_model_id, revision=source_revision).save_pretrained(folder)
|
|
|
|
|
|
|
| 110 |
```
|
| 111 |
|
| 112 |
</details>
|
|
@@ -116,7 +120,7 @@ GenerationConfig.from_pretrained(source_model_id, revision=source_revision).save
|
|
| 116 |
<details><summary>Click to expand</summary>
|
| 117 |
|
| 118 |
```text
|
| 119 |
-
Qwen3.8 MoE: 8 backbone layers + 1 MTP layer; hidden_size=
|
| 120 |
```
|
| 121 |
|
| 122 |
</details>
|
|
@@ -135,4 +139,5 @@ Qwen3.8 MoE: 8 backbone layers + 1 MTP layer; hidden_size=128
|
|
| 135 |
|
| 136 |
### Change log:
|
| 137 |
|
| 138 |
-
- 2026-10-23: Initial version.
|
|
|
|
|
|
| 13 |
| Input modalities | Text | Same |
|
| 14 |
| Vocabulary | 248,320 | Same; special-token IDs preserved |
|
| 15 |
| Backbone layers | 92 | 8 |
|
| 16 |
+
| Hidden size | 8,192 | 16 |
|
| 17 |
| Attention Q/KV heads; head dim | 64/4; 256 | 32/2; 128 |
|
| 18 |
| Attention cycle | 3 linear + 1 full | Same; two complete cycles |
|
| 19 |
| Linear-attention key/value heads | 16/128 | 2/16 |
|
|
|
|
| 26 |
|
| 27 |
| File path | Size |
|
| 28 |
|------|------|
|
| 29 |
+
| model.safetensors | 25.9MB |
|
| 30 |
|
| 31 |
|
| 32 |
### Example usage:
|
|
|
|
| 39 |
|
| 40 |
```bash
|
| 41 |
model_id=tiny-random/qwen3.8-moe
|
| 42 |
+
sglang serve \
|
| 43 |
--model-path $model_id \
|
| 44 |
--tp-size 2 \
|
| 45 |
+
--fp8-gemm-backend triton \
|
| 46 |
+
--moe-runner-backend triton \
|
| 47 |
--speculative-algorithm NEXTN \
|
| 48 |
--speculative-num-steps 3 \
|
| 49 |
--speculative-eagle-topk 1 \
|
|
|
|
| 85 |
from huggingface_hub import hf_hub_download
|
| 86 |
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GenerationConfig, set_seed
|
| 87 |
# Creation helpers: pip install git+https://github.com/yujiepan/tiny-random.git
|
| 88 |
+
from tiny_random.qwen_utils import add_qwen_mtp, save_random_qwen_checkpoint, compact_qwen_tokenizer, check_qwen_repo_size
|
| 89 |
|
| 90 |
source_model_id = "Qwen/Qwen3.8-2.4T-A95B"
|
| 91 |
save_folder = "/tmp/tiny-random/qwen38-moe"
|
|
|
|
| 95 |
folder.mkdir(parents=True, exist_ok=True)
|
| 96 |
raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
|
| 97 |
raw.update(
|
| 98 |
+
hidden_size=16, head_dim=128, num_hidden_layers=8,
|
| 99 |
layer_types=(["linear_attention"] * 3 + ["full_attention"]) * 2,
|
| 100 |
num_attention_heads=32, num_key_value_heads=2,
|
| 101 |
linear_num_key_heads=2, linear_num_value_heads=16,
|
|
|
|
| 109 |
save_random_qwen_checkpoint(model, folder)
|
| 110 |
AutoTokenizer.from_pretrained(source_model_id, revision=source_revision).save_pretrained(folder)
|
| 111 |
GenerationConfig.from_pretrained(source_model_id, revision=source_revision).save_pretrained(folder)
|
| 112 |
+
compact_qwen_tokenizer(folder)
|
| 113 |
+
check_qwen_repo_size(folder)
|
| 114 |
```
|
| 115 |
|
| 116 |
</details>
|
|
|
|
| 120 |
<details><summary>Click to expand</summary>
|
| 121 |
|
| 122 |
```text
|
| 123 |
+
Qwen3.8 MoE: 8 backbone layers + 1 MTP layer; hidden_size=16
|
| 124 |
```
|
| 125 |
|
| 126 |
</details>
|
|
|
|
| 139 |
|
| 140 |
### Change log:
|
| 141 |
|
| 142 |
+
- 2026-10-23: Initial version.
|
| 143 |
+
- 2026-10-23: Reduced all repo files below 50 MB; GPU-validated TP=2, MTP and CUDA Graph.
|
config.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
| 11 |
"full_attention_interval": 4,
|
| 12 |
"head_dim": 128,
|
| 13 |
"hidden_act": "silu",
|
| 14 |
-
"hidden_size":
|
| 15 |
"initializer_range": 0.02,
|
| 16 |
"layer_types": [
|
| 17 |
"linear_attention",
|
|
|
|
| 11 |
"full_attention_interval": 4,
|
| 12 |
"head_dim": 128,
|
| 13 |
"hidden_act": "silu",
|
| 14 |
+
"hidden_size": 16,
|
| 15 |
"initializer_range": 0.02,
|
| 16 |
"layer_types": [
|
| 17 |
"linear_attention",
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b014592253b65e71aac976e7e417c8d9705d0e085cb3b98281141b51bc6063fb
|
| 3 |
+
size 25859808
|
tokenizer.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d765ac5a92a75f240af39f9358a09a140216dce113e57754c91042ef8b9e4e8
|
| 3 |
+
size 10079700
|