nanoGlimmer
Provided only as a demonstration of nanoGlimmer. Hugging Face is used here for large-file storage. The model is reproducible with the included training script in about 2 hours on one H100.
nanoGlimmer is a 29M-parameter language model that writes short children's
stories. It is sized for an ESP32-S3 microcontroller with 16 MB of flash and
8 MB of PSRAM. The ExecuTorch example in
apullin/executorch
(examples/espressif/esp32s3, "A language model that writes stories") exports
it, flashes it, checks the board against the PC and has it write.
Files
| File | Bytes | SHA-256 |
|---|---|---|
nanoglimmer-story.pt |
115,954,291 | 1f514b1b69cb1986030452c2b02b2dd846410fec603ecedf36549fe41b3f943c |
tokenizer.json |
553,715 | f281e194759de36e8122fae74ac625fc163e5482ff9f4d8b579ec2eb39138b2c |
training/ |
the code it was trained with (training/README.md) |
nanoglimmer-story.pt is a torch.save dict:
cfg: the model's settings;quantization: int4 weights and tables in groups of 128, with fp16 scales;state: the float32 weights, 126 tensors.
tokenizer.json is a Hugging Face tokenizers byte-level BPE with 8,192
entries, <|endoftext|> among them.
The model
A Glimmer decoder with Per-Layer Embeddings, an idea from Google's Gemma 3n:
- d_model 256, 8 layers, 8 query heads sharing 1 key/value head;
- a sliding window of 64 tokens in three of every four layers, the fourth global;
- feed-forward width 768, a per-layer table of 256 values a layer, a context of 256 tokens, and the final logits softcapped at 20.
It has 28,977,664 parameters: 18,874,368 in two lookup tables (the token embedding and the per-layer table), 2,097,152 in the output head and 8,006,144 in the layers. Its weight matrices and tables were trained with int4 quantisation-aware training in groups of 128, so the int4 model on the chip is the model that was trained.
Training
The data is TinyStories (Ronen Eldan and Yuanzhi Li, 2023): short stories in
simple English. It is all of TinyStories-train.txt and
TinyStoriesV2-GPT4-train.txt, 1,006,366,144 tokens, with a validation slice
held out. The run was one H100 for 1 h 45 min: 61,423 steps of 16,384 tokens
(about 1.0 billion tokens), ending at validation loss 1.6115 (perplexity 5.01).
The command, from training/ (training/README.md builds the data first):
uv run python src/train.py --vocab 8192 --batch-size 64 --seq-len 256 \
--train-bin data/train_v1v2_v8192.bin --steps 61423 --eval-every 2000 \
--seed 0 --qat --qat-bits 4 --qat-table-bits 4 --qat-group 128 \
--compile reduce-overhead \
--architecture glimmer --arm ple --n-heads 8 --n-kv-heads 1 --glimmer-window 64 \
--d-model 256 --n-layers 8 --fixed-ffn 768 --ple-dim 256 --tag story-d256l8f768p256
On an ESP32-S3
In the ExecuTorch tree, from examples/espressif/esp32s3, with ESP-IDF 5.5.5
and the board on its USB port:
hf download apullin/nanoglimmer nanoglimmer-story.pt tokenizer.json --local-dir nanoglimmer
python story/write_story.py --checkpoint nanoglimmer/nanoglimmer-story.pt \
--tokenizer nanoglimmer/tokenizer.json
This exports the checkpoint in the int4 format it was trained for, as one program with a prefill and a decode method sharing their KV cache. It builds the firmware and flashes it. The 15 MB of weights stay in flash, 6 MB of them copied into PSRAM at load, and every projection is split across both cores. The board then checks its own output against the PC and writes a story, printed a token at a time. On our board its logits equalled the PC's bit for bit, and it wrote at 72.3 ms per token (13.8 tokens a second). The example's README gives the details.
Licence
The checkpoint, the tokenizer and this card are under the BSD 3-Clause License
(LICENSE). The training code in training/ comes from a fork of
esp32-ai and keeps its MIT License,
Copyright (c) 2026 Viacheslav Sierbov (training/LICENSE).