Reading the repo
Reading the repo
How to install on Linux
A 2.78-trillion-parameter Kimi K3 running inference on a single CPU in 8.24 GB of RAM. Portable C99: no BLAS, no framework, no GPU.
Saved setup from 9 h ago
Will it work on my device?
docs/QUICKSTART.mdFrom nothing to generated text.
./scripts/k3-doctor.sh
Reports whether this machine can run the model, which preset fits its memory, and how fast its storage is. Storage matters more than you would expect, the engine moves ~135 GB per token at small budgets.
make -j
No dependencies beyond a C compiler and OpenMP. If -march=native is a problem (you are
building for a different machine), use make portable.
make test
Seconds, and no model weights required. Op kernels, the streaming cache, the safetensors reader, the config reader, the tokenizer, and the end-to-end oracle gates.
export HF_TOKEN=... # a HuggingFace token with access to the model
./scripts/download-model.sh ~/k3model
1.56 TB across 96 shards; roughly 30 minutes at 1 GB/s. The script verifies the byte total against the published figure afterwards, because a partial download does not fail loudly, it produces wrong tokens.
./scripts/pack-trunk.sh ~/k3model ~/k3trunk
A few minutes. This is what allows the trunk to stream, and therefore what makes the memory budget adjustable rather than fixed at ~115 GB.
./bin/k3 ~/k3model \
--trunk ~/k3trunk --preset server \
--tok ~/k3model \
--prompt "The capital of France is" --gen 16 --incremental
--- generated text ---
Paris.
----------------------
examples/, runnable scripts, including one that proves output is identical across
memory budgetsFor a text conversation rather than a raw continuation, use the official K3 XTML REPL:
./bin/k3 ~/k3model --trunk ~/k3trunk --preset desktop --tok ~/k3model \
--chat --system "You are a helpful assistant." \
--history my-session.jsonl --incremental
The JSONL transcript is portable but sensitive: it retains assistant reasoning_content
as well as visible replies, because K3 needs that complete record for the next turn.
"REFUSING: the KV cache for N positions needs X", the context you asked for does not
fit. Shorten it, or drop --incremental (full recompute carries no KV cache, but is
O(T²) in time).
Very slow with a long prompt, expected. Prefill is not chunked and MLA attention is quadratic in sequence length. See ROADMAP.md.
"config could not be read with confidence", the reader found a config it does not fully understand and refused rather than guessing. The message lists every missing field.
Output is a continuation, not an answer, use --chat; ordinary --prompt deliberately
keeps raw-completion behavior for compatibility.
Then run bash setup.sh. It stops at the first error and is safe to run again. Servers and tests aren't started; it lists them at the end. Read it first.
git clone https://github.com/FareedKhan-dev/kimi-k3-in-c.git cd kimi-k3-in-c
Python >=3.12, C/C++ compiler, CMake 3.16, make
sudo apt install python3 python3.12 python3-venv # Debian/Ubuntu sudo apt install build-essential # Debian/Ubuntu sudo apt install cmake sudo apt install make
python -m venv .venv source .venv/bin/activate pip install -e . cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build
Clone, build and run the entire test suite. No checkpoint, no network, no Python. The whole thing takes about a minute.
git clone https://github.com/FareedKhan-dev/kimi-k3-in-c.git
cd kimi-k3-in-c
make -j # seconds. Seven C files, a compiler and OpenMP
make test # under a minute
It ends like this, or it failed:
GATE 1 teacher forcing : 32/32 positions match tf_pred
generated span : 20/20 <- must be exact
GATE 2 greedy decode : 20/20 generated tokens match full_ids
GATE 3 incremental : 20/20 generated tokens match full_ids <- KV cache + carried KDA state
VERDICT: ENGINE MATCHES THE REFERENCE EXACTLY
ALL WEIGHTLESS TESTS PASSED
That is the whole engine: every kernel, the streaming cache, the safetensors reader, the config reader, the tokenizer, and an end-to-end oracle over a 13-layer model built with the same tensor graph as the released one, checked against a PyTorch reference from fixtures committed to the repository.
One published measurement also replays on the spot, from a trace recorded during a full 93-layer run (this one needs Python 3.9+ and numpy):
python3 tools/sim_cache.py tests/fixtures/expert_trace.bin
100,096 expert requests, reprinting the capacity table in
expert-cache-capacity.txt.
No reports for Linux yet.
Opens a chat with this manual already filled in, for Linux. It uses your own account; gitmanual sends nothing.