shibatch commited on
Commit
364c6be
·
verified ·
1 Parent(s): 7aba4c5

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,14 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tinymoe2m.BF16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ tinymoe2m.F16.gguf filter=lfs diff=lfs merge=lfs -text
38
+ tinymoe2m.F32.gguf filter=lfs diff=lfs merge=lfs -text
39
+ tinymoe2m.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
40
+ tinymoe2m.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
41
+ tinymoe2m.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
42
+ tinymoe2m.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
43
+ tinymoe2m.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
44
+ tinymoe2m.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
45
+ tinymoe2m.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
46
+ tinymoe2m.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: mistralai/Mixtral-8x7B-v0.1
4
+ tags:
5
+ - mixtral
6
+ - moe
7
+ - gguf
8
+ - safetensors
9
+ - transformers
10
+ - validation
11
+ - test-suite
12
+ ---
13
+
14
+ # TinyStories Mixtral 2M Top-2 MoE (tinymoe2m) GGUF & HF Validation Suite
15
+
16
+ This repository provides an ultra-lightweight Mixtral model variant (a Mixture-of-Experts architecture utilizing the Llama 2 compute topology) scaled down to a **1.95M total parameter footprint** and a **1.14M active parameter execution frame**. It is trained on the TinyStories dataset and optimized as a precise validation asset.
17
+
18
+ It is designed specifically for debugging custom inference engines, and native tensor compilers against MoE-specific runtime features. These include Gating network weight allocation, token distribution/gathering (Scatter/Gather loops), and the weighted addition combining multiple independent expert outputs.
19
+
20
+ ---
21
+
22
+ ## 📊 Comparison: `tinymoe2m` vs Other 1M Variants
23
+
24
+ To help track feature coverage across the 1M/2M verification suite, the core structural layouts are outlined below:
25
+
26
+ | Feature / Metric | `tiny1m` (Standard) | `tinybpe1m` (BPE Variant) | `tinygemma1m` (Gemma 2 Variant) | `tinymoe2m` (This Repository) |
27
+ | :--- | :--- | :--- | :--- | :--- |
28
+ | **Base Architecture** | Llama 2 | Llama 2 | Gemma 2 | **Llama 2 (Mixtral Format)** |
29
+ | **FFN Structure** | Single FFN (Dense) | Single FFN (Dense) | Single FFN (Dense) | **Mixture-of-Experts (MoE)** |
30
+ | **Attention Mechanism** | MHA (Multi-Head) | MHA (Multi-Head) | GQA (Grouped-Query) | **MHA (Multi-Head)** |
31
+ | **Total Experts** | 1 (Non-MoE) | 1 (Non-MoE) | 1 (Non-MoE) | **4 Experts** |
32
+ | **Selected Experts** | - | - | - | **Top-2 Experts** |
33
+ | **Expert FFN Dim (`intermediate_size`)** | 564 | 352 | 352 | **352** (Shared across all experts) |
34
+ | **Total Parameters** | ~1.2M | ~1.0M | ~1.0M | **~1.95M (1.95M Total)** |
35
+ | **Active Parameters** | ~1.2M | ~1.0M | ~1.0M | **~1.14M (1.14M Active)** |
36
+ | **Primary Debug Target** | Core matrix mult & layout | `byte_fallback` decode | Gemma 2 advanced graph | **Dynamic Routing & Scatter/Gather** |
37
+
38
+ ### 💡 Compute Cost vs Capacity Optimization
39
+ With a total parameter count of approximately 1.95M, this model retains roughly twice the absolute capacity of standard 1M dense variants, allowing it to maintain a stable command of grammar rules and coherent phrasings from the TinyStories corpus. Crucially, because only the top-2 experts fire per token, the active parameter execution count is capped at ~1.14M.
40
+ This layout perfectly replicates the fundamental benefit of MoE architectures: expanding a model's total internal capacity by 2x while restricting the added floating-point operation (FLOPs) overhead to just a 1.1x–1.2x increase compared to a 1M dense counterpart.
41
+
42
+ ---
43
+
44
+ ## 📂 Repository Structure & File Descriptions
45
+
46
+ ### 1. GGUF Formats (Root Directory `./`)
47
+ Binary files optimized for execution via `llama.cpp` or compatible lower-level inference engines. Upstream parsers will automatically recognize this architecture under the `mixed` (Mixtral) type descriptor.
48
+
49
+ | Filename | Type | Size | Target / Validation Focus |
50
+ | :--- | :--- | :--- | :--- |
51
+ | **`tinymoe2m.F32.gguf`** | `F32` | ~8.0 MB | **Baseline Test.** Eliminates quantization noise to isolate and verify the raw probability mathematics of the Gating network and expert tensor synthesis. |
52
+ | **`tinymoe2m.F16.gguf`**<br>**`tinymoe2m.BF16.gguf`** | `F16`<br>`BF16` | ~4.0 MB | **Half-Precision Test.** Evaluates 16-bit floating-point unpacking routines and stability under parallelized accumulation layers. |
53
+ | **`tinymoe2m.Q8_0.gguf`** | `Q8_0` | ~2.2 MB | **Standard Quantization.** Verifies block-based uniform scaling (32-element blocks) across decentralized MoE structures. |
54
+ | **`tinymoe2m.Q4_0.gguf`**<br>**`tinymoe2m.Q4_1.gguf`** | `Q4_0`<br>`Q4_1` | ~1.4 MB | **Classic Quantization.** Tests 4-bit linear scaling and unpacking logic across multiple discontinuous expert weight matrices. |
55
+ | **`tinymoe2m.Q2_K.gguf`** | `Q2_K` | ~1.1 MB | **Standard K-Quant (2-bit).** Evaluates mixed super-block dequantization loops feeding sparse FFN routines. |
56
+ | **`tinymoe2m.Q3_K_M.gguf`** | `Q3_K_M` | ~1.2 MB | **Standard K-Quant (3-bit).** Tests sub-variant multi-block layouts handling dynamic routing vectors. |
57
+ | **`tinymoe2m.Q4_K_M.gguf`** | `Q4_K_M` | ~1.4 MB | **Standard K-Quant (4-bit).** The baseline testing target for modern 4-bit super-block logic coupled with MoE paths. |
58
+ | **`tinymoe2m.Q5_K_M.gguf`** | `Q5_K_M` | ~1.5 MB | **Standard K-Quant (5-bit).** Validates high-fidelity mixed 5-bit precision layouts. |
59
+ | **`tinymoe2m.Q6_K.gguf`** | `Q6_K` | ~1.7 MB | **Standard K-Quant (6-bit).** Validates 6-bit high-fidelity super-block dequantization. |
60
+
61
+ ### 2. Hugging Face Native Format (`./hf/`)
62
+ Unquantized components formatted for direct instantiation inside the PyTorch `transformers` library ecosystem:
63
+ * **`hf/model.safetensors`**: Raw unquantized matrix parameters containing all 4 expert sub-networks alongside the master router tensor.
64
+ * **`hf/config.json`**: Architectural specifications built around `MixtralConfig` criteria (layer depth, head maps, absolute expert counts, and top-k selection targets).
65
+ * **`hf/generation_config.json`**: Standard generation defaults.
66
+ * **`hf/tokenizer.model`**: The custom 512-vocabulary size SentencePiece BPE master binary.
67
+ * **`hf/tokenizer_config.json`**: Metadata linking `LlamaTokenizer` classes to guarantee correct handling of prefix spacing and manage automatic `<s>` (BOS) injection properly on the Hugging Face backend.
68
+ * **`hf/special_tokens_map.json`**: Structural map linking token strings (`<s>`=1, `</s>`=2) back to internal index bounds.
69
+
70
+ ---
71
+
72
+ ## 🚀 Usage Examples
73
+
74
+ ### A. Running GGUF via llama.cpp
75
+ To process the MoE execution graph and evaluate dynamic expert routing directly on your shell:
76
+ ```bash
77
+ ./llama-cli -m tinymoe2m.Q4_K_M.gguf -p "Tom and Jerry are " -n 64 --temp 0.0
78
+
79
+ ```
80
+
81
+ ### B. Loading Hugging Face Formats via Python
82
+
83
+ Because the configuration parameters are seamlessly matched with the custom vocabulary schema, you can invoke the classes using standard automated loaders without building proprietary wrapper systems.
84
+
85
+ ```python
86
+ import torch
87
+ from transformers import AutoTokenizer, AutoModelForCausalLM
88
+
89
+ repo_id = "shibatch/tinymoe2m"
90
+
91
+ print("Loading MoE configuration and tokenizer layers...")
92
+ tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="hf")
93
+ model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="hf")
94
+
95
+ device = "cuda" if torch.cuda.is_available() else "cpu"
96
+ model = model.to(device)
97
+ model.eval()
98
+
99
+ prompt = "Tom and Jerry are "
100
+ inputs = tokenizer(prompt, return_tensors="pt").to(device)
101
+
102
+ print("Running inference loop (Validating Top-2 sparse routing matrices)...")
103
+ with torch.no_grad():
104
+ outputs = model.generate(
105
+ **inputs,
106
+ max_length=64,
107
+ do_sample=False
108
+ )
109
+
110
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
111
+
112
+ print("\n--- Inference Test Result ---")
113
+ print("Prompt :", prompt)
114
+ print("Generated:", generated_text)
115
+
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 📝 Model Specifications
121
+
122
+ * **Architecture:** Mixtral (`MixtralForCausalLM`)
123
+ * **Dataset:** TinyStories
124
+ * **Total Parameters (`num_local_experts` = 4):** ~1.95M
125
+ * **Active Parameters (`num_experts_per_tok` = 2):** ~1.14M
126
+ * **Vocabulary Size (`vocab_size`):** 512 (Custom SentencePiece BPE with `byte_fallback` enabled)
127
+ * **Hidden Size (`hidden_size`):** 128
128
+ * **Number of Hidden Layers (`num_hidden_layers`):** 3
129
+ * **Number of Attention Heads (`num_heads` / `num_kv_heads`):** 2 / 2 *(MHA layout)*
130
+ * **Individual Expert Internal Dimension (`intermediate_size`):** 352 *(SwiGLU structure)*
131
+ * **Max Position Embeddings (`max_position_embeddings`):** 256
132
+
133
+ ## 📜 License
134
+
135
+ * **License:** **MIT License**. You are completely free to duplicate, modify, distribute, and utilize these assets across any commercial, personal, or educational environments.
hf/config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MixtralForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 1,
7
+ "dtype": "float32",
8
+ "eos_token_id": 2,
9
+ "head_dim": null,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 128,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 352,
14
+ "max_position_embeddings": 256,
15
+ "model_type": "mixtral",
16
+ "num_attention_heads": 2,
17
+ "num_experts_per_tok": 2,
18
+ "num_hidden_layers": 3,
19
+ "num_key_value_heads": 2,
20
+ "num_local_experts": 4,
21
+ "output_router_logits": false,
22
+ "pad_token_id": 2,
23
+ "rms_norm_eps": 1e-05,
24
+ "rope_parameters": {
25
+ "rope_theta": 1000000.0,
26
+ "rope_type": "default"
27
+ },
28
+ "router_aux_loss_coef": 0.001,
29
+ "router_jitter_noise": 0.0,
30
+ "sliding_window": null,
31
+ "tie_word_embeddings": false,
32
+ "transformers_version": "5.9.0",
33
+ "use_cache": false,
34
+ "vocab_size": 512
35
+ }
hf/generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 2,
8
+ "transformers_version": "5.9.0",
9
+ "use_cache": true
10
+ }
hf/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:639f23e32fe1d96d3c3608b707446efec64487051b806b761d09dc3950896134
3
+ size 7815432
hf/special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "pad_token": "</s>",
5
+ "unk_token": "<unk>"
6
+ }
hf/tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35a43faf8c59184ca3109ef09ed7b6336ac047baea19032a669d037a793eeb6e
3
+ size 247523
hf/tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "bos_token": "<s>",
5
+ "eos_token": "</s>",
6
+ "model_max_length": 256,
7
+ "pad_token": "</s>",
8
+ "tokenizer_class": "LlamaTokenizer",
9
+ "unk_token": "<unk>"
10
+ }
tinymoe2m.BF16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b18ff85f62de21fc0c2eb68bb31378d3663d5f662eda1f1989349a06b322144
3
+ size 3922752
tinymoe2m.F16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b329df06e638d7c996df9f287d1f7d9903327623efc531c6a78e6486073188f1
3
+ size 3922752
tinymoe2m.F32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f2ccb48ce78dde41d14dca96712c3df606ba75a44b05e70e3b032ff425ef49a
3
+ size 7822144
tinymoe2m.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c11b1b881ead0c2f7fdaf0a191ce4cc3d0159f2c809624408a2ac9b7a94c2ed
3
+ size 1152832
tinymoe2m.Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b431a6e950a4db6218955d1872f3aaf9abf23bd8c0466288328f8b9f23dfd6a
3
+ size 1234752
tinymoe2m.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89803d18cdbafe4432fbdc136b1adacedea5708e8f6381b2bcd9c026b08d8c4f
3
+ size 1152832
tinymoe2m.Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7881d326d3649e087ec56b4de9505c57c2be085e6ac0270027d915770f8bde1
3
+ size 1270592
tinymoe2m.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb6c40f54d12edf5b6ec546d2023dff3d232a09d81e5c1540acc5467d8f9f608
3
+ size 1462080
tinymoe2m.Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45ac88cee0b4cf9ad26859f480457d4e30cf06eae337ea75d7f3ef0eecec7301
3
+ size 1567552
tinymoe2m.Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d195dda47ae604ffd13e9c88112e90b5273951e65b256e482a277dcf89a25bcb
3
+ size 2094912
tinymoe2m.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9eaeba40359bb03252a478076217e93fd55ef0ca7460ae179b135fcd4474b307
3
+ size 2094912