model_017517.pt # Model weights
meta_017517.json # Training config and metadata
optim_017517_rank*.pt # Optimizer state shards (for resuming training)
tokenizer/ # BPE tokenizer (tiktoken format) + token byte counts
nanochat/ # Source code to load and run the model
Quick Start
python
1import torch
2from nanochat.gpt import GPT, GPTConfig
3from nanochat.tokenizer import RustBPETokenizer
45# Load tokenizer6tokenizer = RustBPETokenizer.from_directory("tokenizer")78# Load model9import json
10withopen("meta_017517.json")as f:11 meta = json.load(f)1213config = GPTConfig(**meta["model_config"])1415with torch.device("meta"):16 model = GPT(config)17model.to_empty(device="cuda")18model.init_weights()1920state_dict = torch.load("model_017517.pt", map_location="cuda")21state_dict ={k.removeprefix("_orig_mod."): v for k, v in state_dict.items()}22model.load_state_dict(state_dict, strict=True, assign=True)23model.eval()2425# Generate26bos = tokenizer.get_bos_token_id()27tokens = tokenizer.encode("It was a dark and stormy night", prepend=bos)28with torch.amp.autocast(device_type="cuda", dtype=torch.bfloat16):29for token in model.generate(tokens, max_tokens=100, temperature=0.8):30print(tokenizer.decode([token]), end="", flush=True)
Dependencies
torch>=2.9
tiktoken
rustbpe
Training
Trained with the nanochat framework on H100 GPUs.
To resume training, load the optimizer shards (optim_017517_rank*.pt) — one per rank.