◉ Pulse
cneuralnetwork avatar
#74 today ▲ 13

cneuralnetwork/smol-kimi-k3

Python AI

A 49M-parameter Kimi K3-inspired language model trainable on one 8GB GPU

Created Jul 27, 2026
Stars
24
Today
+5
Forks
2
Quality
80/100
Momentum
23

README

Fetched from GitHub on Oct 30, 2026, 11:08 PM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to cneuralnetwork/smol-kimi-k3 and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

smol-kimi-k3

A 49M-parameter, Kimi K3-inspired language model you can train on one 8GB GPU

Parameters GPU PyTorch Dataset Tests

KDA · Gated MLA · Attention Residuals · Stable LatentMoE · SiTU-GLU · Per-Head Muon

Quick start · Architecture · Dashboard · Benchmarks


smol-kimi-k3 is a training-oriented, text-only miniature of the language backbone described in Moonshot AI's Kimi K3 technical report. It compresses the defining ideas of a 2.8-trillion-parameter frontier model into 49,019,770 trainable parameters, then trains that model from scratch on TinyStories using a single RTX 4060 Laptop GPU.

This is an architecture study, not a claim that 49M parameters reproduce the capabilities of Kimi K3. The point is to make the interesting machinery small enough to read, run, modify, and train at home.

Note

The first CUDA call builds the KDA Triton kernels and can take roughly 75 seconds. Later runs reuse the cache and start normally.

Why this exists

Most "tiny reproductions" replace the unusual parts of a frontier model with a standard Transformer. This project keeps the unusual parts:

  • a 3 KDA : 1 Gated MLA hybrid attention rhythm, followed by a final MLA layer;
  • channel-wise, lower-bounded Kimi Delta Attention with ShortConv;
  • data-dependent Attention Residuals across network depth;
  • sparse Stable LatentMoE channel mixing;
  • bounded SiTU-GLU experts and exact small-batch Quantile Balancing;
  • NoPE global attention;
  • Muon for matrices and Per-Head Muon for attention projections;
  • cached KDA/MLA autoregressive decoding;
  • a tiny live dashboard backed by Matplotlib artifacts.

Architecture

1. The 13-layer backbone

Kimi K3 repeats three KDA layers followed by one global MLA layer, then ends with an additional global layer. smol-kimi-k3 preserves that composition: 9 KDA layers + 4 Gated MLA layers.

Generated architecture diagram of the smol-kimi-k3 13-layer backbone with three hybrid KDA and MLA blocks, Stable LatentMoE layers, and Attention Residuals

Every attention and MoE sublayer receives a learned, data-dependent mixture of the embedding, completed block summaries, and the current partial block. That is the miniature implementation of Block Attention Residuals: information can be selected from earlier depths instead of being forced through one uniform residual stream.

2. Kimi Delta Attention

KDA is a finite-state, linear-attention recurrence. Queries and keys pass through ShortConv, SiLU, and L2 normalization. A learned channel-wise decay forgets stale state, while the delta rule writes only the error between the current value and the state's prediction.

Generated technical diagram explaining the Kimi Delta Attention projections, channel decay, prediction error, delta write, recurrent state, normalization, and gate

On CUDA, the same recurrence is evaluated with the report-linked fla-core chunkwise Triton kernel. A readable FP32 recurrent implementation remains available as the CPU fallback. Their measured mean absolute output difference is 0.00152 at BF16, against a mean reference magnitude of 0.22465.

3. Stable LatentMoE

Each layer has two always-on shared experts and 32 compact routed experts. Only the top four routed experts run for each token.

Generated Stable LatentMoE diagram with two shared SiTU-GLU experts and a Top-4-of-32 routed latent expert path using Quantile Balancing

SiTU-GLU smoothly caps both multiplicative branches:

gate = 4  · tanh(Wg x / 4)  · sigmoid(Wg x)
up   = 25 · tanh(Wu x / 25)
out  = Wdown(gate ⊙ up)

The routed aggregate is normalized before projection back to model width. At this local scale, Quantile Balancing uses the exact batch quantile instead of the distributed histogram approximation required by the 2.8T model.

What was scaled—and what was not

Component Kimi K3 report smol-kimi-k3
Total parameters 2.8T 49.02M
Layers 93 13
Attention composition 69 KDA + 24 MLA 9 KDA + 4 MLA
Hidden size 7,168 320
Attention heads 96 5
Routed experts 896, Top-16 32, Top-4
Shared experts 2 2
Latent MoE width 3,584 160
Vocabulary 160K 8,192 BPE
Position encoding NoPE NoPE
Vision tower MoonViT-V2, 401M omitted
Training data multimodal frontier corpus TinyStories text

