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

fix(windows): enable direct I/O for mirror shards

bill926dde9af3b2
diff --git a/c/st.h b/c/st.h
index ab259ae2..8b911d38 100644
--- a/c/st.h
+++ b/c/st.h
@@ -169,7 +169,7 @@ static int st_mirror_init(shards *S, const char *dir) {
S->mfds[i] = mfd;
#ifdef O_DIRECT
S->mdfds[i] = open(mp, COMPAT_O_RDONLY | O_DIRECT);
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || defined(_WIN32)
S->mdfds[i] = compat_open_direct(mp);
#endif
S->nmirror++;
diff --git a/c/tests/test_st_mirror.c b/c/tests/test_st_mirror.c
index 769c99d6..e520d64b 100644
--- a/c/tests/test_st_mirror.c
+++ b/c/tests/test_st_mirror.c
@@ -83,6 +83,9 @@ int main(void) {
CHECK(st_mirror_init(&S, DIR_B) == 1);
int mfd = st_fd_rep(&S, t->fd, 1);
CHECK(mfd >= 0 && mfd != t->fd);
+#ifdef _WIN32
+ CHECK(st_direct_fd_rep(&S, t->fd, 1) >= 0);
+#endif
float a[8], b[8];
CHECK(pread(t->fd, a, t->nbytes, t->off) == t->nbytes);
CHECK(pread(mfd, b, t->nbytes, t->off) == t->nbytes);