Instructions to use tiny-random/qwen3.8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/qwen3.8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/qwen3.8") 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("tiny-random/qwen3.8") model = AutoModelForMultimodalLM.from_pretrained("tiny-random/qwen3.8", 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 tiny-random/qwen3.8 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" # 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", "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/tiny-random/qwen3.8
- SGLang
How to use tiny-random/qwen3.8 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" \ --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", "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 "tiny-random/qwen3.8" \ --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", "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 tiny-random/qwen3.8 with Docker Model Runner:
docker model run hf.co/tiny-random/qwen3.8
Make creation examples standalone with public dependencies
Browse files- .meta.json +1 -2
- README.md +40 -11
.meta.json
CHANGED
|
@@ -8,8 +8,7 @@
|
|
| 8 |
"numpy": "2.3.5",
|
| 9 |
"safetensors": "0.8.0",
|
| 10 |
"sglang": "0.5.23.dev384+g9ab74b851",
|
| 11 |
-
"tiny-random": "0.2.0",
|
| 12 |
"torch": "2.14.1",
|
| 13 |
"torchcodec": "0.17.0",
|
| 14 |
"transformers": "5.19.0"
|
| 15 |
-
}
|
|
|
|
| 8 |
"numpy": "2.3.5",
|
| 9 |
"safetensors": "0.8.0",
|
| 10 |
"sglang": "0.5.23.dev384+g9ab74b851",
|
|
|
|
| 11 |
"torch": "2.14.1",
|
| 12 |
"torchcodec": "0.17.0",
|
| 13 |
"transformers": "5.19.0"
|
| 14 |
+
}
|
README.md
CHANGED
|
@@ -87,13 +87,14 @@ print(processor.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_to
|
|
| 87 |
|
| 88 |
```python
|
| 89 |
import json
|
|
|
|
| 90 |
from pathlib import Path
|
|
|
|
| 91 |
|
| 92 |
import torch
|
| 93 |
-
from huggingface_hub import hf_hub_download
|
| 94 |
-
from
|
| 95 |
-
|
| 96 |
-
from tiny_random.qwen_utils import add_qwen_mtp, save_random_qwen_checkpoint, compact_qwen_tokenizer, check_qwen_repo_size
|
| 97 |
|
| 98 |
source_model_id = "Qwen/Qwen3.8-27B"
|
| 99 |
save_folder = "/tmp/tiny-random/qwen38"
|
|
@@ -115,12 +116,40 @@ raw["vision_config"].update(depth=2, hidden_size=64, intermediate_size=128, num_
|
|
| 115 |
(folder / "config.json").write_text(json.dumps(raw, indent=2))
|
| 116 |
config = AutoConfig.from_pretrained(folder)
|
| 117 |
model = AutoModelForImageTextToText.from_config(config, dtype=torch.bfloat16)
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
```
|
| 125 |
|
| 126 |
</details>
|
|
@@ -146,7 +175,6 @@ Qwen3.8 VL: 8 backbone layers + 1 MTP layer; hidden_size=16
|
|
| 146 |
- numpy: 2.3.5
|
| 147 |
- safetensors: 0.8.0
|
| 148 |
- sglang: 0.5.23.dev384+g9ab74b851
|
| 149 |
-
- tiny-random: 0.2.0
|
| 150 |
- torch: 2.14.1
|
| 151 |
- torchcodec: 0.17.0
|
| 152 |
- transformers: 5.19.0
|
|
@@ -155,5 +183,6 @@ Qwen3.8 VL: 8 backbone layers + 1 MTP layer; hidden_size=16
|
|
| 155 |
|
| 156 |
- 2026-10-23: Initial version.
|
| 157 |
- 2026-10-23: Reduced all repo files below 50 MB; GPU-validated TP=2, MTP and CUDA Graph.
|
|
|
|
| 158 |
|
| 159 |
This repo is generated by GPT-6.1-Sol
|
|
|
|
| 87 |
|
| 88 |
```python
|
| 89 |
import json
|
| 90 |
+
from copy import deepcopy
|
| 91 |
from pathlib import Path
|
| 92 |
+
from shutil import copyfile
|
| 93 |
|
| 94 |
import torch
|
| 95 |
+
from huggingface_hub import hf_hub_download, list_repo_files
|
| 96 |
+
from safetensors.torch import save_file
|
| 97 |
+
from transformers import AutoConfig, AutoModelForImageTextToText, set_seed
|
|
|
|
| 98 |
|
| 99 |
source_model_id = "Qwen/Qwen3.8-27B"
|
| 100 |
save_folder = "/tmp/tiny-random/qwen38"
|
|
|
|
| 116 |
(folder / "config.json").write_text(json.dumps(raw, indent=2))
|
| 117 |
config = AutoConfig.from_pretrained(folder)
|
| 118 |
model = AutoModelForImageTextToText.from_config(config, dtype=torch.bfloat16)
|
| 119 |
+
backbone = model.model.language_model
|
| 120 |
+
text = backbone.config
|
| 121 |
+
def norm():
|
| 122 |
+
return type(backbone.norm)(text.hidden_size, text.rms_norm_eps).to(torch.bfloat16)
|
| 123 |
+
model.mtp = torch.nn.ModuleDict({
|
| 124 |
+
"pre_fc_norm_embedding": norm(),
|
| 125 |
+
"pre_fc_norm_hidden": norm(),
|
| 126 |
+
"fc": torch.nn.Linear(2 * text.hidden_size, text.hidden_size, bias=False, dtype=torch.bfloat16),
|
| 127 |
+
"layers": torch.nn.ModuleList([deepcopy(backbone.layers[-1])]),
|
| 128 |
+
"norm": norm(),
|
| 129 |
+
})
|
| 130 |
+
with torch.no_grad():
|
| 131 |
+
for name, param in sorted(model.named_parameters()):
|
| 132 |
+
if name.endswith("A_log"):
|
| 133 |
+
param.zero_()
|
| 134 |
+
elif name.endswith("dt_bias"):
|
| 135 |
+
param.fill_(1)
|
| 136 |
+
elif "norm" in name and name.endswith("weight"):
|
| 137 |
+
param.fill_(1 if "visual" in name or ".linear_attn.norm." in name else 0)
|
| 138 |
+
elif name.endswith("bias"):
|
| 139 |
+
param.zero_()
|
| 140 |
+
else:
|
| 141 |
+
torch.nn.init.normal_(param, mean=0, std=0.02)
|
| 142 |
+
state = {name: value.detach().cpu().contiguous() for name, value in model.state_dict().items()}
|
| 143 |
+
save_file(state, folder / "model.safetensors", metadata={"format": "pt"})
|
| 144 |
+
# Preserve tokenizer, processor and generation assets exactly as published.
|
| 145 |
+
assets = {
|
| 146 |
+
"tokenizer.json", "tokenizer_config.json", "special_tokens_map.json",
|
| 147 |
+
"vocab.json", "merges.txt", "added_tokens.json", "chat_template.jinja",
|
| 148 |
+
"chat_template.json", "preprocessor_config.json", "processor_config.json",
|
| 149 |
+
"video_preprocessor_config.json", "generation_config.json",
|
| 150 |
+
}
|
| 151 |
+
for name in sorted(set(list_repo_files(source_model_id, revision=source_revision)) & assets):
|
| 152 |
+
copyfile(hf_hub_download(source_model_id, name, revision=source_revision), folder / name)
|
| 153 |
```
|
| 154 |
|
| 155 |
</details>
|
|
|
|
| 175 |
- numpy: 2.3.5
|
| 176 |
- safetensors: 0.8.0
|
| 177 |
- sglang: 0.5.23.dev384+g9ab74b851
|
|
|
|
| 178 |
- torch: 2.14.1
|
| 179 |
- torchcodec: 0.17.0
|
| 180 |
- transformers: 5.19.0
|
|
|
|
| 183 |
|
| 184 |
- 2026-10-23: Initial version.
|
| 185 |
- 2026-10-23: Reduced all repo files below 50 MB; GPU-validated TP=2, MTP and CUDA Graph.
|
| 186 |
+
- 2026-10-23: Creation examples use only public dependencies; source assets are copied unchanged.
|
| 187 |
|
| 188 |
This repo is generated by GPT-6.1-Sol
|