gaggle-nanochat-ift-climbmix-20261031
The chat model made from
castorini/gaggle-nanochat-pretrained-climbmix-20260924
(step 227,158) with nanochat's standard two-stage chat recipe: midtraining, then supervised fine-tuning (SFT).
No RL. The midtraining checkpoint is included as well.
The same weights load three ways, with the base model's code: with transformers (trust_remote_code=True), with
vLLM (through the base model's plugin), and with nanochat's own code from the original checkpoint files.
Model
Architecture, tokenizer and code are those of the base model, unchanged; only the weights differ.
| Architecture | nanochat depth-34 decoder-only transformer: 34 layers, width 2,176, 17 attention heads of dimension 128, 2,048-token context; 3.29B parameters (1.21B of them value-embedding lookups) |
| Tokenizer | the base model's byte-level BPE, 32,768 entries |
| Chat format | nanochat's: <|bos|>, then <|user_start|>...<|user_end|> and <|assistant_start|>...<|assistant_end|> turns; a system message is merged into the first user message |
| Code | karpathy/nanochat at commit 92d63d4 |
Training
nanochat removed midtraining on 2026-01-31 (commit 1ddaad1). We ran the last two-stage version of the recipe,
nanochat commit 348fbb3 (scripts/mid_train.py, then scripts/chat_sft.py starting from the midtrained model), with its
data and hyperparameters unchanged. Its scripts were ported onto nanochat 92d63d4, the code the base model was trained
with; the port changes only APIs and reporting (no autocast, since 92d63d4 handles the compute dtype in the model; the full
model config is saved in the checkpoint metadata). Both stages start with a fresh optimizer.
Midtraining (one epoch, 816 steps of 524,288 tokens, 2,048-token sequences with BOS-aligned best-fit packing, loss on all tokens):
| Data | Rows |
|---|---|
| smol-smoltalk train | 460,341 |
MMLU auxiliary_train | 99,842 |
GSM8K main train | 7,473 |
| nanochat identity conversations, 2 epochs | 2,000 |
| SimpleSpelling | 200,000 |
| SpellingBee | 80,000 |
| Total | 849,656 |
Learning rates 0.2 (embeddings), 0.004 (unembedding), 0.02 (Muon, block matrices), no weight decay; constant for the first 80% of training, then linear decay to zero; Muon momentum 0.85 to 0.95 over the first 300 steps.
SFT (one epoch, 701 steps of 32 conversations, loss on assistant tokens only):
| Data | Rows |
|---|---|
| ARC-Easy train | 2,251 |
| ARC-Challenge train | 1,119 |
GSM8K main train | 7,473 |
| smol-smoltalk train, first 10,000 after nanochat's seed-42 shuffle | 10,000 |
| nanochat identity conversations | 1,000 |
| SimpleSpelling | 300 |
| SpellingBee | 300 |
| Total | 22,443 |
Same learning rates scaled by 0.02, decayed linearly to zero.
Neither stage replays pre-training (ClimbMix) text.
Compute: one NVIDIA H100 80GB (Fir, Digital Research Alliance of Canada). The recipe's batch sizes are kept by gradient accumulation over micro-batches of 4 sequences. Midtraining took 3 h 10 min, SFT 25 min.
Evaluation
Four models: nanochat d34 and Gaggle, each as the pre-trained base model (PT) and after nanochat's midtraining + SFT
recipe (PT + IFT). For nanochat d34 the IFT model is
pankajmathur/nanochat-d34-finetuned, which ran the same
nanochat midtraining + SFT recipe (nanochat code from December 2025) on Karpathy's checkpoint. The two PT rows are the
numbers in the Gaggle paper and on the base model's card.
The IFT rows are ours, measured with the same code for both models. nanochat d34 runs through nanochat commit f37d45c
(its architecture), Gaggle through 92d63d4.
Each model is shown in the format it was trained for:
- Few-shot, plain text (pre-trained models): MMLU and MMLU-Pro 5-shot with the LM Evaluation Harness 0.4.9 (
mmlu,leaderboard_mmlu_pro); ARC-Easy and ARC-Challenge 10-shot as in CORE (500 questions each); all scored by the log-likelihood of the answer. CORE is nanochat's average centered accuracy over 22 in-context-learning tasks (500 examples each). - Zero-shot, chat (IFT models): nanochat's
chat_evalin the chat format, on the full test sets; ARC, MMLU and MMLU-Pro by the answer letter, GSM8K and HumanEval by greedy generation (up to 512 tokens). ChatCORE is nanochat's mean centered accuracy over ARC-Easy, ARC-Challenge, MMLU, GSM8K and HumanEval. nanochat has no MMLU-Pro task; ours (code/tasks/mmlu_pro.py) is its MMLU task on MMLU-Pro's 12,032 test questions, with each question's own options lettered A to J (random guessing scores 11.1%).
| Model | Stage | Format | MMLU | MMLU-Pro | ARC-Easy | ARC-Challenge | GSM8K | HumanEval | CORE | ChatCORE |
|---|---|---|---|---|---|---|---|---|---|---|
| nanochat d34 | PT | few-shot, plain text | 25.71 | 11.49 | 73.8 | 47.0 | — | — | 0.338† | — |
| nanochat d34 | PT + IFT | zero-shot, chat | 43.06 | 17.21 | 72.14 | 54.27 | 13.65 | 11.59 | — | 0.302 |
| Gaggle | PT | few-shot, plain text | 49.27 | 17.76 | 83.4 | 59.0 | — | — | 0.458 | — |
| Gaggle | PT + IFT (this model) | zero-shot, chat | 44.93 | 19.97 | 81.57 | 68.00 | 30.63 | 15.85 | — | 0.412 |
"—" means not measured in that format: GSM8K and HumanEval are generation tasks we ran only in the chat format, and CORE
and ChatCORE each belong to one format. In the other format, the pre-trained models are at chance (chat-format MMLU
24.12 and 23.12, GSM8K 0), and the IFT models score lower with 5-shot plain-text prompts (MMLU 24.74 for nanochat d34,
36.68 for this model, whose CORE is 0.363). logs/comparison/ has our runs of both formats for all
four models; the table's PT rows use the paper's runs. † Karpathy's published CORE for nanochat d34, as in the paper and on
the base model's card.
What the comparison shows:
- Gaggle is ahead of nanochat d34 at both stages. Pre-trained: MMLU 49.3 vs 25.7, MMLU-Pro 17.8 vs 11.5, ARC-Challenge 59.0 vs 47.0, CORE 0.458 vs 0.338. After IFT: ahead on every benchmark, for example ARC-Challenge 68.0 vs 54.3, GSM8K 30.6 vs 13.7, HumanEval 15.9 vs 11.6, ChatCORE 0.412 vs 0.302.
- IFT moves the two models differently on MMLU. nanochat d34 rises from near chance (25.7) to 43.1, while Gaggle's best MMLU remains its pre-trained 5-shot score (49.3, against 44.9 after IFT). On MMLU-Pro both rise (11.5 to 17.2; 17.8 to 20.0). The format differs between the two stages.
- The two models differ in scale and data: nanochat d34 has 2.2B parameters trained on 89B tokens, Gaggle 3.3B parameters (1.21B of them value-embedding lookups) trained on 283B ClimbMix tokens.
Our nanochat d34 PT + IFT chat numbers match pankajmathur's model card to within 0.1 point on ARC and MMLU (GSM8K 13.65 vs 13.27, HumanEval 11.59 vs 10.37).
The midtraining checkpoint of this model, in the chat format:
| Model | Stage | Format | MMLU | MMLU-Pro | ARC-Easy | ARC-Challenge | GSM8K | HumanEval | CORE | ChatCORE |
|---|---|---|---|---|---|---|---|---|---|---|
| Gaggle | PT + midtraining only (step 816) | zero-shot, chat | 44.32 | 19.90 | 80.01 | 65.70 | 13.95 | 16.46 | — | 0.368 |
Validation: midtraining validation loss fell from 0.390 to 0.288 bits per byte; SFT validation loss 0.712.
Usage
Prompts must use nanochat's chat format, which the tokenizer's chat template produces exactly
(apply_chat_template(..., add_generation_prompt=True) ends with <|assistant_start|>), and replies end with
<|assistant_end|>, which is the eos token. The context is 2,048 tokens.
transformers
pip install "transformers>=4.57" "torch>=2.5"
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "castorini/gaggle-nanochat-ift-climbmix-20261031"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).to("cuda").eval()
messages = [{"role": "user", "content": "What is the capital of France?"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt",
return_dict=True).to("cuda")
out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Output on one H100 GPU:
The capital of France is Paris.
trust_remote_code=True is needed because the architecture is nanochat's; configuration_gaggle.py and
modeling_gaggle.py are the base model's files, byte for byte. The chat template already adds <|bos|>: if you render
it to a string first, tokenize that string with add_special_tokens=False, or the tokenizer adds a second <|bos|>.
vLLM
vLLM has no built-in class for this architecture, so install the base model's plugin (a copy is in this repo); vLLM then finds it automatically:
pip install vllm https://huggingface.co/castorini/gaggle-nanochat-ift-climbmix-20261031/resolve/main/vllm_gaggle-0.1.0-py3-none-any.whl
vllm serve castorini/gaggle-nanochat-ift-climbmix-20261031 --trust-remote-code
from vllm import LLM, SamplingParams
llm = LLM("castorini/gaggle-nanochat-ift-climbmix-20261031", trust_remote_code=True)
out = llm.chat([{"role": "user", "content": "What is the capital of France?"}],
SamplingParams(max_tokens=64, temperature=0))
print(out[0].outputs[0].text)
Output on one L40S GPU (vLLM 0.30):
The capital of France is Paris.
vllm serve gives the same reply through the OpenAI-compatible chat endpoint. Both use the chat template from
tokenizer_config.json, and replies stop at <|assistant_end|>.
nanochat
The original checkpoints are laid out as a nanochat base directory, so nanochat's chat scripts load them directly.
git clone https://github.com/karpathy/nanochat.git
cd nanochat && git checkout 92d63d4
uv sync --extra gpu
export NANOCHAT_BASE_DIR=$(uv run --with huggingface_hub python -c "from huggingface_hub import snapshot_download; \
print(snapshot_download('castorini/gaggle-nanochat-ift-climbmix-20261031', allow_patterns=['tokenizer/*', 'chatsft_checkpoints/*']))")
uv run --extra gpu python -m scripts.chat_cli -i sft -g gaggle227158 # chat in the terminal
uv run --extra gpu python -m scripts.chat_eval -i sft -g gaggle227158 # the chat evaluation above
From Python, nanochat.checkpoint_manager.build_model(f"{NANOCHAT_BASE_DIR}/chatsft_checkpoints/gaggle227158", step=700, device=..., phase="eval") returns the model, tokenizer and metadata; conversations go through
tokenizer.render_conversation / render_for_completion.
Stock 92d63d4 has no mid source and no MMLU-Pro task. code/ has both: the patched
nanochat/checkpoint_manager.py (maps -i mid to mid_checkpoints), tasks/mmlu_pro.py, and scripts/chat_eval.py
with MMLU-Pro added (-a MMLU-Pro).
The implementations agree
transformers and vLLM load the same tensors as nanochat. We checked them against nanochat's own forward pass on the
original SFT checkpoint, with the base model's checks (code/hf/) plus chat-specific ones.
| Check | Result |
|---|---|
transformers vs nanochat, bf16 on an H100 (both with PyTorch SDPA attention): logits of real text at 2 to 2,048 tokens | bitwise identical |
| same, a right-padded batch vs nanochat on the same batch | bitwise identical |
| loss on a 2,048-token sequence | identical (1.4402) |
| greedy generation, 5 text prompts x 48 tokens, with and without the KV cache | identical token for token |
greedy chat replies, 6 prompts up to 96 tokens, stopping at <|assistant_end|>, with and without the KV cache | identical token for token |
| tokenizer vs nanochat's, 400 documents | identical ids, identical decoding |
chat template vs nanochat's render_conversation / render_for_completion, 5,700 conversations (smol-smoltalk, GSM8K with tool calls, MMLU, MMLU-Pro, ARC, identity, SimpleSpelling, SpellingBee), message content as strings and as lists of text parts (as vLLM passes it), transformers 4.57 and 5.18 | identical ids, apart from the two nanochat behaviours below |
vLLM vs transformers, fp32 (vLLM Triton attention): per-token log-probabilities of real text at 2 to 2,048 tokens | mean difference 0.0005 to 0.0016 nats (0.006 for one sequence); all 5 greedy generations identical |
vLLM vs transformers, bf16 (vLLM eager and compiled on an L40S, the transformers reference on an H200) | mean difference 0.02 to 0.03 nats; greedy generations identical for 4 of 5 (eager) and 5 of 5 (compiled) |
vLLM chat (LLM.chat): prompt ids, greedy replies to the 6 chat prompts | prompt ids identical to the chat template's; 5 of 6 replies identical to transformers, the sixth diverges at token 29 |
Two nanochat behaviours the chat template does not copy: nanochat cuts a rendered conversation at 2,048 tokens (the template does not; this is all 39 of the 3,000 smol-smoltalk prompts that differed), and it tokenizes consecutive text parts of one assistant message separately, where the template joins them (all 300 SpellingBee training conversations become identical once the parts are joined). Neither affects ordinary chat prompts.
In bf16, any change of kernel shape (batching, padding, a KV cache, a different attention kernel) moves logits by
rounding, which can flip near-tied greedy choices; a left-padded batch of the same prompts agreed on 4 of 5 text and 5
of 6 chat generations, and vLLM in bf16 matched 5 of 6 chat replies. convert_nanochat_to_hf.py is the base repo's converter,
unchanged; convert_ift.py runs it on model_000700.pt and adds the chat template.
Files
model-0000{1,2,3}-of-00003.safetensors,model.safetensors.index.json: the weights fortransformersand vLLM. These are the tensors ofchatsft_checkpoints/gaggle227158/model_000700.pt, unchanged in value and dtype, renamed tomodel.<nanochat name>(lm_head.weightkeeps its name).config.json,generation_config.json,configuration_gaggle.py,modeling_gaggle.py: the architecture fortransformersand vLLM; the two.pyfiles are the base model's.tokenizer.json(the base model's),tokenizer_config.json(the base model's plus the chat template and<|assistant_end|>as eos).vllm_gaggle-0.1.0-py3-none-any.whl,vllm_plugin/: the base model's vLLM plugin, unchanged.chatsft_checkpoints/gaggle227158/model_000700.pt,meta_000700.json: this model for nanochat (SFT, step 700).mid_checkpoints/gaggle227158/model_000816.pt,meta_000816.json: the midtraining checkpoint (step 816), nanochat only; no optimizer state.tokenizer/: the base model's tokenizer in nanochat's format, unchanged.code/: the ported midtraining and SFT scripts, the patched nanochat files, the MMLU-Pro task, the Slurm scripts, the 5-shot evaluation harness, the conversion and vLLM checks (code/hf/), and the four-model comparison (code/comparison/).logs/: training, evaluation and check logs.SHA256SUMS: checksums of every other file.
Related
castorini/gaggle-nanochat-pretrained-climbmix-20260924: the base model.