This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from Qwen/Qwen3.8-27B-FP8.

Structural comparison with Qwen/Qwen3.8-27B-FP8:

Feature Source Tiny
Input modalities Text, image, video Same
Vocabulary 248,320 Same; special-token IDs preserved
Backbone layers 64 8
Hidden size 5,120 32
Attention Q/KV heads; head dim 24/4; 256 12/2; 128
Attention cycle 3 linear + 1 full Same; two complete cycles
Linear-attention key/value heads 16/48 2/6
Linear-attention key/value head dim 128/128 Same
MLP intermediate size 17,408 512
MTP 1 full-attention layer; shared embeddings Same
Vision layers / hidden size 27 / 1,152 2 / 64
Vision patch / temporal patch / merge 16 / 2 / 2 Same
Vision output size 5,120 32
Checkpoint format FP8 language/MTP projections; BF16 vision/gates; 128x128 blocks Same FP8/BF16 layout; 32x32 blocks
File path Size
model.safetensors 34.1MB

Example usage:

  • SGLang (✅ verified)

    • Runs with TP=2, the embedded NEXTN/MTP layer, and CUDA Graph.
    • Verified for text, image-plus-text and video-plus-text on two NVIDIA H20 GPUs; see Test environment for dependency versions.
model_id=tiny-random/qwen3.8-fp8
sglang serve \
  --model-path $model_id \
  --tp-size 2 \
  --fp8-gemm-backend triton \
  --moe-runner-backend triton \
  --speculative-algorithm NEXTN \
  --speculative-num-steps 3 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 4 \
  --context-length 4096 \
  --max-total-tokens 4096 \
  --chunked-prefill-size 512 \
  --mem-fraction-static 0.4 \
  --cuda-graph-config '{"decode": {"bs": [1, 2, 4, 8]}}' \
  --disable-custom-all-reduce
  • Transformers (✅ verified)
import numpy as np
import torch
from PIL import Image
from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration
from transformers.video_utils import VideoMetadata

model_id = "tiny-random/qwen3.8-fp8"
model = Qwen3_5ForConditionalGeneration.from_pretrained(
    model_id, dtype=torch.bfloat16, device_map="cuda", attn_implementation="sdpa",
)
processor = AutoProcessor.from_pretrained(model_id)
image = Image.new("RGB", (64, 64), (220, 30, 30))
# Four predecoded RGB frames, with timestamps supplied through video_metadata.
video = np.stack([np.asarray(Image.new("RGB", (64, 64), color)) for color in
                  [(220, 30, 30), (30, 220, 30), (30, 30, 220), (220, 220, 30)]])
