Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b923e55
Windows: a platform layer and host builds that pass
BobClawblaw Oct 12, 2026
60c6892
Windows: CUDA kernels, the native server and the GPU suites on sm_89
BobClawblaw Oct 12, 2026
9c36621
Windows: pull into the hub cache, HOME, and the whole test step
BobClawblaw Oct 12, 2026
2f626e1
Windows: build notes, strip before install, formatting
BobClawblaw Oct 12, 2026
ec0ddc5
Default port 8888
BobClawblaw Oct 12, 2026
3c57c14
qwen3_5: serve Qwen3.5-2B on CUDA
BobClawblaw Oct 13, 2026
84c58d3
qwen3_5: serve Qwen3.8-27B on CUDA, one arena for a model's device me…
BobClawblaw Oct 14, 2026
a087521
qwen3_5: replay each decode shape as a CUDA graph
BobClawblaw Oct 14, 2026
c3861d3
qwen3_5: DFlash2 drafts for Qwen3.8-27B on CUDA
BobClawblaw Oct 14, 2026
9b8d4af
qwen3_5: tree drafts on CUDA, the kept path replayed from a log
BobClawblaw Oct 14, 2026
b5b5c4b
docs: the Qwen hybrids on CUDA in the Windows page and the README
BobClawblaw Oct 14, 2026
cf2cdf1
qwen3_5, platform: comments on one line
BobClawblaw Oct 14, 2026
221c2b5
Windows: checkpoint reads skip the page cache
BobClawblaw Oct 14, 2026
522d17d
Windows: the signal handler type allows address 1, for aarch64
BobClawblaw Oct 14, 2026
d1ea47f
docs: Windows as a target in the README and the Windows page
BobClawblaw Oct 14, 2026
95f879e
CI: the host unit tests on Windows
BobClawblaw Oct 14, 2026
7efc823
qwen3_5: the drafter reads TF_TIMING through the platform layer
BobClawblaw Oct 14, 2026
85bb88d
qwen3_5: the drafter takes a prompt longer than its tap ring
BobClawblaw Oct 14, 2026
e01d423
qwen3_5 cuda: prompt chunks past 32 rows see the right keys, and tree…
BobClawblaw Oct 14, 2026
0baccf3
Windows: the server goldens and the Cortheon fuzz step on Windows hosts
BobClawblaw Oct 14, 2026
40159f8
cuda: cuBLASLt opens by its Windows DLL name
BobClawblaw Oct 14, 2026
cdb735b
Windows: writes on an O_APPEND descriptor land at the end whole
BobClawblaw Oct 14, 2026
a63ec9b
golden check: a request-log mismatch names the first differing line
BobClawblaw Oct 14, 2026
d7fb12f
golden check: the request log compares with LF endings on either side
BobClawblaw Oct 14, 2026
02d3e2e
qwen3_5: attention chunks follow each row's own keys, not the forward…
BobClawblaw Oct 15, 2026
e7744bc
qwen3_5: the DFlash2 config's divisors must be positive, and staging …
BobClawblaw Oct 15, 2026
48dcc42
Windows: 1.0.12's new code through the platform layer
BobClawblaw Oct 16, 2026
1d0a11f
docs: 1.0.12's new pages at the default port, 8888
BobClawblaw Oct 16, 2026
26e9b68
lanes recorder: a stream's new file is never made through a link ther…
BobClawblaw Oct 16, 2026
59be20e
qwen3_5 cuda: mixed-width MLX checkpoints, 2 to 8 bits in groups of 64
BobClawblaw Oct 14, 2026
d7e44b5
qwen3_5 cuda: mixed-width comments on one line each
BobClawblaw Oct 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Windows: the server goldens and the Cortheon fuzz step on Windows hosts
zig build test-golden and zig build fuzz-cortheon exist on every non-macOS
host since the golden step moved into zig/build/golden.zig, so the golden
check compiles against the platform layer on Windows:

- the platform's posix gains sockaddr.in, timeval, connect and kill for a
  child's handle (TerminateProcess; HUP has no equivalent), setsockopt turns
  a timeval for SO_RCVTIMEO or SO_SNDTIMEO into Winsock's milliseconds, and a
  socket read that times out is WouldBlock, as std.posix reports it.
- the check carries SystemRoot into the spawned server's environment, which
  Winsock needs to start, and drains the server's stdout after the port line
  on every host: the fake server logs each request there, and a full pipe
  (4 KiB on Windows) blocked it after sixteen cases.
- on Windows the check cannot send SIGTERM or SIGHUP, so the sigterm-exit-0
  outcome and the cases after a key rewrite are skipped and printed as such.

On Windows the goldens give 306 of 315 equal with the same nine known
differences as Linux, and the fuzz step passes its eight tests; the no-GPU
workflow's Windows job runs both.
  • Loading branch information
