Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- gpt
|
| 6 |
+
- transformer
|
| 7 |
+
- ablation-study
|
| 8 |
+
- attention
|
| 9 |
+
- rope
|
| 10 |
+
- mixture-of-experts
|
| 11 |
+
- linear-attention
|
| 12 |
+
datasets:
|
| 13 |
+
- HuggingFaceFW/fineweb-edu
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# codemindv2: SLM Attention / Position / Optimizer Ablation Study
|
| 17 |
+
|
| 18 |
+
19 small (~63M-param) GPT-style language models, each changing exactly one
|
| 19 |
+
architectural axis from a shared baseline, trained on 1B tokens of
|
| 20 |
+
[fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
|
| 21 |
+
(`sample-10BT`, GPT-2 tokenizer). Full paper, figures, and code:
|
| 22 |
+
https://github.com/<your-username>/<your-repo> (GitHub repo URL — fill in once pushed).
|
| 23 |
+
|
| 24 |
+
Every subfolder (`m01/` ... `m19/`) is one model: `model.safetensors` (weights,
|
| 25 |
+
optimizer state stripped), `config.json` (architecture + training hyperparameters),
|
| 26 |
+
`eval_results.json` (perplexity / FLOPs / throughput / VRAM), and
|
| 27 |
+
`benchmark_results.json` (zero-shot LAMBADA / HellaSwag / PIQA / SciQ / ARC-Easy /
|
| 28 |
+
WinoGrande / BLiMP via `lm-eval`).
|
| 29 |
+
|
| 30 |
+
## Models
|
| 31 |
+
|
| 32 |
+
| ID | Attention | Position | Optimizer | FFN | Val PPL |
|
| 33 |
+
|-----|-----------|----------|-----------|-------------|---------|
|
| 34 |
+
| m01 | MHA | learned | AdamW | dense | 34.08 |
|
| 35 |
+
| m02 | MHA | learned | AdamW | MoE (8/2) | 33.48 |
|
| 36 |
+
| m03 | MQA | learned | AdamW | dense | 35.40 |
|
| 37 |
+
| m04 | GQA (4:1) | learned | AdamW | dense | 34.70 |
|
| 38 |
+
| m05 | MLA | learned | AdamW | dense | 38.28 |
|
| 39 |
+
| m06 | MHA | RoPE | AdamW | dense | 31.27 |
|
| 40 |
+
| m07 | MQA | RoPE | AdamW | dense | 32.26 |
|
| 41 |
+
| m08 | GQA (4:1) | RoPE | AdamW | dense | 32.10 |
|
| 42 |
+
| m09 | MLA | RoPE | AdamW | dense | 33.84 |
|
| 43 |
+
| m10 | Diff Attn | RoPE | AdamW | dense | 30.60 |
|
| 44 |
+
| m11 | MHA | RoPE | Muon | dense | 30.54 |
|
| 45 |
+
| m12 | GQA (4:1) | RoPE | Muon | dense | 32.09 |
|
| 46 |
+
| m13 | MHA | RoPE | Muon | dense + AttnRes | 37.14 |
|
| 47 |
+
| m14 | MHA | RoPE | Muon | MoE (8/2) | 31.07 |
|
| 48 |
+
| m15 | MHA | RoPE | Muon | Shared MoE | 32.07 |
|
| 49 |
+
| m16 | MHA | RoPE | Muon | Shared MoE (fat) | 31.71 |
|
| 50 |
+
| m17 | MHA | none | AdamW | dense | 35.69 |
|
| 51 |
+
| m18 | GQA (4:1) | none | AdamW | dense | 35.97 |
|
| 52 |
+
| m19 | KDA (linear) | RoPE | Muon | dense | 33.58 |
|
| 53 |
+
|
| 54 |
+
All models: `d_model=512`, `num_layers=12`, `num_heads=8`, `block_size=1024`,
|
| 55 |
+
1B training tokens. See each `config.json` for exact hyperparameters.
|
| 56 |
+
|
| 57 |
+
**Note on perplexity:** the paper's thesis is that PPL is not a reliable proxy
|
| 58 |
+
for downstream capability across attention variants — see `benchmark_results.json`
|
| 59 |
+
per model and the paper for zero-shot accuracy, which reorders several
|
| 60 |
+
comparisons versus the PPL table above.
|
| 61 |
+
|
| 62 |
+
## Loading a model
|
| 63 |
+
|
| 64 |
+
Weights are architecture-specific (custom PyTorch, not a `transformers`
|
| 65 |
+
`AutoModel`). Clone the code repo above, then:
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
import json
|
| 69 |
+
import torch
|
| 70 |
+
from safetensors.torch import load_file
|
| 71 |
+
from models import build_model # dispatches on config["model_id"]
|
| 72 |
+
|
| 73 |
+
model_id = "m11"
|
| 74 |
+
config = json.load(open(f"{model_id}/config.json"))
|
| 75 |
+
state_dict = load_file(f"{model_id}/model.safetensors")
|
| 76 |
+
|
| 77 |
+
model = build_model(config)
|
| 78 |
+
model.load_state_dict(state_dict, strict=not config.get("tie_embeddings"))
|
| 79 |
+
model.eval()
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
`strict=False` is only needed for tied-embedding models (`lm_head.weight` was
|
| 83 |
+
dropped before saving since it's a view of `token_emb.emb.weight`; it's
|
| 84 |
+
re-materialized by `tie_embeddings` in the model's `__init__`).
|
| 85 |
+
|
| 86 |
+
M19 has no KV-cache path (`supports_kv_cache = False`) — its attention operator
|
| 87 |
+
(KDA, a linear-attention recurrence) carries a fixed-size state rather than a
|
| 88 |
+
growing K/V tensor, so `inference_tok_per_sec_kvcache` is `null` in its
|
| 89 |
+
`eval_results.json` and its `inference_tok_per_sec` (full re-forward) is not
|
| 90 |
+
comparable to the other models' cached numbers.
|
| 91 |
+
|
| 92 |
+
## Citation
|
| 93 |
+
|
| 94 |
+
See the paper (`paper/main.pdf` in the code repo) for the full ablation
|
| 95 |
+
methodology, comparison pairs, and analysis.
|