Instructions to use tiny-random/qwen3.8-flash-next with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/qwen3.8-flash-next 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-flash-next") 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-flash-next") model = AutoModelForMultimodalLM.from_pretrained("tiny-random/qwen3.8-flash-next", 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-flash-next 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-flash-next" # 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-flash-next", "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-flash-next
- SGLang
How to use tiny-random/qwen3.8-flash-next 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-flash-next" \ --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-flash-next", "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-flash-next" \ --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-flash-next", "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-flash-next with Docker Model Runner:
docker model run hf.co/tiny-random/qwen3.8-flash-next
Make creation examples standalone with public dependencies
Browse files- .meta.json +0 -1
- README.md +50 -7
.meta.json
CHANGED
|
@@ -8,7 +8,6 @@
|
|
| 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",
|
|
|
|
| 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",
|
README.md
CHANGED
|
@@ -104,13 +104,15 @@ print(processor.decode(output[0, inputs['input_ids'].shape[1]:], skip_special_to
|
|
| 104 |
|
| 105 |
```python
|
| 106 |
import json
|
|
|
|
| 107 |
from pathlib import Path
|
|
|
|
| 108 |
|
| 109 |
import torch
|
| 110 |
-
from huggingface_hub import hf_hub_download
|
|
|
|
| 111 |
from transformers import AutoConfig, AutoModelForImageTextToText, set_seed
|
| 112 |
-
|
| 113 |
-
from tiny_random.qwen_utils import add_qwen4_mtp, copy_qwen_source_assets, save_random_qwen_checkpoint
|
| 114 |
|
| 115 |
source_model_id = "Qwen/Qwen3.8-Flash-Next"
|
| 116 |
save_folder = "/tmp/tiny-random/qwen38-flash-next"
|
|
@@ -132,9 +134,50 @@ raw['vision_config'].update(depth=2, hidden_size=64, intermediate_size=128, num_
|
|
| 132 |
(folder / 'config.json').write_text(json.dumps(raw, indent=2))
|
| 133 |
config = AutoConfig.from_pretrained(folder)
|
| 134 |
model = AutoModelForImageTextToText.from_config(config, dtype=torch.bfloat16)
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
```
|
| 139 |
|
| 140 |
</details>
|
|
@@ -160,7 +203,6 @@ Qwen3.8 Flash-Next: 8 backbone layers + 1 HC-aware MTP layer; hidden_size=4
|
|
| 160 |
- numpy: 2.3.5
|
| 161 |
- safetensors: 0.8.0
|
| 162 |
- sglang: 0.5.23.dev384+g9ab74b851
|
| 163 |
-
- tiny-random: 0.2.0
|
| 164 |
- torch: 2.14.1
|
| 165 |
- torchcodec: 0.17.0
|
| 166 |
- transformers: 5.19.0
|
|
@@ -171,5 +213,6 @@ Qwen3.8 Flash-Next: 8 backbone layers + 1 HC-aware MTP layer; hidden_size=4
|
|
| 171 |
### Change log:
|
| 172 |
|
| 173 |
- 2026-10-23: Initial version.
|
|
|
|
| 174 |
|
| 175 |
This repo is generated by GPT-6.1-Sol
|
|
|
|
| 104 |
|
| 105 |
```python
|
| 106 |
import json
|
| 107 |
+
from copy import deepcopy
|
| 108 |
from pathlib import Path
|
| 109 |
+
from shutil import copyfile
|
| 110 |
|
| 111 |
import torch
|
| 112 |
+
from huggingface_hub import hf_hub_download, list_repo_files
|
| 113 |
+
from safetensors.torch import save_file
|
| 114 |
from transformers import AutoConfig, AutoModelForImageTextToText, set_seed
|
| 115 |
+
from transformers.models.qwen4_exp.modeling_qwen4_exp import Qwen4ExpTextRMSNorm
|
|
|
|
| 116 |
|
| 117 |
source_model_id = "Qwen/Qwen3.8-Flash-Next"
|
| 118 |
save_folder = "/tmp/tiny-random/qwen38-flash-next"
|
|
|
|
| 134 |
(folder / 'config.json').write_text(json.dumps(raw, indent=2))
|
| 135 |
config = AutoConfig.from_pretrained(folder)
|
| 136 |
model = AutoModelForImageTextToText.from_config(config, dtype=torch.bfloat16)
|
| 137 |
+
backbone = model.model.language_model
|
| 138 |
+
text = backbone.config
|
| 139 |
+
width = text.hidden_size
|
| 140 |
+
model.mtp = torch.nn.ModuleDict({
|
| 141 |
+
"fc_embedding": torch.nn.Linear(width, width, bias=False, dtype=torch.bfloat16),
|
| 142 |
+
"fc_hidden": torch.nn.Linear(width, width, bias=False, dtype=torch.bfloat16),
|
| 143 |
+
"pre_fc_norm_embedding": Qwen4ExpTextRMSNorm(width, eps=text.rms_norm_eps).to(torch.bfloat16),
|
| 144 |
+
"pre_fc_norm_hidden": Qwen4ExpTextRMSNorm(width * text.hc_count, eps=text.rms_norm_eps).to(torch.bfloat16),
|
| 145 |
+
"layers": torch.nn.ModuleList([deepcopy(backbone.layers[-1])]),
|
| 146 |
+
"hyper_connection_mixer": deepcopy(backbone.hyper_connection_mixer),
|
| 147 |
+
})
|
| 148 |
+
with torch.no_grad():
|
| 149 |
+
for name, param in sorted(model.named_parameters()):
|
| 150 |
+
if name.endswith("A_log"):
|
| 151 |
+
param.zero_()
|
| 152 |
+
elif name.endswith("dt_bias"):
|
| 153 |
+
param.fill_(1)
|
| 154 |
+
elif "norm" in name and name.endswith("weight"):
|
| 155 |
+
param.fill_(1 if "visual" in name or ".linear_attn.norm." in name else 0)
|
| 156 |
+
elif name.endswith("bias"):
|
| 157 |
+
param.zero_()
|
| 158 |
+
else:
|
| 159 |
+
torch.nn.init.normal_(param, mean=0, std=0.02)
|
| 160 |
+
state = {name: value.detach().cpu().contiguous() for name, value in model.state_dict().items()}
|
| 161 |
+
# The public checkpoint stores PLE embeddings in shard_N tensors.
|
| 162 |
+
for name in list(state):
|
| 163 |
+
if not name.endswith(".ple.ple_embedding.ngram_embedding.weight"):
|
| 164 |
+
continue
|
| 165 |
+
table = state.pop(name)
|
| 166 |
+
parts = text.split_ngram_parts
|
| 167 |
+
rows = (table.shape[0] + parts - 1) // parts
|
| 168 |
+
prefix = name.removesuffix(".weight")
|
| 169 |
+
for part in range(parts):
|
| 170 |
+
state[f"{prefix}.shard_{part}.weight"] = table[part * rows:(part + 1) * rows].contiguous()
|
| 171 |
+
save_file(state, folder / "model.safetensors", metadata={"format": "pt"})
|
| 172 |
+
# Preserve tokenizer, processor and generation assets exactly as published.
|
| 173 |
+
assets = {
|
| 174 |
+
"tokenizer.json", "tokenizer_config.json", "special_tokens_map.json",
|
| 175 |
+
"vocab.json", "merges.txt", "added_tokens.json", "chat_template.jinja",
|
| 176 |
+
"chat_template.json", "preprocessor_config.json", "processor_config.json",
|
| 177 |
+
"video_preprocessor_config.json", "generation_config.json",
|
| 178 |
+
}
|
| 179 |
+
for name in sorted(set(list_repo_files(source_model_id, revision=source_revision)) & assets):
|
| 180 |
+
copyfile(hf_hub_download(source_model_id, name, revision=source_revision), folder / name)
|
| 181 |
```
|
| 182 |
|
| 183 |
</details>
|
|
|
|
| 203 |
- numpy: 2.3.5
|
| 204 |
- safetensors: 0.8.0
|
| 205 |
- sglang: 0.5.23.dev384+g9ab74b851
|
|
|
|
| 206 |
- torch: 2.14.1
|
| 207 |
- torchcodec: 0.17.0
|
| 208 |
- transformers: 5.19.0
|
|
|
|
| 213 |
### Change log:
|
| 214 |
|
| 215 |
- 2026-10-23: Initial version.
|
| 216 |
+
- 2026-10-23: Creation examples use only public dependencies; source assets are copied unchanged.
|
| 217 |
|
| 218 |
This repo is generated by GPT-6.1-Sol
|