Text Generation
Transformers
Safetensors
English
moeloop
looptitan
mixture-of-experts
Mixture of Experts
custom_code
muon
conversational
Eval Results (legacy)
Instructions to use NaturalScale/LoopTitan-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-1.3B-A0.2B-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaturalScale/LoopTitan-MoE12-FineExperts-1.3B-A0.2B-Muon
- SGLang
How to use NaturalScale/LoopTitan-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-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-MoE12-FineExperts-1.3B-A0.2B-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaturalScale/LoopTitan-MoE12-FineExperts-1.3B-A0.2B-Muon with Docker Model Runner:
docker model run hf.co/NaturalScale/LoopTitan-MoE12-FineExperts-1.3B-A0.2B-Muon
File size: 4,043 Bytes
5087312 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | """Exact, inference-only KV storage indexed by logical attention calls."""
from __future__ import annotations
from dataclasses import dataclass, field
import torch
from torch import Tensor
CacheSlot = tuple[str, int, int]
@dataclass
class DecodeCache:
"""Fixed-depth KV cache. Shared attention weights still have separate slots.
``length`` counts stored columns (including padding), while ``valid_mask``
and ``positions`` retain each row's valid-token and RoPE metadata. Use
:meth:`reorder` for beam/batch reordering; never reorder slots individually.
During a forward every attention call appends to its slot; ``advance`` then
records the forward's columns. A forward that raises midway leaves some
slots longer than ``length``, and the next forward on this cache fails, so
``clear`` it or start a new cache.
"""
num_visits: int
length: int = field(default=0, init=False)
slots: dict[CacheSlot, tuple[Tensor, Tensor]] = field(default_factory=dict, init=False)
positions: Tensor | None = field(default=None, init=False)
valid_mask: Tensor | None = field(default=None, init=False)
def next_positions(self, valid_mask: Tensor) -> Tensor:
"""Standard padding-aware positions for the new query columns."""
offset = valid_mask.new_zeros((valid_mask.size(0), 1), dtype=torch.long)
if self.valid_mask is not None:
if self.valid_mask.size(0) != valid_mask.size(0):
raise ValueError("cache batch size changed without reorder")
columns = torch.arange(self.length, device=self.valid_mask.device)
last = torch.where(self.valid_mask, columns, -1).amax(-1, keepdim=True)
offset = self.positions.gather(1, last.clamp_min(0)) + 1
offset = torch.where(last >= 0, offset, 0)
positions = offset + valid_mask.long().cumsum(-1) - 1
return positions.clamp_min(0)
def append(self, slot: CacheSlot, key: Tensor, value: Tensor) -> tuple[Tensor, Tensor]:
"""Append this forward's [batch, kv_heads, tokens, head_dim] K/V; return the slot's whole K/V."""
if slot in self.slots:
old_key, old_value = self.slots[slot]
key, value = torch.cat((old_key, key), dim=-2), torch.cat((old_value, value), dim=-2)
self.slots[slot] = (key, value)
return key, value
def advance(self, positions: Tensor, valid_mask: Tensor, expected_slots: tuple[CacheSlot, ...]) -> None:
"""Record a finished forward's columns; every expected slot must hold all of them."""
if self.positions is not None:
positions = torch.cat((self.positions, positions), dim=1)
valid_mask = torch.cat((self.valid_mask, valid_mask), dim=1)
length = positions.size(1)
if set(self.slots) != set(expected_slots) or any(key.size(-2) != length for key, _ in self.slots.values()):
raise ValueError("forward did not update every logical cache slot; "
"clear() the cache after a failed forward")
self.positions, self.valid_mask, self.length = positions, valid_mask, length
def reorder(self, indices: Tensor) -> "DecodeCache":
if indices.ndim != 1 or indices.dtype not in (torch.int32, torch.int64):
raise ValueError("cache reorder indices must be integer [new_batch]")
self.slots = {
slot: (key.index_select(0, indices.to(key.device, dtype=torch.long)),
value.index_select(0, indices.to(value.device, dtype=torch.long)))
for slot, (key, value) in self.slots.items()
}
if self.positions is not None:
self.positions = self.positions.index_select(0, indices.to(self.positions.device, dtype=torch.long))
self.valid_mask = self.valid_mask.index_select(0, indices.to(self.valid_mask.device, dtype=torch.long))
return self
def clear(self) -> None:
self.slots.clear()
self.length = 0
self.positions = self.valid_mask = None
|