BobClawblaw committed Oct 16, 2026
commit 0baccf3687972fb83bb8e95a4a4cb222600b800b
5 changes: 5 additions & 0 deletions .github/workflows/no-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ jobs:
# The same host unit tests on Windows: the platform layer (zig/src/platform) over the UCRT, Win32 and Winsock.
- name: zig build test
run: zig build test
# The server goldens and the Cortheon fuzz harness on Windows too; the goldens skip the signal-driven cases.
- name: zig build test-golden
run: zig build test-golden
- name: zig build fuzz-cortheon
run: zig build fuzz-cortheon
39 changes: 35 additions & 4 deletions zig/src/platform/win_posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ pub const S = c.S;

pub const socket_t = isize;
pub const socklen_t = c_int;
pub const sockaddr = extern struct { family: u16, data: [14]u8 };
pub const sockaddr = extern struct {
family: u16,
data: [14]u8,

pub const in = extern struct { family: u16, port: u16, addr: u32, zero: [8]u8 = @splat(0) };
};
pub const timeval = c.timeval;

pub const AF = struct {
pub const UNIX: u32 = 1;
Expand All @@ -29,6 +35,8 @@ pub const SOL = struct {
pub const SO = struct {
/// SO_EXCLUSIVEADDRUSE: Windows' SO_REUSEADDR would let a second server take the port, the opposite of POSIX's.
pub const REUSEADDR: u32 = @bitCast(@as(i32, -5));
pub const RCVTIMEO: u32 = 0x1006;
pub const SNDTIMEO: u32 = 0x1005;
};
pub const SHUT = struct {
pub const RD: i32 = 0;
Expand Down Expand Up @@ -124,6 +132,9 @@ pub const system = struct {
pub fn bind(fd: socket_t, addr: *const anyopaque, len: anytype) c_int {
return if (ws.bind(fd, addr, @intCast(len)) != 0) failed() else 0;
}
pub fn connect(fd: socket_t, addr: *const anyopaque, len: anytype) c_int {
return if (ws.connect(fd, addr, @intCast(len)) != 0) failed() else 0;
}
pub fn listen(fd: socket_t, backlog: u31) c_int {
return if (ws.listen(fd, backlog) != 0) failed() else 0;
}
Expand Down Expand Up @@ -155,6 +166,13 @@ pub const system = struct {
};

pub fn setsockopt(fd: socket_t, level: i32, opt: u32, value: []const u8) error{SetSockOptFailed}!void {
if (opt == SO.RCVTIMEO or opt == SO.SNDTIMEO) {
// POSIX gives a timeval; Winsock takes the milliseconds as a DWORD
const tv: *align(1) const timeval = @ptrCast(value.ptr);
const ms: u32 = @intCast(@as(i64, tv.sec) * 1000 + @divTrunc(@as(i64, tv.usec), 1000));
if (ws.setsockopt(fd, level, @bitCast(opt), @ptrCast(&ms), @sizeOf(u32)) != 0) return error.SetSockOptFailed;
return;
}
if (ws.setsockopt(fd, level, @bitCast(opt), value.ptr, @intCast(value.len)) != 0) return error.SetSockOptFailed;
}

Expand Down Expand Up @@ -184,13 +202,26 @@ pub fn poll(fds: []pollfd, timeout_ms: i32) error{PollFailed}!usize {

extern "kernel32" fn Sleep(ms: u32) callconv(.winapi) void;

/// Receives from a socket; 0 is the peer's orderly close.
pub fn read(fd: socket_t, buf: []u8) error{ConnectionResetByPeer}!usize {
/// Receives from a socket; 0 is the peer's orderly close, and a receive timeout (SO.RCVTIMEO) is WouldBlock.
pub fn read(fd: socket_t, buf: []u8) error{ ConnectionResetByPeer, WouldBlock }!usize {
const n = ws.recv(fd, buf.ptr, len32(buf.len), 0);
if (n < 0) return error.ConnectionResetByPeer;
if (n < 0) return switch (ws.WSAGetLastError()) {
10035, 10060 => error.WouldBlock,
else => error.ConnectionResetByPeer,
};
return @intCast(n);
}

// ---- processes ----

extern "kernel32" fn TerminateProcess(process: *anyopaque, code: c_uint) callconv(.winapi) c_int;

/// kill for a spawned child's handle: TERM ends it with exit code 1; HUP and the rest have no Windows equivalent.
pub fn kill(process: std.os.windows.HANDLE, sig: SIG) error{ Unsupported, Unexpected }!void {
if (sig != .TERM) return error.Unsupported;
if (TerminateProcess(process, 1) == 0) return error.Unexpected;
}

// ---- signals: console control events ----

pub const SIG = enum(c_int) {
Expand Down
33 changes: 32 additions & 1 deletion zig/tests/server/golden_check.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Frozen server goldens for `zig build test-golden`, with the ten differences that are still known.
const std = @import("std");
const builtin = @import("builtin");
const platform = @import("sys");
const posix = std.posix;
const posix = platform.posix;
const Io = std.Io;
const wire = @import("wire.zig");
const Reply = wire.Reply;
Expand All @@ -22,6 +23,18 @@ const known_diffs = [_]Known{
.{ .group = "anthropic", .name = "tool-use-stream" },
};

/// Reads a spawned server's stdout to its end, so its log lines never fill the pipe (4 KiB on Windows).
fn drainStdout(io: Io, out: Io.File) void {
var buf: [4096]u8 = undefined;
var reader = out.reader(io, &buf);
while (true) {
_ = reader.interface.discardShort(buf.len) catch return;
}
}

/// The parent's SystemRoot, which a Windows child needs for Winsock; null elsewhere.
var system_root: ?[]const u8 = null;

fn isKnown(group: []const u8, name: []const u8) bool {
for (known_diffs) |k| {
if (std.mem.eql(u8, k.group, group) and std.mem.eql(u8, k.name, name)) return true;
Expand Down Expand Up @@ -355,6 +368,7 @@ fn spawnServer(a: std.mem.Allocator, io: Io, binary: []const u8, fixtures: []con
} else try argv.append(a, arg);
}
var map = std.process.Environ.Map.init(a);
if (system_root) |root| try map.put("SystemRoot", root); // Winsock refuses to start without it
try map.put("TENSORFOLD_NO_LIVE", "1");
try map.put("TF_FAKE_CONTEXT", context_tokens);
var it = env.iterator();
Expand Down Expand Up @@ -398,12 +412,16 @@ fn spawnServer(a: std.mem.Allocator, io: Io, binary: []const u8, fixtures: []con
const line = reader.interface.takeDelimiterExclusive('\n') catch return error.NoPortLine;
if (std.mem.startsWith(u8, line, "PORT ")) {
const port = try std.fmt.parseInt(u16, std.mem.trim(u8, line[5..], " \r"), 10);
// the server's log lines keep coming on stdout: drained, or a full pipe blocks the server
const drain = try std.Thread.spawn(.{}, drainStdout, .{ io, child.stdout.? });
drain.detach();
return .{ .child = child, .port = port, .log_path = log_path, .key_path = key_path };
}
}
}

pub fn main(init: std.process.Init) !void {
if (builtin.os.tag == .windows) system_root = init.environ_map.get("SystemRoot");
const gpa = init.gpa;
const io = init.io;
const args = try init.minimal.args.toSlice(init.arena.allocator());
Expand Down Expand Up @@ -436,15 +454,26 @@ pub fn main(init: std.process.Init) !void {
if (obj.get("cases")) |cases| {
for (cases.array.items) |case| try runCase(init.arena.allocator(), io, golden_dir, server.?.port, case);
}
var after_signal = false; // Windows: a step's cases after a signal it cannot send are skipped, and said so
for (obj.get("then").?.array.items) |then| {
const t = then.object;
const kind = t.get("kind").?.string;
const s = &server.?;
if (std.mem.eql(u8, kind, "cases")) {
if (after_signal) {
std.debug.print("SKIPPED {d} cases after a signal Windows cannot send\n", .{t.get("cases").?.array.items.len});
continue;
}
for (t.get("cases").?.array.items) |case| try runCase(init.arena.allocator(), io, golden_dir, s.port, case);
} else if (std.mem.eql(u8, kind, "sleep")) {
std.Io.sleep(io, .fromMilliseconds(@intFromFloat(t.get("seconds").?.float * 1000.0)), .awake) catch {};
} else if (std.mem.eql(u8, kind, "sigterm")) {
if (builtin.os.tag == .windows) {
std.debug.print("SKIPPED lifecycle/sigterm-exit-0: Windows has no SIGTERM to send, the server is ended\n", .{});
posix.kill(s.child.id.?, posix.SIG.TERM) catch {};
_ = s.child.wait(io) catch {};
continue;
}
posix.kill(s.child.id.?, posix.SIG.TERM) catch {};
const term = s.child.wait(io) catch return error.WaitFailed;
try outcomes.append(init.arena.allocator(), .{
Expand All @@ -471,8 +500,10 @@ pub fn main(init: std.process.Init) !void {
try fw.interface.writeAll(t.get("content").?.string);
try fw.interface.flush();
posix.kill(s.child.id.?, posix.SIG.HUP) catch {}; // the server rereads the key file, as the reference does
after_signal = builtin.os.tag == .windows;
} else if (std.mem.eql(u8, kind, "sighup")) {
posix.kill(s.child.id.?, posix.SIG.HUP) catch {};
after_signal = builtin.os.tag == .windows;
} else if (std.mem.eql(u8, kind, "terminate")) {
posix.kill(s.child.id.?, posix.SIG.TERM) catch {};
_ = s.child.wait(io) catch {};
Expand Down