Skip to content

Run frontier MoE models on hardware you already own β€” pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

Merge branch 'main' into fix/windows-cuda-dll-build

mohamedmastouri2000-boopc70d94368e11
diff --cc c/Makefile
index c1e93196,ccf0a3cb..5ae7a9c0
--- a/c/Makefile
+++ b/c/Makefile
@@@ -163,21 -212,7 +212,21 @@@ all: glm$(EXE
# phony 'glm' β†’ 'glm.exe' on Windows (so 'make glm' and 'coli build' work on every platform)
glm: glm$(EXE)
-glm$(EXE): glm.c st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h $(CUDA_OBJ) $(METAL_OBJ)
+# Config stamp: make only tracks file timestamps, not flag changes. Without this,
+# `make glm.exe CUDA_DLL=1` after a prior CPU-only build reports "up to date" and
+# silently keeps the CPU-only binary (no CUDA loader) β€” a build that looks like it
+# worked but isn't. We record the build-affecting flags in .build-config and rewrite
+# it ONLY when they change (evaluated here at parse time, so the file's timestamp
+# moves exactly when the config moves). glm.exe and the CUDA/loader objects depend
+# on it, so they relink on a config change and stay put otherwise. (#306)
+BUILD_CONFIG := $(CC)|$(CFLAGS)|$(LDFLAGS)|CUDA=$(CUDA)|CUDA_DLL=$(CUDA_DLL)|ARCH=$(ARCH)|CUDA_ARCH=$(CUDA_ARCH)|METAL=$(METAL)
+BUILD_CONFIG_OLD := $(shell cat .build-config 2>/dev/null)
+ifneq "$(BUILD_CONFIG)" "$(BUILD_CONFIG_OLD)"
+$(shell printf '%s' '$(BUILD_CONFIG)' > .build-config)
+endif
+.build-config: ;
+
- glm$(EXE): glm.c st.h json.h tok.h tok_unicode.h compat.h grammar.h $(CUDA_OBJ) $(METAL_OBJ) .build-config
++glm$(EXE): glm.c st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h $(CUDA_OBJ) $(METAL_OBJ) .build-config
$(CC) $(CFLAGS) glm.c $(CUDA_OBJ) $(METAL_OBJ) -o glm$(EXE) $(LDFLAGS)
# Windows runtime loader object: resolves coli_cuda_* from coli_cuda.dll.
@@@ -188,11 -223,11 +237,11 @@@ backend_loader.o: backend_loader.c back
# compiler, required by nvcc on Windows) into coli_cuda.dll. Run this from a
# shell that has the MSVC environment set (e.g. after vcvars64.bat, or from a
# "x64 Native Tools Command Prompt"). COLI_CUDA_BUILDING_DLL enables
- # __declspec(dllexport) so the 11 API symbols are exported.
+ # __declspec(dllexport) so the 15 API symbols are exported.
cuda-dll: backend_cuda.cu backend_cuda.h
- @command -v $(NVCC) >/dev/null 2>&1 || { echo "nvcc not found: set CUDA_HOME or NVCC" >&2; exit 1; }
+ @command -v "$(NVCC)" >/dev/null 2>&1 || { echo "nvcc not found: set CUDA_HOME or NVCC" >&2; exit 1; }
@command -v cl >/dev/null 2>&1 || { echo "cl.exe (MSVC) not in PATH β€” run vcvars64.bat first" >&2; exit 1; }
- $(NVCC) $(NVCCFLAGS) -shared -DCOLI_CUDA_BUILDING_DLL \
+ "$(NVCC)" $(NVCCFLAGS) -shared -DCOLI_CUDA_BUILDING_DLL \
-L"$(CUDA_HOME)/lib/x64" -lcudart \
backend_cuda.cu -o coli_cuda.dll