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

build(vk): link the Vulkan loader on Windows under -static

Kenneth-Javier Ortigozaad65a59e9b42
diff --git a/c/Makefile b/c/Makefile
index 370160e7..00a024fe 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -681,7 +681,17 @@ VK_SPV =
GLSLC ?= glslc
ifeq ($(VK),1)
CFLAGS += -DCOLI_VULKAN
+ifneq ($(IS_WIN),)
+# Windows has no libvulkan: the loader is vulkan-1.dll, installed by the GPU
+# driver, and MSYS2's vulkan-loader package ships only its import library,
+# libvulkan-1.dll.a. The -static in the Windows LDFLAGS makes ld skip every
+# .dll.a, so neither -lvulkan nor -lvulkan-1 resolved and VK=1 failed at link
+# time. Search dynamically for this one library, then switch back: libgomp,
+# winpthreads and libgcc stay static, and the only new import is vulkan-1.dll.
+LDFLAGS += -Wl,-Bdynamic -lvulkan-1 -Wl,-Bstatic
+else
LDFLAGS += -lvulkan
+endif
VK_OBJ = backend_vulkan.o
VK_SPV = shaders/qmatmul.spv shaders/qmatmul_gate_up.spv shaders/attention_absorb.spv shaders/rmsnorm.spv
endif
diff --git a/c/tests/test_makefile_platform.py b/c/tests/test_makefile_platform.py
index 50b4c7af..f8943083 100644
--- a/c/tests/test_makefile_platform.py
+++ b/c/tests/test_makefile_platform.py
@@ -60,6 +60,24 @@ class MakefilePlatformTests(unittest.TestCase):
result = self._dry_run("portable", triplet)
self.assertIn(expected_flag, result.stdout)
+ def test_vk_links_the_platform_vulkan_loader(self):
+ # Windows links -static, and ld skips import libraries under it: MSYS2
+ # ships the Vulkan loader only as libvulkan-1.dll.a, so -lvulkan never
+ # resolved. Dynamic lookup for that one library, then back to static.
+ cases = (
+ ("x86_64-unknown-linux-gnu", "-o colibri ", ["-pthread", "-lvulkan"]),
+ ("x86_64-w64-mingw32", "-o colibri.exe ",
+ ["-static", "-lpsapi", "-Wl,-Bdynamic", "-lvulkan-1", "-Wl,-Bstatic"]),
+ )
+
+ for triplet, output, tail in cases:
+ with self.subTest(triplet=triplet):
+ result = self._dry_run("colibri", triplet, VK=1)
+ link = next(
+ line for line in result.stdout.splitlines() if output in line
+ )
+ self.assertEqual(link.split()[-len(tail):], tail)
+
def test_darwin_portable_build_does_not_force_x86_architecture(self):
missing_libomp = "/colibri-test/missing-libomp"
result = self._dry_run(
diff --git a/docs/vulkan.md b/docs/vulkan.md
index 05518f76..2b39cacb 100644
--- a/docs/vulkan.md
+++ b/docs/vulkan.md
@@ -40,6 +40,34 @@ The compiled shaders are found via `COLI_VK_SHADERS` (either the
`qmatmul.spv` file or the directory holding the `.spv` set); unset, the
engine looks in `shaders/` next to the binary, then relative to the CWD.
+### Windows (MSYS2)
+
+In the MSYS2 **UCRT64** shell ([quickstart.md](quickstart.md)), add the Vulkan
+headers, the loader's import library and `glslc`, then build:
+
+```bash
+pacman -S --needed mingw-w64-ucrt-x86_64-vulkan-headers \
+ mingw-w64-ucrt-x86_64-vulkan-loader mingw-w64-ucrt-x86_64-shaderc
+cd c
+make colibri.exe VK=1
+```
+
+The binary is statically linked like the default Windows build, plus one
+import: `vulkan-1.dll`, the loader the GPU driver installs in `System32`, so it
+runs outside MSYS2 with nothing added to `PATH`. The next-to-the-binary shader
+lookup above is Linux-only: on Windows run from `c\` or set `COLI_VK_SHADERS`.
+To check the driver before downloading a model, point `SNAP` at a folder
+holding only a `config.json`, as the CI's Lavapipe job does; the backend
+initialises before any weight is read:
+
+```powershell
+# in c\
+New-Item -ItemType Directory -Force $env:TEMP\vkprobe | Out-Null
+'{"model_type":"glm_moe_dsa"}' | Set-Content $env:TEMP\vkprobe\config.json
+$env:SNAP = "$env:TEMP\vkprobe"; $env:COLI_VULKAN = "1"; $env:COLI_NO_OMP_TUNE = "1"
+.\colibri.exe # prints "[VK] ready: <GPU>", then exits: there is no model
+```
+
## What runs on the GPU
| Piece | Env | Mechanism |