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.
C avx2c99cpu-inferencedeep-learningfrom-scratchinference-enginekimi-k3linear-attentionllmllm-inferencemachine-learningmemory-efficientmixture-of-expertsmoemxfp4quantizationsimdsystems-programmingtransformerzero-dependencies
build: add a CMake CI regression job and pin Python tool dependencies
Fareed Khan68622d7bc81f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b2eb7d9..2917df7 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -185,6 +185,24 @@ jobs:plain.f32.2d plain.bf16.1d tricky.f16.1d packed.u8.2d scalar.f32 second.shard.f32./bin/k3_model.exe tests/fixtures+ # CMakeLists.txt documents itself as staying interchangeable with the Make build, but+ # nothing in CI ever actually built or ran tests through CMake before this job -- that+ # claim was unverified. This runs the same weightless oracle test that gates the Make+ # build through cmake/ctest instead, so a future change cannot silently break the+ # CMake path without CI noticing.+ cmake-build-and-test:+ name: build + test (CMake)+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v7+ - run: sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libomp-dev+ - name: Configure+ run: cmake -B build -DCMAKE_BUILD_TYPE=Release+ - name: Build+ run: cmake --build build -j+ - name: ctest+ run: ctest --test-dir build --output-on-failure+# Warnings are defects here. The engine does arithmetic on `const void *` weight# pointers, where a missing -Wpointer-arith silently strides by one byte.strict-warnings:diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 608d196..38250f1 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -9,6 +9,12 @@ make -j && make test`make test` needs no model weights and must stay green. If it is red on `main`, that isthe bug worth fixing first.+`tools/*.py` (fixture generation, reference conformance, cache replay) needs `numpy`,+`torch`, and, for lint and the tokenizer parity check, `ruff` and `tiktoken`. Exact+versions are pinned in `pyproject.toml`; install them however you normally manage Python+dependencies, for example `pip install numpy==2.5.2 torch==2.13.0` and, for the dev+group, `pip install ruff==0.16.3 tiktoken==0.13.0`.+## The standard this codebase holds itself to**A wrong answer that looks right is the worst failure mode here.** This engine can loaddiff --git a/pyproject.toml b/pyproject.tomlnew file mode 100644index 0000000..505adc2--- /dev/null+++ b/pyproject.toml@@ -0,0 +1,19 @@+[project]+name = "kimi-k3-in-c"+version = "1.0.0"+description = "Python tooling for the Kimi K3 inference engine: fixture generation, reference-vs-C conformance, cache replay"+requires-python = ">=3.12"+# Pinned exact, not a range, so the next environment anyone builds from this file+# resolves to the same versions rather than whatever happens to be newest that day.+dependencies = [+ "numpy==2.5.2",+ "torch==2.13.0",+]++[dependency-groups]+# Lint/CI-only. tiktoken is the reference tokenizer tools/tok_parity.py checks against;+# it is never a runtime dependency of the C engine.+dev = [+ "ruff==0.16.3",+ "tiktoken==0.13.0",+]