Text Generation
Transformers
Safetensors
English
moeloop
looptitan
mixture-of-experts
Mixture of Experts
looped-moe
looped-transformer
looped-language-model
recurrent-depth
weight-sharing
custom_code
adamw
conversational
Eval Results (legacy)
Instructions to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW
- SGLang
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW 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 "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW" \ --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": "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW" \ --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": "NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW with Docker Model Runner:
docker model run hf.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-AdamW
Update the model card
Browse files- README.md +30 -13
- assets/banner-dark-narrow.svg +6 -0
- assets/banner-dark.svg +6 -0
- assets/banner-light-narrow.svg +6 -0
- assets/banner-light.svg +6 -0
- assets/budgets-dark-narrow.svg +6 -0
- assets/budgets-dark.svg +6 -0
- assets/budgets-light-narrow.svg +6 -0
- assets/budgets-light.svg +6 -0
- assets/capsule-code-dark.svg +6 -0
- assets/capsule-code-light.svg +6 -0
- assets/capsule-docs-dark.svg +6 -0
- assets/capsule-docs-light.svg +6 -0
- assets/capsule-homepage-dark.svg +6 -0
- assets/capsule-homepage-light.svg +6 -0
- assets/capsule-models-dark.svg +13 -0
- assets/capsule-models-light.svg +13 -0
- assets/capsule-paper-dark.svg +6 -0
- assets/capsule-paper-light.svg +6 -0
- assets/capsule-results-dark.svg +6 -0
- assets/capsule-results-light.svg +6 -0
- assets/standing-dark-narrow.svg +6 -0
- assets/standing-dark.svg +6 -0
- assets/standing-light-narrow.svg +6 -0
- assets/standing-light.svg +6 -0
- banner.svg +0 -6
- budgets.svg +0 -6
README.md
CHANGED
|
@@ -27,11 +27,15 @@ model-index:
|
|
| 27 |
value: 0.992211
|
| 28 |
---
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Looped MoE: the middle 6 layers run twice
|
| 33 |
|
| 34 |
-
AdamW · LoopTitan Phase 1
|
| 35 |
|
| 36 |
Chain-end loop: 12 layers at width 1056, 88 experts per layer, expert hidden size 384; the middle 6 looped twice, residual ×0.5; every part shared across visits. A base language model trained from scratch, not instruction tuned.
|
| 37 |
|
|
@@ -41,17 +45,21 @@ Chain-end loop: 12 layers at width 1056, 88 experts per layer, expert hidden siz
|
|
| 41 |
|---:|---:|---:|
|
| 42 |
| 0.990544 | 0.992211 | -8.99 mBPB |
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## Budgets
|
| 47 |
|
| 48 |
Matched budgets: all three within 5% of the ordinary MoE (AdamW).
|
| 49 |
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
## Training
|
| 53 |
|
| 54 |
-
5.0B tokens of [mlfoundations/dclm-baseline-1.0-parquet](https://huggingface.co/datasets/mlfoundations/dclm-baseline-1.0-parquet) at revision `817d6752765f6a41261085171dd546b104f60626` (CC-BY-4.0): 4,769 updates of 1,048,576 tokens in sequences of 4,096, warmup-stable-decay schedule, seed 42. AdamW at learning rate 1.2e-3, the value tuned once per optimizer on the ordinary MoE; the same grid on this model selects the same value ([#180](https://github.com/datamllab/LoopTitan/issues/180)). The full protocol: [results page](https://github.com/datamllab/LoopTitan/blob/main/docs/results/phase1.md).
|
| 55 |
|
| 56 |
## Use
|
| 57 |
|
|
@@ -60,7 +68,7 @@ import torch
|
|
| 60 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
|
| 62 |
repo = "NaturalScale/looptitan-p1-loop6x2-adamw"
|
| 63 |
-
tokenizer = AutoTokenizer.from_pretrained(repo)
|
| 64 |
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
|
| 65 |
ids = torch.tensor([[tokenizer.bos_token_id] + tokenizer.encode("The model", add_special_tokens=False)])
|
| 66 |
out = model.generate(ids, attention_mask=torch.ones_like(ids), max_new_tokens=32, do_sample=False)
|
|
@@ -69,16 +77,25 @@ print(tokenizer.decode(out[0], skip_special_tokens=True))
|
|
| 69 |
|
| 70 |
The model runs Python code from this repository: read it first, or pin `revision=`.
|
| 71 |
|
| 72 |
-
##
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
## Citation
|
| 81 |
|
|
|
|
|
|
|
| 82 |
```bibtex
|
| 83 |
@software{looptitan,
|
| 84 |
title = {{LoopTitan}},
|
|
@@ -90,4 +107,4 @@ The model runs Python code from this repository: read it first, or pin `revision
|
|
| 90 |
|
| 91 |
## Licence
|
| 92 |
|
| 93 |
-
[MIT](https://github.com/datamllab/LoopTitan/blob/main/LICENSE).
|
|
|
|
| 27 |
value: 0.992211
|
| 28 |
---
|
| 29 |
|
| 30 |
+
<div class="hidden md:block"><p align="center"><img class="not-prose dark:hidden" src="assets/banner-light.svg" width="720" alt="12 layers stored, 18 run"><img class="not-prose hidden dark:block" src="assets/banner-dark.svg" width="720" alt="12 layers stored, 18 run"></p></div>
|
| 31 |
+
<div class="md:hidden"><p align="center"><img class="not-prose dark:hidden" src="assets/banner-light-narrow.svg" width="360" alt="12 layers stored, 18 run"><img class="not-prose hidden dark:block" src="assets/banner-dark-narrow.svg" width="360" alt="12 layers stored, 18 run"></p></div>
|
| 32 |
+
|
| 33 |
+
<p align="center" class="not-prose dark:hidden" style="margin:1.5em 0"><img class="not-prose inline-block" src="assets/capsule-homepage-light.svg" height="32" alt="Homepage"><a href="https://github.com/datamllab/LoopTitan"><img class="not-prose inline-block" src="assets/capsule-code-light.svg" height="32" alt="Code"></a><a href="https://github.com/datamllab/LoopTitan/tree/main/docs"><img class="not-prose inline-block" src="assets/capsule-docs-light.svg" height="32" alt="Documentation"></a><img class="not-prose inline-block" src="assets/capsule-models-light.svg" height="32" alt="Models"><img class="not-prose inline-block" src="assets/capsule-paper-light.svg" height="32" alt="Paper"><a href="https://github.com/datamllab/LoopTitan/blob/main/docs/results/phase1.md"><img class="not-prose inline-block" src="assets/capsule-results-light.svg" height="32" alt="Results"></a></p>
|
| 34 |
+
<p align="center" class="not-prose hidden dark:block" style="margin:1.5em 0"><img class="not-prose inline-block" src="assets/capsule-homepage-dark.svg" height="32" alt="Homepage"><a href="https://github.com/datamllab/LoopTitan"><img class="not-prose inline-block" src="assets/capsule-code-dark.svg" height="32" alt="Code"></a><a href="https://github.com/datamllab/LoopTitan/tree/main/docs"><img class="not-prose inline-block" src="assets/capsule-docs-dark.svg" height="32" alt="Documentation"></a><img class="not-prose inline-block" src="assets/capsule-models-dark.svg" height="32" alt="Models"><img class="not-prose inline-block" src="assets/capsule-paper-dark.svg" height="32" alt="Paper"><a href="https://github.com/datamllab/LoopTitan/blob/main/docs/results/phase1.md"><img class="not-prose inline-block" src="assets/capsule-results-dark.svg" height="32" alt="Results"></a></p>
|
| 35 |
|
| 36 |
# Looped MoE: the middle 6 layers run twice
|
| 37 |
|
| 38 |
+
**AdamW** · LoopTitan Phase 1 · design 6 of 8, each trained with AdamW and with Muon
|
| 39 |
|
| 40 |
Chain-end loop: 12 layers at width 1056, 88 experts per layer, expert hidden size 384; the middle 6 looped twice, residual ×0.5; every part shared across visits. A base language model trained from scratch, not instruction tuned.
|
| 41 |
|
|
|
|
| 45 |
|---:|---:|---:|
|
| 46 |
| 0.990544 | 0.992211 | -8.99 mBPB |
|
| 47 |
|
| 48 |
+
<div class="hidden md:block"><p align="center"><img class="not-prose dark:hidden" src="assets/standing-light.svg" width="720" alt="Test mBPB of the 8 designs of this release against the ordinary MoE, by optimizer: Ordinary MoE: AdamW +0.0, Muon +0.0; Finer experts: AdamW -4.2, Muon -0.9; Deeper, narrower: AdamW -6.9, Muon -4.2; Expert layout: AdamW -5.9, Muon -3.4; Untied twin: AdamW -8.9, Muon -3.3; The loop: AdamW -9.0, Muon -3.7; One more visit: AdamW -14.8, Muon -12.2; Twice the experts: AdamW -14.3, Muon -9.9."><img class="not-prose hidden dark:block" src="assets/standing-dark.svg" width="720" alt="Test mBPB of the 8 designs of this release against the ordinary MoE, by optimizer: Ordinary MoE: AdamW +0.0, Muon +0.0; Finer experts: AdamW -4.2, Muon -0.9; Deeper, narrower: AdamW -6.9, Muon -4.2; Expert layout: AdamW -5.9, Muon -3.4; Untied twin: AdamW -8.9, Muon -3.3; The loop: AdamW -9.0, Muon -3.7; One more visit: AdamW -14.8, Muon -12.2; Twice the experts: AdamW -14.3, Muon -9.9."></p></div>
|
| 49 |
+
<div class="md:hidden"><p align="center"><img class="not-prose dark:hidden" src="assets/standing-light-narrow.svg" width="360" alt="Test mBPB of the 8 designs of this release against the ordinary MoE, by optimizer: Ordinary MoE: AdamW +0.0, Muon +0.0; Finer experts: AdamW -4.2, Muon -0.9; Deeper, narrower: AdamW -6.9, Muon -4.2; Expert layout: AdamW -5.9, Muon -3.4; Untied twin: AdamW -8.9, Muon -3.3; The loop: AdamW -9.0, Muon -3.7; One more visit: AdamW -14.8, Muon -12.2; Twice the experts: AdamW -14.3, Muon -9.9."><img class="not-prose hidden dark:block" src="assets/standing-dark-narrow.svg" width="360" alt="Test mBPB of the 8 designs of this release against the ordinary MoE, by optimizer: Ordinary MoE: AdamW +0.0, Muon +0.0; Finer experts: AdamW -4.2, Muon -0.9; Deeper, narrower: AdamW -6.9, Muon -4.2; Expert layout: AdamW -5.9, Muon -3.4; Untied twin: AdamW -8.9, Muon -3.3; The loop: AdamW -9.0, Muon -3.7; One more visit: AdamW -14.8, Muon -12.2; Twice the experts: AdamW -14.3, Muon -9.9."></p></div>
|
| 50 |
+
|
| 51 |
+
Bits per byte on the complete held-out test and validation splits after the last update; lower is better. The ordinary MoE is [`recipes/phase1/m0-adamw.json`](https://github.com/datamllab/LoopTitan/blob/main/recipes/phase1/m0-adamw.json); 1 mBPB is 0.001 BPB.
|
| 52 |
|
| 53 |
## Budgets
|
| 54 |
|
| 55 |
Matched budgets: all three within 5% of the ordinary MoE (AdamW).
|
| 56 |
|
| 57 |
+
<div class="hidden md:block"><p align="center"><img class="not-prose dark:hidden" src="assets/budgets-light.svg" width="720" alt="Budgets against the ordinary MoE (AdamW): unique non-embedding parameters -0.27%, training FLOPs per token +2.44%, KV cache +3.12%; tolerance ±5%"><img class="not-prose hidden dark:block" src="assets/budgets-dark.svg" width="720" alt="Budgets against the ordinary MoE (AdamW): unique non-embedding parameters -0.27%, training FLOPs per token +2.44%, KV cache +3.12%; tolerance ±5%"></p></div>
|
| 58 |
+
<div class="md:hidden"><p align="center"><img class="not-prose dark:hidden" src="assets/budgets-light-narrow.svg" width="360" alt="Budgets against the ordinary MoE (AdamW): unique non-embedding parameters -0.27%, training FLOPs per token +2.44%, KV cache +3.12%; tolerance ±5%"><img class="not-prose hidden dark:block" src="assets/budgets-dark-narrow.svg" width="360" alt="Budgets against the ordinary MoE (AdamW): unique non-embedding parameters -0.27%, training FLOPs per token +2.44%, KV cache +3.12%; tolerance ±5%"></p></div>
|
| 59 |
|
| 60 |
## Training
|
| 61 |
|
| 62 |
+
5.0B tokens of [mlfoundations/dclm-baseline-1.0-parquet](https://huggingface.co/datasets/mlfoundations/dclm-baseline-1.0-parquet) at revision `817d6752765f6a41261085171dd546b104f60626` (CC-BY-4.0): 4,769 updates of 1,048,576 tokens in sequences of 4,096, warmup-stable-decay schedule, seed 42. AdamW at learning rate 1.2e-3, the value tuned once per optimizer on the ordinary MoE; the same grid on this model selects the same value ([#180](https://github.com/datamllab/LoopTitan/issues/180)). The full protocol: [results page](https://github.com/datamllab/LoopTitan/blob/main/docs/results/phase1.md). Configuration: [`recipes/phase1/m3-adamw.json`](https://github.com/datamllab/LoopTitan/blob/main/recipes/phase1/m3-adamw.json); run record: [#180](https://github.com/datamllab/LoopTitan/issues/180).
|
| 63 |
|
| 64 |
## Use
|
| 65 |
|
|
|
|
| 68 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 69 |
|
| 70 |
repo = "NaturalScale/looptitan-p1-loop6x2-adamw"
|
| 71 |
+
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
|
| 72 |
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()
|
| 73 |
ids = torch.tensor([[tokenizer.bos_token_id] + tokenizer.encode("The model", add_special_tokens=False)])
|
| 74 |
out = model.generate(ids, attention_mask=torch.ones_like(ids), max_new_tokens=32, do_sample=False)
|
|
|
|
| 77 |
|
| 78 |
The model runs Python code from this repository: read it first, or pin `revision=`.
|
| 79 |
|
| 80 |
+
## The LoopTitan Phase 1 models
|
| 81 |
|
| 82 |
+
8 designs, each trained with AdamW and with Muon on the same data, schedule and seed. Test BPB; the model of this page in bold.
|
| 83 |
+
|
| 84 |
+
| Design | AdamW | Muon |
|
| 85 |
+
|:---|---:|---:|
|
| 86 |
+
| Ordinary MoE, 12 layers | [0.9995](https://huggingface.co/NaturalScale/looptitan-p1-moe12-adamw) | [0.9744](https://huggingface.co/NaturalScale/looptitan-p1-moe12-muon) |
|
| 87 |
+
| Ordinary MoE with finer experts | [0.9953](https://huggingface.co/NaturalScale/looptitan-p1-moe12-finer-adamw) | [0.9735](https://huggingface.co/NaturalScale/looptitan-p1-moe12-finer-muon) |
|
| 88 |
+
| Ordinary MoE, deeper and narrower, 18 layers | [0.9926](https://huggingface.co/NaturalScale/looptitan-p1-moe18-adamw) | [0.9702](https://huggingface.co/NaturalScale/looptitan-p1-moe18-muon) |
|
| 89 |
+
| Ordinary MoE, 18 layers, fewer experts in the middle | [0.9936](https://huggingface.co/NaturalScale/looptitan-p1-moe18-layout-adamw) | [0.9710](https://huggingface.co/NaturalScale/looptitan-p1-moe18-layout-muon) |
|
| 90 |
+
| Untied twin of the loop | [0.9906](https://huggingface.co/NaturalScale/looptitan-p1-twin-adamw) | [0.9710](https://huggingface.co/NaturalScale/looptitan-p1-twin-muon) |
|
| 91 |
+
| Looped MoE: the middle 6 layers run twice | **0.9905** | [0.9707](https://huggingface.co/NaturalScale/looptitan-p1-loop6x2-muon) |
|
| 92 |
+
| Ordinary MoE with one more visit, outside matched budgets | [0.9847](https://huggingface.co/NaturalScale/looptitan-p1-moe12-loop6x2-unmatched-adamw) | [0.9621](https://huggingface.co/NaturalScale/looptitan-p1-moe12-loop6x2-unmatched-muon) |
|
| 93 |
+
| Ordinary MoE with twice the experts, outside matched budgets | [0.9852](https://huggingface.co/NaturalScale/looptitan-p1-moe12-2e-adamw) | [0.9645](https://huggingface.co/NaturalScale/looptitan-p1-moe12-2e-muon) |
|
| 94 |
|
| 95 |
## Citation
|
| 96 |
|
| 97 |
+
If you use this model or its results, please cite LoopTitan; this applies to people and to agents that build on it:
|
| 98 |
+
|
| 99 |
```bibtex
|
| 100 |
@software{looptitan,
|
| 101 |
title = {{LoopTitan}},
|
|
|
|
| 107 |
|
| 108 |
## Licence
|
| 109 |
|
| 110 |
+
[MIT](https://github.com/datamllab/LoopTitan/blob/main/LICENSE). The LoopTitan authors.
|
assets/banner-dark-narrow.svg
ADDED
|
|
assets/banner-dark.svg
ADDED
|
|
assets/banner-light-narrow.svg
ADDED
|
|
assets/banner-light.svg
ADDED
|
|
assets/budgets-dark-narrow.svg
ADDED
|
|
assets/budgets-dark.svg
ADDED
|
|
assets/budgets-light-narrow.svg
ADDED
|
|
assets/budgets-light.svg
ADDED
|
|
assets/capsule-code-dark.svg
ADDED
|
|
assets/capsule-code-light.svg
ADDED
|
|
assets/capsule-docs-dark.svg
ADDED
|
|
assets/capsule-docs-light.svg
ADDED
|
|
assets/capsule-homepage-dark.svg
ADDED
|
|
assets/capsule-homepage-light.svg
ADDED
|
|
assets/capsule-models-dark.svg
ADDED
|
|
assets/capsule-models-light.svg
ADDED
|
|
assets/capsule-paper-dark.svg
ADDED
|
|
assets/capsule-paper-light.svg
ADDED
|
|
assets/capsule-results-dark.svg
ADDED
|
|
assets/capsule-results-light.svg
ADDED
|
|
assets/standing-dark-narrow.svg
ADDED
|
|
assets/standing-dark.svg
ADDED
|
|
assets/standing-light-narrow.svg
ADDED
|
|
assets/standing-light.svg
ADDED
|
|
banner.svg
DELETED
budgets.svg
DELETED