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 pull request #1924 from JustVugg/feat/vk-tier-exclusive

Vincenzo Fornaro0405e103da1a
diff --cc c/deepseek_v41.c
index bffc211e,60de2eca..bfe09378
--- a/c/deepseek_v41.c
+++ b/c/deepseek_v41.c
@@@ -81,17 -81,13 +81,21 @@@
#include "backend_vulkan.h"
#include "vk_tier.h"
#include "route_trace.h" /* the tier's expert history (.coli_usage), kept while it is on */
+#include "vk_chain.h" /* vkc_fit: how many layers the dense chain places (a partial chain) */
/* 1 once COLI_VULKAN=1 opened a device, after the weights load (a VK=1 build). */
static int g_vk_ready = 0;
+/* The partial chain (deepseek_v41_chain.h, v41c_fit_now): the first g_v41_fit.n layers on
+ * the device, decided once before anything goes up. g_v41_partial: something the full
+ * chain would place stays on the CPU (layers, the head), so the per-matrix path uploads
+ * nothing that is not on the device already. */
+static VkcFit g_v41_fit;
+static int g_v41_fit_done, g_v41_partial;
+static int g_v41_dho_try; /* the fit runs where the trunk may live on the device only (v41_dho_open) */
#endif
+ #ifndef COLI_VULKAN /* exclusive RAM/VRAM (vk_tier.h) is the Vulkan build's: no device holds an expert */
+ static inline int vkt_ram_first(int layer, int eid) { (void)layer; (void)eid; return 0; }
+ static inline void vkt_ram_gave(void) {}
+ #endif
#define V41_MAX_LAYERS 64
#define V41_MAX_ENGRAM 4
diff --cc c/inkling.c
index 6cab3008,d35d4ab6..b1258062
--- a/c/inkling.c
+++ b/c/inkling.c
@@@ -82,10 -81,11 +82,14 @@@ static int g_vk_ready = 0
static int g_vk_tier_try = 0; /* the device opened with the expert tier to be tried */
static int g_vk_chain = 0; /* COLI_VK_CHAIN decided on, and the chain's pipelines are up (inkling_chain.h) */
static int g_ink_dho = 0; /* COLI_VK_DENSE_HOST: the dense matrices on the device only (ink_dho_place) */
+/* The partial chain's fit (inkc_fit_start, inkling_chain.h): the first n of L layers on the
+ * device; L = 0 while there is none (the chain off, or one that declines as before). */
+static VkcFit g_inkc_fit;
#endif
+ #ifndef COLI_VULKAN /* exclusive RAM/VRAM (vk_tier.h) is the Vulkan build's: no device holds an expert */
+ static inline int vkt_ram_first(int layer, int eid) { (void)layer; (void)eid; return 0; }
+ static inline void vkt_ram_gave(void) {}
+ #endif
#if defined(__APPLE__)
#include <mach/mach.h>
#include <sys/sysctl.h>