Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(win): inkling and kimi_k3 now build on Windows; CI covers every engine
JustVuggf8823030e55c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex e7a48740..578ac41a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -17,6 +17,55 @@ jobs:- name: C test suiterun: cd c && make test-c+ # Every engine, on every platform a release archive is built for. Before this,+ # CI built colibri + inkling on Linux only and kimi_k3 on nothing -- so the fact+ # that inkling and kimi_k3 did not compile under msys2/UCRT64 at all was invisible+ # for months, and binary releases silently shipped the GLM engine alone (#720).+ # Each engine is built separately so one failure does not mask the others.+ engines-all-platforms:+ name: All engines (${{ matrix.name }})+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: ubuntu-latest+ name: linux+ shell: bash+ - os: macos-latest+ name: macos+ shell: bash+ - os: windows-latest+ name: windows+ # GitHub shells are format strings: 'msys2 {0}', never bare 'msys2'.+ shell: "msys2 {0}"+ runs-on: ${{ matrix.os }}+ defaults:+ run:+ shell: ${{ matrix.shell }}+ steps:+ - uses: actions/checkout@v4+ - if: matrix.os == 'windows-latest'+ uses: msys2/setup-msys2@v2+ with:+ msystem: UCRT64+ update: false+ path-type: inherit+ install: >-+ make+ mingw-w64-ucrt-x86_64-gcc+ - if: matrix.os == 'macos-latest'+ run: brew install libomp+ - name: Build every engine+ run: |+ cd c+ rc=0+ for t in colibri inkling kimi_k3 olmoe; do+ echo "::group::$t"+ make $t || { echo "FAILED: $t"; rc=1; }+ echo "::endgroup::"+ done+ exit $rc+engine-cuda-syntax:name: CUDA syntax checkruns-on: ubuntu-latestdiff --git a/c/compat.h b/c/compat.hindex 1b56f5fb..7531ccdb 100644--- a/c/compat.h+++ b/c/compat.h@@ -10,6 +10,9 @@#include <fcntl.h>#include <unistd.h>#include <sys/types.h>+#ifndef _WIN32+#include <sys/select.h> /* select(), fd_set, struct timeval per coli_stdin_readable */+#endif/* --- posix_fadvise: assente su macOS ---* WILLNEED -> F_RDADVISE (readahead esplicito: stessa semantica).@@ -371,4 +374,41 @@ static inline char *compat_mkdtemp(char *tmpl){#define COMPAT_O_RDONLY O_RDONLY#endif+/* --- coli_stdin_readable: "c'e' input su stdin adesso?", senza bloccare ---+ *+ * I serve loop di inkling.c e kimi_k3.c usavano select() su fd_set direttamente.+ * Su Windows quei simboli non esistono in quella forma e le due build FALLIVANO+ * (misurato: Linux ok, macOS ok, Windows/UCRT64 no) -- ed e' il motivo per cui+ * le release binarie hanno sempre contenuto il solo motore GLM.+ *+ * La logica Windows non e' una traduzione meccanica: ha assorbito due bug.+ * #139 select() su un handle di pipe finisce in winsock e ritorna sempre+ * SOCKET_ERROR, quindi il loop non accettava mai una richiesta.+ * #195 le pipe anonime NON sono oggetti attendibili: WaitForSingleObject su+ * di esse e' undefined, e PeekNamedPipe fallisce su handle di file o+ * console. Su stdin non-pipe si riporta "niente da leggere" invece di+ * bloccare il loop.+ * Duplicarla una terza volta avrebbe rifatto entrare quei due bug in due motori+ * dove nessuno li avrebbe cercati: sta qui una volta sola.+ *+ * static inline: e' un header condiviso, e un TU che non la usa non deve pagarla. */+#ifdef _WIN32+static inline int coli_stdin_readable(void)+{+ HANDLE ih = (HANDLE)_get_osfhandle(_fileno(stdin));+ DWORD avail = 0;+ if (ih == INVALID_HANDLE_VALUE) return 0;+ if (PeekNamedPipe(ih, NULL, 0, NULL, &avail, NULL)) return avail > 0;+ return 0; /* console/file: nessun poll non bloccante, meglio "niente" che bloccare */+}+#else+static inline int coli_stdin_readable(void)+{+ fd_set r; struct timeval tv = {0, 0};+ FD_ZERO(&r); FD_SET(STDIN_FILENO, &r);+ return select(STDIN_FILENO + 1, &r, NULL, NULL, &tv) > 0+ && FD_ISSET(STDIN_FILENO, &r);+}+#endif+#endif /* COMPAT_H */diff --git a/c/inkling.c b/c/inkling.cindex 4b2796e9..e6dbfe3e 100644--- a/c/inkling.c+++ b/c/inkling.c@@ -1393,9 +1393,9 @@ typedef struct { char id[64]; int max_tok; float temp, top_p; char *payload; intstatic SReq g_q[SRV_QMAX]; static int g_qn = 0;static int stdin_readable(void) {- fd_set r; struct timeval tv = {0, 0};- FD_ZERO(&r); FD_SET(0, &r);- return select(1, &r, NULL, NULL, &tv) > 0;+ /* Windows non ha fd_set/select in questa forma: la build falliva del tutto.+ * La versione portabile (con i fix #139/#195) vive in compat.h, incluso via st.h. */+ return coli_stdin_readable();}/* read one control line (+ payload for SUBMIT). cur_id: request in flight;diff --git a/c/kimi_k3.c b/c/kimi_k3.cindex 904c0773..31c65f41 100644--- a/c/kimi_k3.c+++ b/c/kimi_k3.c@@ -1430,9 +1430,9 @@ static void model_state_reset(Model *m){}static int serve_stdin_readable(void){- fd_set r; struct timeval tv={0,0};- FD_ZERO(&r); FD_SET(0,&r);- return select(1,&r,NULL,NULL,&tv)>0;+ /* Windows non ha fd_set/select in questa forma: la build falliva del tutto.+ * La versione portabile (con i fix #139/#195) vive in compat.h, incluso via st.h. */+ return coli_stdin_readable();}static int serve_read_req(ServeReq *q, const char *active){