messages = [{"role": "user", "content": [
    {"type": "image", "image": image},
    {"type": "video", "video": video},
    {"type": "text", "text": "Describe the image and the video."},
]}]
inputs = processor.apply_chat_template(
    messages, tokenize=True, add_generation_prompt=True,
    return_dict=True, return_tensors="pt",
    do_sample_frames=False,
    video_metadata=[VideoMetadata(total_num_frames=4, fps=2, frames_indices=[0, 1, 2, 3])],
).to(model.device)
output = model.generate(**inputs, do_sample=False, max_new_tokens=10)
print(processor.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Codes to create this repo (✅ verified):

Click to expand
import json
from copy import deepcopy
from pathlib import Path
from shutil import copyfile

import torch
from huggingface_hub import hf_hub_download, list_repo_files
from safetensors.torch import save_file
from transformers import AutoConfig, AutoModelForImageTextToText, set_seed

source_model_id = "Qwen/Qwen3.8-27B-FP8"
save_folder = "/tmp/tiny-random/qwen38-fp8"
source_revision = '017b9c7af6b5689d5dd426a76e0bc077eb5ca20a'
set_seed(42)
folder = Path(save_folder)
folder.mkdir(parents=True, exist_ok=True)
raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
quantization = raw.pop("quantization_config")
quantization["weight_block_size"] = [32, 32]
raw["text_config"].update(
    hidden_size=32, head_dim=128, num_hidden_layers=8,
    layer_types=(["linear_attention"] * 3 + ["full_attention"]) * 2,
    num_attention_heads=12, num_key_value_heads=2,
    linear_num_key_heads=2, linear_num_value_heads=6,
    linear_key_head_dim=128, linear_value_head_dim=128,
    intermediate_size=512,
)
raw["text_config"]["rope_parameters"]["mrope_section"] = [6, 5, 5]
raw["vision_config"].update(depth=2, hidden_size=64, intermediate_size=128, num_heads=2, out_hidden_size=32)
(folder / "config.json").write_text(json.dumps(raw, indent=2))
config = AutoConfig.from_pretrained(folder)
model = AutoModelForImageTextToText.from_config(config, dtype=torch.bfloat16)
backbone = model.model.language_model
text = backbone.config
def norm():
    return type(backbone.norm)(text.hidden_size, text.rms_norm_eps).to(torch.bfloat16)
model.mtp = torch.nn.ModuleDict({
    "pre_fc_norm_embedding": norm(),
    "pre_fc_norm_hidden": norm(),
    "fc": torch.nn.Linear(2 * text.hidden_size, text.hidden_size, bias=False, dtype=torch.bfloat16),
    "layers": torch.nn.ModuleList([deepcopy(backbone.layers[-1])]),
    "norm": norm(),
})
with torch.no_grad():
    for name, param in sorted(model.named_parameters()):
        if name.endswith("A_log"):
            param.zero_()
        elif name.endswith("dt_bias"):
            param.fill_(1)
        elif "norm" in name and name.endswith("weight"):
            param.fill_(1 if "visual" in name or ".linear_attn.norm." in name else 0)
        elif name.endswith("bias"):
            param.zero_()
        else:
            torch.nn.init.normal_(param, mean=0, std=0.02)
state = {name: value.detach().cpu().contiguous() for name, value in model.state_dict().items()}
# Prune source exclusions absent from this architecture before FP8 loading.
names = set(dict(model.named_modules())) | set(dict(model.named_parameters()))
exclusions = [name for name in quantization["modules_to_not_convert"] if name in names]
quantization["modules_to_not_convert"] = exclusions

def pack(name, weight):
    n, k = weight.shape
    bn, bk = quantization["weight_block_size"]
    blocks = weight.float().reshape(n // bn, bn, k // bk, bk)
    scales = (blocks.abs().amax(dim=(1, 3)) / 448).clamp_min(1e-12).to(torch.bfloat16)
    packed = (blocks / scales.float()[:, None, :, None]).clamp(-448, 448)
    state[name] = packed.reshape(n, k).to(torch.float8_e4m3fn).contiguous()
    state[name.removesuffix("weight") + "weight_scale_inv"] = scales.contiguous()

for name, module in model.named_modules():
    excluded = any(name == prefix or name.startswith(prefix + ".") for prefix in exclusions)
    if isinstance(module, torch.nn.Linear) and not excluded:
        pack(name + ".weight", state[name + ".weight"])
save_file(state, folder / "model.safetensors", metadata={"format": "pt"})
raw["quantization_config"] = quantization
(folder / "config.json").write_text(json.dumps(raw, indent=2))
# Preserve tokenizer, processor and generation assets exactly as published.
assets = {
    "tokenizer.json", "tokenizer_config.json", "special_tokens_map.json",
    "vocab.json", "merges.txt", "added_tokens.json", "chat_template.jinja",
    "chat_template.json", "preprocessor_config.json", "processor_config.json",
    "video_preprocessor_config.json", "generation_config.json",
}
for name in sorted(set(list_repo_files(source_model_id, revision=source_revision)) & assets):
    copyfile(hf_hub_download(source_model_id, name, revision=source_revision), folder / name)

Printing the model:

Click to expand
Qwen3_5ForConditionalGeneration(
  (model): Qwen3_5Model(
    (visual): Qwen3_5VisionModel(
      (patch_embed): Qwen3_5VisionPatchEmbed(
        (proj): Conv3d(3, 64, kernel_size=(2, 16, 16), stride=(2, 16, 16))
      )
      (pos_embed): Embedding(2304, 64)
      (rotary_pos_emb): Qwen3_5VisionRotaryEmbedding()
      (blocks): ModuleList(
        (0-1): 2 x Qwen3_5VisionBlock(
          (norm1): LayerNorm((64,), eps=1e-06, elementwise_affine=True, bias=True)
          (norm2): LayerNorm((64,), eps=1e-06, elementwise_affine=True, bias=True)
          (attn): Qwen3_5VisionAttention(
            (qkv): Linear(in_features=64, out_features=192, bias=True)
            (proj): Linear(in_features=64, out_features=64, bias=True)
          )
          (mlp): Qwen3_5VisionMLP(
            (linear_fc1): Linear(in_features=64, out_features=128, bias=True)
            (linear_fc2): Linear(in_features=128, out_features=64, bias=True)
            (act_fn): GELUTanh()
          )
        )
      )
      (merger): Qwen3_5VisionPatchMerger(
        (norm): LayerNorm((64,), eps=1e-06, elementwise_affine=True, bias=True)
        (linear_fc1): Linear(in_features=256, out_features=256, bias=True)
        (act_fn): GELU(approximate='none')
        (linear_fc2): Linear(in_features=256, out_features=32, bias=True)
      )
    )
    (language_model): Qwen3_5TextModel(
      (embed_tokens): Embedding(248320, 32)
      (layers): ModuleList(
        (0-2): 3 x Qwen3_5DecoderLayer(
          (linear_attn): Qwen3_5GatedDeltaNet(
            (conv1d): Conv1d(1280, 1280, kernel_size=(4,), stride=(1,), padding=(3,), groups=1280, bias=False)
            (norm): Qwen3_5RMSNormGated()
            (out_proj): Linear(in_features=768, out_features=32, bias=False)
            (in_proj_qkv): Linear(in_features=32, out_features=1280, bias=False)
            (in_proj_z): Linear(in_features=32, out_features=768, bias=False)
            (in_proj_b): Linear(in_features=32, out_features=6, bias=False)
            (in_proj_a): Linear(in_features=32, out_features=6, bias=False)
          )
          (mlp): Qwen3_5MLP(
            (gate_proj): Linear(in_features=32, out_features=512, bias=False)
            (up_proj): Linear(in_features=32, out_features=512, bias=False)
            (down_proj): Linear(in_features=512, out_features=32, bias=False)
            (act_fn): SiLUActivation()
          )
          (input_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
          (post_attention_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
        )
        (3): Qwen3_5DecoderLayer(
          (self_attn): Qwen3_5Attention(
            (q_proj): Linear(in_features=32, out_features=3072, bias=False)
            (k_proj): Linear(in_features=32, out_features=256, bias=False)
            (v_proj): Linear(in_features=32, out_features=256, bias=False)
            (o_proj): Linear(in_features=1536, out_features=32, bias=False)
            (q_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
            (k_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
          )
          (mlp): Qwen3_5MLP(
            (gate_proj): Linear(in_features=32, out_features=512, bias=False)
            (up_proj): Linear(in_features=32, out_features=512, bias=False)
            (down_proj): Linear(in_features=512, out_features=32, bias=False)
            (act_fn): SiLUActivation()
          )
          (input_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
          (post_attention_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
        )
        (4-6): 3 x Qwen3_5DecoderLayer(
          (linear_attn): Qwen3_5GatedDeltaNet(
            (conv1d): Conv1d(1280, 1280, kernel_size=(4,), stride=(1,), padding=(3,), groups=1280, bias=False)
            (norm): Qwen3_5RMSNormGated()
            (out_proj): Linear(in_features=768, out_features=32, bias=False)
            (in_proj_qkv): Linear(in_features=32, out_features=1280, bias=False)
            (in_proj_z): Linear(in_features=32, out_features=768, bias=False)
            (in_proj_b): Linear(in_features=32, out_features=6, bias=False)
            (in_proj_a): Linear(in_features=32, out_features=6, bias=False)
          )
          (mlp): Qwen3_5MLP(
            (gate_proj): Linear(in_features=32, out_features=512, bias=False)
            (up_proj): Linear(in_features=32, out_features=512, bias=False)
            (down_proj): Linear(in_features=512, out_features=32, bias=False)
            (act_fn): SiLUActivation()
          )
          (input_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
          (post_attention_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
        )
        (7): Qwen3_5DecoderLayer(
          (self_attn): Qwen3_5Attention(
            (q_proj): Linear(in_features=32, out_features=3072, bias=False)
            (k_proj): Linear(in_features=32, out_features=256, bias=False)
            (v_proj): Linear(in_features=32, out_features=256, bias=False)
            (o_proj): Linear(in_features=1536, out_features=32, bias=False)
            (q_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
            (k_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
          )
          (mlp): Qwen3_5MLP(
            (gate_proj): Linear(in_features=32, out_features=512, bias=False)
            (up_proj): Linear(in_features=32, out_features=512, bias=False)
            (down_proj): Linear(in_features=512, out_features=32, bias=False)
            (act_fn): SiLUActivation()
          )
          (input_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
          (post_attention_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
        )
      )
      (norm): Qwen3_5RMSNorm((32,), eps=1e-06)
      (rotary_emb): Qwen3_5TextRotaryEmbedding()
    )
  )
  (lm_head): Linear(in_features=32, out_features=248320, bias=False)
  (mtp): ModuleDict(
    (pre_fc_norm_embedding): Qwen3_5RMSNorm((32,), eps=1e-06)
    (pre_fc_norm_hidden): Qwen3_5RMSNorm((32,), eps=1e-06)
    (fc): Linear(in_features=64, out_features=32, bias=False)
    (layers): ModuleList(
      (0): Qwen3_5DecoderLayer(
        (self_attn): Qwen3_5Attention(
          (q_proj): Linear(in_features=32, out_features=3072, bias=False)
          (k_proj): Linear(in_features=32, out_features=256, bias=False)
          (v_proj): Linear(in_features=32, out_features=256, bias=False)
          (o_proj): Linear(in_features=1536, out_features=32, bias=False)
          (q_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
          (k_norm): Qwen3_5RMSNorm((128,), eps=1e-06)
        )
        (mlp): Qwen3_5MLP(
          (gate_proj): Linear(in_features=32, out_features=512, bias=False)
          (up_proj): Linear(in_features=32, out_features=512, bias=False)
          (down_proj): Linear(in_features=512, out_features=32, bias=False)
          (act_fn): SiLUActivation()
        )
        (input_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
        (post_attention_layernorm): Qwen3_5RMSNorm((32,), eps=1e-06)
      )
    )
    (norm): Qwen3_5RMSNorm((32,), eps=1e-06)
  )
)

Test environment:

  • Pillow: 12.2.0
  • accelerate: 1.15.0
  • av: 19.0.2
  • flashinfer-python: 0.7.2
  • huggingface_hub: 1.33.0
  • kernels: 0.17.0
  • numpy: 2.3.5
  • safetensors: 0.8.0
  • sglang: 0.5.23.dev384+g9ab74b851
  • torch: 2.14.1
  • torchcodec: 0.17.0
  • transformers: 5.19.0

Change log:

  • 2026-10-23: Initial version.
  • 2026-10-23: Reduced all repo files below 50 MB; GPU-validated TP=2, MTP and CUDA Graph.
  • 2026-10-23: Creation examples use only public dependencies; source assets are copied unchanged.

This repo is generated by GPT-6.1-Sol

Downloads last month
58
Safetensors
Model size
17.8M params
Tensor type
BF16
·
F8_E4M3
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for tiny-random/qwen3.8-fp8

Base model

Qwen/Qwen3.8-27B
Quantized
(9)
this model

Collection including tiny-random/qwen3.8-fp8