The vision encoder is intentionally omitted: at 401M parameters, the upstream tower alone is eight times larger than this entire model, and TinyStories contains no visual inputs. Gated MLA preserves low-rank KV compression and NoPE global attention, but does not attempt to reproduce Moonshot's production inference kernels.

Model card

The checked-in configuration lives in configs/k3_50m.json.

Field Value
Trainable parameters 49,019,770
Layers 13
Hidden size 320
Heads / head size 5 / 64
Vocabulary 8,192
MLA latent size 128
Latent MoE width 160
Routed expert hidden size 168
Routed experts 32, Top-4
Shared expert hidden size 192
Shared experts 2
AttnRes block size 4 layers
Default sequence length 256
Optimizer Per-Head Muon + AdamW
Precision BF16 autocast

Quick start

1. Install

git clone https://github.com/cneuralnetwork/smol-kimi-k3.git
cd smol-kimi-k3
python3 -m pip install -r requirements.txt

2. Prepare TinyStories

Full training split plus 10,000 validation stories:

python3 scripts/prepare_tinystories.py \
  --output-dir data/tinystories

Small pipeline check:

python3 scripts/prepare_tinystories.py \
  --output-dir data/tinystories-smoke \
  --tokenizer-stories 10000 \
  --train-stories 10000 \
  --validation-stories 1000

3. Start the dashboard

In terminal A:

python3 dashboard.py \
  --run-dir checkpoints/k3-50m \
  --port 8080

Open http://127.0.0.1:8080.

4. Train

In terminal B:

python3 train.py \
  --data-dir data/tinystories \
  --output-dir checkpoints/k3-50m \
  --steps 10000

The safe defaults are:

micro-batch             16
sequence length         256
gradient accumulation   2
effective token batch   8,192
warmup                  1%
schedule                cosine
weight decay            0.1
sample interval         250 steps

Resume from the most recent atomic checkpoint:

python3 train.py \
  --data-dir data/tinystories \
  --output-dir checkpoints/k3-50m \
  --steps 10000 \
  --resume checkpoints/k3-50m/latest.pt

Generate a story:

python3 generate.py checkpoints/k3-50m/best.pt \
  --prompt "Once upon a time, a little fox"

Download the trained model

The best 10,000-step TinyStories checkpoint is published in the v0.1.0-tinystories GitHub Release. It uses BF16 SafeTensors and does not include optimizer state.

mkdir -p pretrained/smol-kimi-k3

gh release download v0.1.0-tinystories \
  --repo cneuralnetwork/smol-kimi-k3 \
  --dir pretrained/smol-kimi-k3

python3 generate.py pretrained/smol-kimi-k3/model.safetensors \
  --prompt "Once upon a time, a little fox"

Published bundle:

File Purpose
model.safetensors 49.02M BF16 model weights
config.json Exact architecture configuration
tokenizer.json TinyStories 8,192-token BPE tokenizer
training_metadata.json Steps, validation loss, run settings, and final state
sha256sums.txt Integrity checksums for every bundle artifact

The selected checkpoint is step 9,750 with validation loss 1.6277. To reproduce the export from a local training checkpoint:

python3 scripts/export_model.py checkpoints/k3-50m/best.pt \
  --dashboard-state checkpoints/k3-50m/dashboard_state.json

Live training dashboard

The monitor deliberately stays simple: the trainer writes durable files, and the local web page polls them every two seconds.

Generated workflow diagram showing TinyStories training on an RTX 4060, local checkpoints and metrics, Matplotlib loss rendering, and the live dashboard

The page shows:

  • current step and run status;
  • train and validation cross-entropy;
  • measured tokens per second;
  • peak allocated VRAM;
  • the Matplotlib loss curve;
  • the latest cached autoregressive sample.

Change sample cadence with --sample-interval, change its length with --sample-tokens, or use --skip-samples for pure throughput benchmarking.

Measured on an RTX 4060 Laptop GPU

Synthetic full optimizer steps at BF16, sequence length 256:

Micro-batch Throughput Peak allocated Peak reserved
8 424 tok/s 2.12 GiB —
16 901 tok/s 4.01 GiB —
24 1,318 tok/s 5.84 GiB 6.35 GiB

