Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
build: address review of the generated-deps change
Kenneth-Javier Ortigoza081d28dd4f9f
diff --git a/c/Makefile b/c/Makefileindex 4aaf6e6c..95d966cd 100644--- a/c/Makefile+++ b/c/Makefile@@ -496,7 +496,10 @@ endif# in the other direction: it promoted files that deliberately have no rule (a branch's# work-in-progress test, test_fse, test_tok, test_tok_kimi, test_vk_mxfp4) into gates, and# they fail to link. Having a rule is the honest definition of "this is a gate".-TEST_RULES := $(shell sed -n 's|^tests/\(test_[a-z0-9_]*\)\$$(EXE):.*|\1|p' $(firstword $(MAKEFILE_LIST)))+# RULE_NAMES is every `NAME$(EXE):` rule, with its directory; one pass over the+# Makefile serves both TEST_RULES here and ENGINE_RULES (#1741, end of file).+RULE_NAMES := $(shell sed -n 's|^\([a-z0-9_/]*\)\$$(EXE):.*|\1|p' $(firstword $(MAKEFILE_LIST)))+TEST_RULES := $(patsubst tests/%,%,$(filter tests/test_%,$(RULE_NAMES)))# test_uring is Linux-only. V4 engine tests are appended below only on supported# x86-64 Linux/Windows and aarch64 Linux hosts; the V4 infrastructure tests have# unconditional rules and therefore remain portable gates. The six forced@@ -1206,8 +1209,7 @@ qwen36$(EXE): qwen36.c $(QWEN36_TIER_OBJ) $(CUDA_OBJ) .build-config# DeepSeek V4.1 Flash: one file, like every other portable engine. The fp4 experts# stream from the official checkpoint and quant.h's mxfp4 kernel reads them as they# are, so there is no conversion target here to go with it.-deepseek_v41$(EXE): deepseek_v41.c \- .build-config+deepseek_v41$(EXE): deepseek_v41.c .build-config$(CC) $(CFLAGS) deepseek_v41.c -o deepseek_v41$(EXE) $(LDFLAGS)# Qwen3.8-Flash-Next text-only sibling. qwen38.c owns the direct checkpoint@@ -1266,8 +1268,8 @@ qwen38-tier-engine-check: qwen38-tiny-fp8-generate tests/test_qwen38_tier_engine# Context-size gates: KV layout, growth across requests, and the attention# capacity. Includes qwen36.c directly, so no model file is needed.-# Same tier sources as the engine: the test includes qwen36.c, so with CUDA=1-# it needs qwen36_tier.c and the backend object too (without CUDA, the header's+# Same tier objects as the engine: the test includes qwen36.c, so with CUDA=1+# it links qwen36_tier.o and the backend object too (without CUDA, the header's# inline stubs cover it and both are empty).tests/test_qwen36_ctx$(EXE): tests/test_qwen36_ctx.c qwen36.c $(QWEN36_TIER_OBJ) $(CUDA_OBJ)$(CC) $(CFLAGS) $< $(QWEN36_TIER_OBJ) $(CUDA_OBJ) -o $@ $(LDFLAGS)@@ -2465,7 +2467,7 @@ AUTODEP_MULTI_TU = test_xdna_qt_state test_xdna_failure test_qwen38_tokenizer \AUTODEP_ELSEWHERE = test_segment_adapters_registration test_segment_adapters_real \test_edge_adapters_registration test_edge_adapters_real test_deepseek_v4 \test_v4_serve_framing-ENGINE_RULES := $(foreach n,$(shell sed -n 's|^\([a-z0-9_]*\)\$$(EXE):.*|\1|p' $(firstword $(MAKEFILE_LIST))),$(if $(wildcard $(n).c),$(n)))+ENGINE_RULES := $(foreach n,$(RULE_NAMES),$(if $(findstring /,$(n)),,$(if $(wildcard $(n).c),$(n))))AUTODEP_OBJS = backend_vulkan.o backend_loader.o backend_xdna.o qwen36_tier.oAUTODEP_BINS = $(addsuffix $(EXE),$(ENGINE_RULES)) \$(addprefix tests/,$(addsuffix $(EXE),$(filter-out $(AUTODEP_MULTI_TU) $(AUTODEP_ELSEWHERE),$(TEST_RULES)))) \diff --git a/c/tests/test_makefile_deps.py b/c/tests/test_makefile_deps.pyindex 8462533d..4559e388 100644--- a/c/tests/test_makefile_deps.py+++ b/c/tests/test_makefile_deps.py@@ -34,6 +34,7 @@ The engine list is still DERIVED from the Makefile, never kept here: anythingmatching `NAME$(EXE):` with a `NAME.c` beside it is an engine, and the familyregistry is the cross-check that the parse found them all."""+import contextlibimport osimport reimport shlex@@ -72,24 +73,47 @@ def _engine_rules():return rules-def _make(*args):- """Run make in c/ with the build's own configuration.+def _build_config_kept():+ """Leave .build-config exactly as it was, contents and timestamp.- Inside `make check` the child inherits MAKEFLAGS, so it parses the same- variables the build did and leaves .build-config as it was.+ The Makefile rewrites .build-config while it parses, whenever the flags+ differ from the last build's. Every make call below parses, and some pass+ CUDA=1 or CUDA_DLL=1 on purpose, so without this the suite would switch+ the tree's recorded configuration and the next `make` would relink+ everything that depends on it."""- return subprocess.run([MAKE, "--no-print-directory", *args], cwd=C_DIR,- text=True, encoding="utf-8", errors="replace",- capture_output=True, timeout=600)+ path = C_DIR / ".build-config"+ before = path.read_bytes() if path.exists() else None+ stamp = path.stat() if before is not None else None+ try:+ yield+ finally:+ if before is None:+ if path.exists():+ path.unlink()+ elif not path.exists() or path.read_bytes() != before or \+ path.stat().st_mtime_ns != stamp.st_mtime_ns:+ path.write_bytes(before)+ os.utime(path, ns=(stamp.st_atime_ns, stamp.st_mtime_ns))+++def _make(*args):+ """Run make in c/, leaving the tree's build configuration untouched."""+ with _build_config_kept():+ return subprocess.run([MAKE, "--no-print-directory", *args], cwd=C_DIR,+ text=True, encoding="utf-8", errors="replace",+ capture_output=True, timeout=600)def _make_var(name):# `make --eval` needs GNU Make 3.82; macOS ships 3.81, which does read an# extra makefile from stdin.- proc = subprocess.run([MAKE, "-s", "--no-print-directory", "-f", "Makefile",- "-f", "-", f"print-{name}"], cwd=C_DIR, text=True,- input="print-%: ; @echo $($*)\n", capture_output=True,- timeout=300)+ with _build_config_kept():+ proc = subprocess.run([MAKE, "-s", "--no-print-directory", "-f", "Makefile",+ "-f", "-", f"print-{name}"], cwd=C_DIR, text=True,+ input="print-%: ; @echo $($*)\n", capture_output=True,+ timeout=300)if proc.returncode != 0:raise AssertionError(f"could not read {name} from the Makefile:\n"f"{proc.stderr}")@@ -274,6 +298,19 @@ class GeneratedDepsWiringTest(unittest.TestCase):problems = self._one_unit_problems(variable)self.assertEqual(problems, [], f"with {variable}:\n " + "\n ".join(problems))+ def test_the_checks_leave_the_build_config_alone(self):+ """Parsing with CUDA=1 or CUDA_DLL=1 rewrites .build-config; the checks+ above do exactly that, and must not change which configuration the+ tree says it was built with. Bite: drop the `with _build_config_kept()`+ from `_make` and this fails whenever a GPU flavour is accepted here."""+ path = C_DIR / ".build-config"+ before = (path.read_bytes(), path.stat().st_mtime_ns) if path.exists() else None+ _gpu_variables(self.exe)+ _make("-Bn", "colibri" + self.exe, "XDNA=1")+ after = (path.read_bytes(), path.stat().st_mtime_ns) if path.exists() else None+ self.assertEqual(after, before, ".build-config was changed by a make call "+ "that only meant to read the Makefile")+def test_multi_unit_exceptions_are_still_multi_unit(self):"""An exception that no longer applies should rejoin AUTODEP_BINS."""targets = [f"tests/{n}{self.exe}" for n in self.multi]diff --git a/c/tools/clean.py b/c/tools/clean.pyindex ad0a71b9..dc1fcd8b 100644--- a/c/tools/clean.py+++ b/c/tools/clean.py@@ -26,6 +26,9 @@ FILES = ["glm", "glm.exe", # pre-rename name of the colibri engine"iobench", "iobench.exe","backend_cuda.o", "backend_loader.o", "qwen36_tier.o",+ # VK=1 and XDNA=1 objects. Left behind once their .d is cleaned, an+ # object would sit in the tree with no record of the headers it read.+ "backend_vulkan.o", "backend_xdna.o","backend_cuda_test", "backend_cuda_test.exe","mxfp4_expert_cuda_test", "mxfp4_expert_cuda_test.exe","backend_cuda_bench", "backend_cuda_bench.exe",@@ -63,8 +66,12 @@ FILES = [# *.d are the dependency files -MMD writes beside each binary and object# (#1741). A stale one only adds prerequisites, but clean should leave nothing# the build made, and removing it forces the rebuild that writes a fresh one.+# They land wherever an output does: c/ and tests/ for the engines and tests,+# tools/ for the ctypes libraries, build/segment/ for the V4 unit objects+# (build/ownership/ goes as a whole directory below).ARTIFACT_GLOBS = ["tests/test_*", "tests/bench_*", "tests/fuzz_*",- "tests/*_probe*", "COLI_V4_UNIT_*.o", "*.d", "tests/*.d"]+ "tests/*_probe*", "COLI_V4_UNIT_*.o", "*.d", "tests/*.d",+ "tools/*.d", "build/segment/*.d"]KEEP_EXT = (".c", ".h", ".cc", ".cpp", ".cu", ".mm", ".py", ".txt", ".json",".md", ".bin", ".sh", ".toml", ".yml", ".yaml")# Directories to remove.