Downloads · 30 days
0
shibatch/tinyqwen3moe2m
tinyqwen3moe2m is a machine learning model from shibatch. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This repository provides an ultra-lightweight Qwen3 Mixture-of-Experts (MoE) model file in Hugging Face / Safetensors format, trained to 100% convergence on the TinyStories dataset and optimized for inference engine t…
Downloads · 30 days
0
Access
Public
Updated Jun 14, 2026
Repo size
7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors7 MB · 99%
From the Hugging Face model README
This repository provides an ultra-lightweight Qwen3 Mixture-of-Experts (MoE) model file in Hugging Face / Safetensors format, trained to 100% convergence on the TinyStories dataset and optimized for inference engine testing, MoE routing verification, and automated CI pipelines.
When developing a custom Mixture-of-Experts (MoE) inference engine or optimizing low-level routing layers, debugging with full-sized models significantly slows down development efficiency. This suite offers a true 1.95M parameter scale Qwen3-MoE model, allowing developers to validate their top-k gates, token dispatchers, shared expert combinations, and YaRN RoPE scaling parameters step-by-step with maximum efficiency and verifiable natural language outputs.
This model is specifically designed to expose architectural layout and edge-case calculation bugs in MoE pipelines:
num_attention_heads=8 and head_dim=32 in the configuration, a physical 256-dimensional q_proj layer is built directly. This eliminates the need for implicit, runtime 2x layer expansion logic and ensures a predictable memory layout during weight loading.rope_scaling) with factor=4.0 and original_max_position_embeddings=64. This validates that the inference engine can accurately compute frequency adjustments across an expanded context window.num_attention_heads=8, num_key_value_heads=1). This checks that KV caching structures, stride calculations, parallel splits, and index handling process Grouped-Query Attention topologies properly without memory alignment failures.num_experts_per_tok=1) across 6 deep transformer layers. This allows developers to strictly track and trace the accuracy of router logit probability flows, routing masks, and row-major tensor switching logic without heavy hardware memory tracking.shared_expert_intermediate_size=128). This helps verify whether the model correctly adds the non-gated common network baseline output onto the single gated routing expert output path without accumulation alignment bugs.<s> / </s>) into exact 256-block chunks. This is ideal for testing internal state boundaries, position indexing shifts, and sequence-packing continuous-attention masks in custom hardware layouts.q_proj, k_proj, and v_proj architectures. If an inference engine's dynamic lookup fails to map or slightly shifts these attention biases, the numerical discrepancy scales exponentially across the 6 network layers, immediately destroying greedy generation text into garbage within a few tokens.The repository structure follows standard Hugging Face native configurations for standalone tensor loading:
```text
SUCCESS
```text
.
└── hf/
├── config.json
├── generation_config.json
├── model.safetensors
├── tokenizer_config.json
├── special_tokens_map.json
└── tokenizer.json
./hf/)hf/model.safetensors: The raw, unquantized model weights containing standard query/key/value projections with biases, routing router layers, and MoE experts stored in secure Safetensors format.hf/config.json: The architectural configuration file defining MoE hyperparameters (6 layers, 8 heads, 2 local experts, 1 active expert, shared parameters, weight-tying, standard dimensions, and YaRN scaling parameters).hf/generation_config.json: Default parameters optimized for text generation.hf/tokenizer_config.json: Tokenizer behavior layout specifying the custom ChatML/Qwen3 fast tokenizer setup.hf/special_tokens_map.json: Architectural mappings tying special characters to the token blocks.hf/tokenizer.json: The custom Byte-Level BPE tokenization descriptor layout trained with a base size of 1000.To match the dataset structure used during training, encode text with add_special_tokens=False and manually prepend the exact BOS token ID (1000). This ensures perfect token alignment and accurate MoE forward pass sampling.
import torch
from transformers import PreTrainedTokenizerFast, Qwen3MoeForCausalLM
repo_id = "shibatch/tinyqwen3moe2m"
# Load via PreTrainedTokenizerFast to preserve the vocabulary configuration safely
tokenizer = PreTrainedTokenizerFast.from_pretrained(repo_id, subfolder="hf")
model = Qwen3MoeForCausalLM.from_pretrained(repo_id, subfolder="hf")
prompt = "Once upon"
# Tokenize without injecting automatic special tokens
input_ids = tokenizer.encode(prompt, add_special_tokens=False)
# Manually prepend the exact BOS token ID (1000) to match the training pipeline layout
input_ids = [tokenizer.bos_token_id] + input_ids
inputs = {"input_ids": torch.tensor([input_ids])}
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
do_sample=False, # Forces deterministic greedy decoding
repetition_penalty=1.0,
top_p=1.0,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The routing configuration, hidden layers, and attention mechanics conform strictly to the standard Qwen3-MoE structural profiling.
Qwen3MoeForCausalLM)hidden_size): 128head_dim): 32 (8 heads $\times$ 32 dim = 256, explicitly defining the 256-dimensional q_proj from the start without dynamic runtime extensions)num_hidden_layers): 6num_attention_heads): 8num_key_value_heads): 1 (Standard GQA 8:1 topology)intermediate_size): 256max_position_embeddings): 256attention_bias): True (Explicitly uniform random between -0.2 and 0.2 for q_proj, k_proj, and v_proj)num_experts): 2num_experts_per_tok): 1 (Top-1 Routing)moe_intermediate_size): 256shared_expert_intermediate_size): 128rope_theta): 1,000,000.0rope_scaling): {"type": "yarn", "factor": 4.0, "original_max_position_embeddings": 64}tie_word_embeddings): True