Batch 16 is the default because it leaves room for the display driver, evaluation, other desktop applications, and dashboard sample generation. If other applications consume substantial VRAM, use:

python3 train.py \
  --batch-size 8 \
  --gradient-accumulation 4

An end-to-end TinyStories verification step measured:

Check Result
Parameters 49,019,770
Train loss after step 0 9.0381
Validation loss 8.9360
Throughput 1,268 tok/s
Peak allocated VRAM 4.01 GiB
Dashboard artifacts JSONL + state + PNG + sample

These values verify the pipeline; they are not final model-quality results.

Repository map

smol-kimi-k3/
├── configs/
│   └── k3_50m.json              # authoritative model shape
├── dashboard/
│   ├── index.html               # barebones live UI
│   ├── styles.css
│   └── app.js
├── k3/
│   ├── config.py
│   ├── model.py                 # KDA, MLA, AttnRes, LatentMoE, decoding
│   ├── monitoring.py            # JSONL state + Matplotlib rendering
│   └── optim.py                 # Muon, Per-Head Muon, AdamW split
├── scripts/
│   └── prepare_tinystories.py
├── tests/
│   └── test_model.py
├── dashboard.py                 # local HTTP server
├── generate.py
└── train.py

Verification

python3 -m pytest -q

The test suite checks:

  1. the report's 3 KDA + 1 MLA layer composition;
  2. forward, loss, backward, and router-bias behavior;
  3. causal invariance;
  4. cached token-by-token decoding against full-sequence logits;
  5. the 48–52M parameter budget;
  6. dashboard state, metric, sample, and Matplotlib artifacts.

Expected result:

6 passed

Design notes

  • KDA training: official FLA chunkwise Triton kernel on CUDA; readable recurrent FP32 fallback on CPU.
  • KDA decoding: recurrent state and ShortConv caches are carried one token at a time.
  • MLA decoding: global key/value caches are retained per layer.
  • Routing: biases select experts, but do not alter normalized mixture weights, matching the auxiliary-loss-free design.
  • Balancing: exact quantiles replace distributed histograms because a single-device batch is small.
  • Optimizer split: matrix parameters use Muon; Q/K/V matrices are orthogonalized per head; embeddings, norms, biases, and scalars use AdamW.
  • Checkpointing: latest.pt and best.pt are written through a temporary file and atomically renamed.

Acknowledgements

This project is derived from ideas presented by the Kimi Team and uses the Flash Linear Attention KDA implementation. TinyStories was introduced by Eldan and Li and is consumed through the Hugging Face dataset.

Please consult the upstream repositories and technical report for their respective licenses, citations, and authoritative architectural details.


Big architecture, small GPU.

Rendered by GitHub from the repository’s README. Scroll to read the full file.
First trending

Jul 28, 2026

first spotted on the list

Best rank

#12

highest position reached

Appearances

3

times on the trending list

Quality score

80

out of 100

Momentum

23

trend strength indicator

Star velocity

0.25

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot
51015202530cneuralnetwork/smol-kimi-k3 · Jul 28, 2 AM UTC: 11 starscneuralnetwork/smol-kimi-k3 · Jul 28, 8 AM UTC: 19 starscneuralnetwork/smol-kimi-k3 · Jul 28, 2 PM UTC: 24 stars2 AM8 AM2 PM

Rank history

position on trending · lower is better
#1#10#20#30#40#50#60#70#80Jul 28, 2 AM UTC: rank #12Jul 28, 8 AM UTC: rank #18Jul 28, 2 PM UTC: rank #742 AM8 AM2 PM

3D card for your website

Live HTML card with a glass surface and pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/cneuralnetwork/smol-kimi-k3" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="cneuralnetwork/smol-kimi-k3 — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

cneuralnetwork/smol-kimi-k3 stars badge
Markdown
[![cneuralnetwork/smol-kimi-k3](https://www.notionpulse.cc/api/badge/cneuralnetwork/smol-kimi-k3.svg)](https://www.notionpulse.cc/repo/cneuralnetwork/smol-kimi-k3)
HTML
<a href="https://www.notionpulse.cc/repo/cneuralnetwork/smol-kimi-k3"><img src="https://www.notionpulse.cc/api/badge/cneuralnetwork/smol-kimi-k3.svg" alt="cneuralnetwork/smol-kimi-k3 stars badge" /></a>

Repository of the Day

#12 Repository of the Day

Repository of the Week

#12 Repository of the Week

Repository of the Month

#12 Repository of the Month