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
muon
conversational
Eval Results (legacy)
Instructions to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon 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-Muon 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-Muon", 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-Muon", 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-Muon 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-Muon" # 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-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon
- SGLang
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon 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-Muon" \ --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-Muon", "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-Muon" \ --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-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon with Docker Model Runner:
docker model run hf.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon
Download latent.py from NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon: direct link, hf CLI and curl.
- Browser
- Download file 2.95 kB
-
https://huggingface.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon/resolve/main/latent.py
- Command line
-
hf download hf://NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon/latent.py
-
curl -L -o latent.py https://huggingface.co/NaturalScale/LoopTitan-Looped-1.3B-A0.2B-Muon/resolve/main/latent.py
2.95 kB
| """Independent latent initialization and stateless microbatch depth sampling.""" | |
| from __future__ import annotations | |
| import hashlib | |
| import math | |
| import torch | |
| from torch import Tensor, nn | |
| def initial_latent( | |
| anchor: Tensor, *, training: bool, std: float = math.sqrt(2 / 5), | |
| truncation: float = 3.0, | |
| ) -> Tensor: | |
| """Draw an independent training state; evaluation explicitly starts at zero. | |
| Training uses the device's global Torch RNG, which the trainer checkpoints. | |
| ``std`` describes the normal before truncation, not the resulting variance. | |
| Neither branch creates a gradient path from the initial state to the anchor. | |
| The live anchor must still be passed separately to the recurrent update. | |
| Precondition: finite positive ``std`` and ``truncation``; ``ModelConfig`` | |
| enforces this for ``latent_init_std`` and ``latent_truncation``. | |
| """ | |
| if not isinstance(anchor, Tensor) or not anchor.is_floating_point(): | |
| raise ValueError("initial latent needs a floating-point anchor tensor") | |
| if type(training) is not bool: | |
| raise ValueError("training must be bool") | |
| if not training: | |
| return torch.zeros_like(anchor) | |
| return nn.init.trunc_normal_(torch.empty_like(anchor), mean=0.0, std=std, | |
| a=-truncation * std, b=truncation * std) | |
| def sampled_depth( | |
| *, seed: int, completed_updates: int, microbatch: int, | |
| mean: float = 4.0, log_std: float = 0.5, | |
| ) -> int: | |
| """Sample ``1 + Poisson(LogNormal)`` with the requested expected depth. | |
| The coordinate, rather than a rank's mutable RNG, determines the draw. All | |
| ranks using the same recipe/update/microbatch therefore agree, including | |
| after restoration. No upper depth cap or reconstructed global RNG is used. | |
| Precondition: finite ``mean`` > 1 and finite ``log_std`` >= 0; | |
| ``TrainingRecipe`` enforces this for ``depth_mean`` and ``depth_log_std``. | |
| """ | |
| if type(seed) is not int: | |
| raise ValueError("depth seed must be an integer") | |
| for name, value in (("completed_updates", completed_updates), ("microbatch", microbatch)): | |
| if type(value) is not int or value < 0: | |
| raise ValueError(f"{name} must be a nonnegative integer") | |
| location = math.log(mean - 1) - 0.5 * log_std * log_std | |
| if not math.isfinite(location): | |
| raise ValueError("lognormal depth location must be finite") | |
| key = f"poisson_lognormal_micro_v1:{seed}:{completed_updates}:{microbatch}".encode() | |
| local_seed = int.from_bytes(hashlib.sha256(key).digest()[:8], "big") | |
| generator = torch.Generator(device="cpu").manual_seed(local_seed) | |
| epsilon = torch.randn((), dtype=torch.float64, generator=generator) | |
| rate = torch.exp(location + log_std * epsilon) | |
| if not torch.isfinite(rate).item(): | |
| raise ValueError("sampled depth rate overflowed; change the declared distribution") | |
| return 1 + int(torch.poisson(rate, generator=generator).item()) | |