Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 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
a1f54b4
qwen3_5 cuda: the drafter's top-k over many blocks a row, the same id…
BobClawblaw Oct 16, 2026
b3e306b
qwen3_5 cuda: group sums made once a projection input, the norm writi…
BobClawblaw Oct 16, 2026
cc0fc9e
qwen3_5 cuda: greedy rows' argmax in two stages over many blocks, a r…
BobClawblaw Oct 16, 2026
44005ad
qwen3_5 cuda: a group's sum a thread, in eight 16-byte loads, its ent…
BobClawblaw Oct 16, 2026
48a6622
lanes: a drafter may grow its own trees (Facts.tree_nodes), read back…
BobClawblaw Oct 16, 2026
aa214f9
qwen3_5 cuda: DFlash2 drafts best-first trees of up to 15 nodes, four…
BobClawblaw Oct 16, 2026
c7eea82
qwen3_5 cuda: the delta rule loads a row's inputs while the row befor…
BobClawblaw Oct 16, 2026
a76fd79
qwen3_5 cuda: a hold's chain, lanes and best-first tree in cuda_draft…
BobClawblaw Oct 16, 2026
d15bf69
qwen3_5 cuda: DFlash2 drafts 16-row blocks as the reference does; gro…
BobClawblaw Oct 16, 2026
6f7acde
qwen3_5 cuda: Landing's comment on one line
BobClawblaw Oct 16, 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
Next Next commit
Windows: a platform layer and host builds that pass
- zig/src/platform: `sys`, imported by every module (zig/build/sys.zig wires
  it). On POSIX it is std.c, std.posix and std.DynLib unchanged; on Windows
  win_c.zig gives libc's surface over the UCRT and Win32 (integer
  descriptors, directory descriptors, readdir, pread/pwrite, high-resolution
  sleep, monotonic clock, /tmp and /proc/self/exe mapped), win_posix.zig the
  server's sockets over Winsock, console events as SIGINT/SIGTERM, and
  LoadLibraryW for DynLib.
- std.c and std.DynLib calls go through `platform` (mechanical).
- build.zig routes Windows targets to the CUDA build.
- Server: socket closes and writes are explicit, the key file's mode check
  is skipped on NTFS (ACLs), descriptor limits are a no-op.
- shard_edit: the shard's map is released before the rename, since Windows
  refuses to replace a mapped file.
- Tests that need symlink privilege or mode bits skip on Windows.

zig build test-cuda-host passes on x86_64-windows.
  • Loading branch information
BobClawblaw committed Oct 16, 2026
commit b923e554c4ec60266944400a5ded9a737b56d9a7
6 changes: 4 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const server_build = @import("zig/build/server.zig");
const golden_build = @import("zig/build/golden.zig");
const contract_build = @import("zig/build/kernel_contract.zig");
const video_build = @import("zig/build/video.zig");
const sys_build = @import("zig/build/sys.zig");

comptime {
const required = std.mem.trim(u8, @embedFile(".zig-version"), "\r\n");
Expand Down Expand Up @@ -163,14 +164,14 @@ pub fn build(b: *std.Build) void {
merge_build.targets(b, target, optimize); // tf-merge-check and test-merge, host only on every OS
switch (target.result.os.tag) {
.macos => metalTargets(b, target, optimize, draft_ids, build_options, test_step),
.linux => cuda_build.targets(b, target, optimize, draft_ids, build_options),
.linux, .windows => cuda_build.targets(b, target, optimize, draft_ids, build_options),
else => {},
}
const xgrammar = grammar_build.option(b);
dist_build.targets(b, draft_ids, build_options, release_version, xgrammar);
cuda_build.hostTests(b, draft_ids, build_options, test_step, target.result.os.tag != .macos);
xpu_build.hostTests(b, test_step);
if (target.result.os.tag == .linux) {
if (target.result.os.tag == .linux or target.result.os.tag == .windows) {
// the engine seam's tests (lane_host.zig and its siblings), which the macOS branch runs from its own api module
const lanes_mod = b.createModule(.{ .root_source_file = b.path("zig/src/core/lanes/lanes.zig"), .target = target, .optimize = optimize, .link_libc = true });
const api_mod = b.createModule(.{ .root_source_file = b.path("zig/src/core/engine_api.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{.{ .name = "lanes", .module = lanes_mod }} });
Expand Down Expand Up @@ -204,6 +205,7 @@ pub fn build(b: *std.Build) void {
b.step("test-learn-warning", "CPU production-log refusal, backoff and recovery test").dependOn(&warning_run.step);
grammar_build.steps(b, target, xgrammar);
contract_build.hostTests(b);
sys_build.wire(b);
}

/// `zig build native -Dcpu=apple_m1`: tensorfold-native with the Metal engines for the Python package's bundle (a native M5 build traps on M1-M4).
Expand Down
41 changes: 41 additions & 0 deletions zig/build/sys.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//! `sys` (zig/src/platform/sys.zig) for every module the build compiles: one walk of the step graph after it is
//! declared, so no module's declaration needs to name it.

const std = @import("std");

pub fn wire(b: *std.Build) void {
var seen_steps: std.AutoHashMapUnmanaged(*std.Build.Step, void) = .empty;
var seen_mods: std.AutoHashMapUnmanaged(*std.Build.Module, void) = .empty;
var per_target: std.StringHashMapUnmanaged(*std.Build.Module) = .empty;
var w: Walk = .{ .b = b, .seen_steps = &seen_steps, .seen_mods = &seen_mods, .per_target = &per_target };
for (b.top_level_steps.values()) |top| w.step(&top.step);
}

const Walk = struct {
b: *std.Build,
seen_steps: *std.AutoHashMapUnmanaged(*std.Build.Step, void),
seen_mods: *std.AutoHashMapUnmanaged(*std.Build.Module, void),
per_target: *std.StringHashMapUnmanaged(*std.Build.Module),

fn step(w: *Walk, s: *std.Build.Step) void {
if ((w.seen_steps.getOrPut(w.b.allocator, s) catch @panic("OOM")).found_existing) return;
if (s.cast(std.Build.Step.Compile)) |compile| w.module(compile.root_module, compile.root_module.resolved_target);
for (s.dependencies.items) |dep| w.step(dep);
}

fn module(w: *Walk, m: *std.Build.Module, inherited: ?std.Build.ResolvedTarget) void {
if ((w.seen_mods.getOrPut(w.b.allocator, m) catch @panic("OOM")).found_existing) return;
const target = m.resolved_target orelse inherited orelse w.b.graph.host;
// only TensorFold's own sources see it; the sys module itself and generated modules do not
if (m.root_source_file) |root| if (root == .src_path and !m.import_table.contains("sys") and !std.mem.endsWith(u8, root.src_path.sub_path, "platform/sys.zig"))
m.addImport("sys", w.sys(target));
for (m.import_table.values()) |dep| w.module(dep, target);
}

fn sys(w: *Walk, target: std.Build.ResolvedTarget) *std.Build.Module {
const key = target.result.zigTriple(w.b.allocator) catch @panic("OOM");
const slot = w.per_target.getOrPut(w.b.allocator, key) catch @panic("OOM");
if (!slot.found_existing) slot.value_ptr.* = w.b.createModule(.{ .root_source_file = w.b.path("zig/src/platform/sys.zig"), .target = target, .link_libc = true });
return slot.value_ptr.*;
}
};
23 changes: 12 additions & 11 deletions zig/src/core/checkpoint_metal.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The shared safetensors index read into Metal buffers: one shared buffer a shard, each tensor at its data offset.
const std = @import("std");
const platform = @import("sys");
const mtl = @import("metal");
const st = @import("safetensors.zig");

Expand Down Expand Up @@ -33,7 +34,7 @@ pub const Deferred = struct { file: usize, at: usize, bytes: usize, dtype: DType
pub const Later = *const fn (name: []const u8, rank: usize) bool;

/// A shard file that deferred tensors stay in, and its address-only views' reservation once one is asked for.
const File = struct { fd: std.c.fd_t, end: usize = 0, views: ?[]align(std.heap.page_size_min) u8 = null };
const File = struct { fd: platform.c.fd_t, end: usize = 0, views: ?[]align(std.heap.page_size_min) u8 = null };

/// Kept tensors pack at this alignment; reads this large or larger run on 8 threads.
pub const alignment = 256;
Expand Down Expand Up @@ -63,22 +64,22 @@ pub const Checkpoint = struct {

/// As addFileSelected; with `later`, the tensors it names stay in the file for `read` and the rest pack into one buffer.
pub fn addFileSplit(self: *Checkpoint, device: mtl.Device, path: [:0]const u8, prefix: []const u8, selected: ?[]const u8, later: ?Later) !void {
const fd = std.c.open(path, .{ .ACCMODE = .RDONLY });
const fd = platform.c.open(path, .{ .ACCMODE = .RDONLY });
if (fd < 0) {
std.log.err("cannot open {s}", .{path});
return error.OpenFailed;
}
var held = false;
defer if (!held) {
_ = std.c.close(fd);
_ = platform.c.close(fd);
};
var head: [8]u8 = undefined;
try readAll(fd, &head, 0);
const header_len = std.mem.readInt(u64, &head, .little);
const header = try self.allocator.alloc(u8, header_len);
defer self.allocator.free(header);
try readAll(fd, header, 8);
const end = std.c.lseek(fd, 0, std.c.SEEK.END);
const end = platform.c.lseek(fd, 0, platform.c.SEEK.END);
const data_start = 8 + header_len;
const data_len: usize = @as(usize, @intCast(end)) - data_start;

Expand Down Expand Up @@ -114,7 +115,7 @@ pub const Checkpoint = struct {
}

/// The kept entries packed into one buffer, the `later` ones recorded for `read`; `held` once the file stays open.
fn split(self: *Checkpoint, device: mtl.Device, fd: std.c.fd_t, held: *bool, data_start: usize, entries: st.Header, prefix: []const u8, later: Later) !void {
fn split(self: *Checkpoint, device: mtl.Device, fd: platform.c.fd_t, held: *bool, data_start: usize, entries: st.Header, prefix: []const u8, later: Later) !void {
var arena = std.heap.ArenaAllocator.init(self.allocator);
defer arena.deinit();
const names = try arena.allocator().alloc([]const u8, entries.count());
Expand Down Expand Up @@ -184,7 +185,7 @@ pub const Checkpoint = struct {
/// Close the files the deferred tensors live in, once load has read them.
pub fn closeFiles(self: *Checkpoint) void {
for (self.files.items) |*file| if (file.fd >= 0) {
_ = std.c.close(file.fd);
_ = platform.c.close(file.fd);
file.fd = -1;
};
}
Expand Down Expand Up @@ -300,16 +301,16 @@ pub const Stage = struct {
}
};

fn readAll(fd: std.c.fd_t, dest: []u8, at: usize) !void {
fn readAll(fd: platform.c.fd_t, dest: []u8, at: usize) !void {
var done: usize = 0;
while (done < dest.len) {
const n = std.c.pread(fd, dest.ptr + done, dest.len - done, @intCast(at + done));
const n = platform.c.pread(fd, dest.ptr + done, dest.len - done, @intCast(at + done));
if (n <= 0) return error.ShortRead;
done += @intCast(n);
}
}

const Part = struct { fd: std.c.fd_t, dest: []u8, at: usize, failed: bool = false };
const Part = struct { fd: platform.c.fd_t, dest: []u8, at: usize, failed: bool = false };

fn readPart(part: *Part) void {
readAll(part.fd, part.dest, part.at) catch {
Expand All @@ -318,7 +319,7 @@ fn readPart(part: *Part) void {
}

/// pread `dest.len` bytes from `at` on 8 threads (page cache or disk, the copy is the load's main cost).
fn readParallel(fd: std.c.fd_t, dest: []u8, at: usize) !void {
fn readParallel(fd: platform.c.fd_t, dest: []u8, at: usize) !void {
const n_threads = 8;
var parts: [n_threads]Part = undefined;
var threads: [n_threads]?std.Thread = @splat(null);
Expand All @@ -335,7 +336,7 @@ fn readParallel(fd: std.c.fd_t, dest: []u8, at: usize) !void {
}

/// One tensor's bytes: small ones on this thread, large ones on 8.
fn readInto(fd: std.c.fd_t, dest: []u8, at: usize) !void {
fn readInto(fd: platform.c.fd_t, dest: []u8, at: usize) !void {
return if (dest.len >= parallel_bytes) readParallel(fd, dest, at) else readAll(fd, dest, at);
}

Expand Down
25 changes: 13 additions & 12 deletions zig/src/core/direct_io.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Positional reads that skip the page cache (O_DIRECT on Linux): 4 KiB-aligned spans into aligned buffers.

const std = @import("std");
const platform = @import("sys");
const builtin = @import("builtin");

/// Offset, length and buffer alignment a direct read needs (the logical block size of every NVMe we run on).
Expand All @@ -20,22 +21,22 @@ pub fn fits(bytes: usize) usize {
}

pub const File = struct {
fd: std.c.fd_t,
fd: platform.c.fd_t,
direct: bool,

/// `path` read-only, direct when its file system allows it, else through the page cache.
pub fn open(path: [:0]const u8) !File {
if (builtin.os.tag == .linux) {
const fd = std.c.open(path, .{ .ACCMODE = .RDONLY, .CLOEXEC = true, .DIRECT = true });
const fd = platform.c.open(path, .{ .ACCMODE = .RDONLY, .CLOEXEC = true, .DIRECT = true });
if (fd >= 0) return .{ .fd = fd, .direct = true };
}
const fd = std.c.open(path, .{ .ACCMODE = .RDONLY, .CLOEXEC = true });
const fd = platform.c.open(path, .{ .ACCMODE = .RDONLY, .CLOEXEC = true });
if (fd < 0) return error.FileNotFound;
return .{ .fd = fd, .direct = false };
}

pub fn close(f: *File) void {
_ = std.c.close(f.fd);
_ = platform.c.close(f.fd);
f.* = undefined;
}

Expand All @@ -46,11 +47,11 @@ pub const File = struct {
}
};

fn sysPread(_: *anyopaque, fd: std.c.fd_t, buf: [*]u8, len: usize, offset: u64) isize {
return std.c.pread(fd, buf, len, @intCast(offset));
fn sysPread(_: *anyopaque, fd: platform.c.fd_t, buf: [*]u8, len: usize, offset: u64) isize {
return platform.c.pread(fd, buf, len, @intCast(offset));
}

fn readAt(f: File, buf: Buffer, offset: u64, len: usize, ctx: *anyopaque, pread: *const fn (*anyopaque, std.c.fd_t, [*]u8, usize, u64) isize) ![]u8 {
fn readAt(f: File, buf: Buffer, offset: u64, len: usize, ctx: *anyopaque, pread: *const fn (*anyopaque, platform.c.fd_t, [*]u8, usize, u64) isize) ![]u8 {
const lo = std.mem.alignBackward(u64, offset, alignment);
const want: usize = @intCast(offset + len - lo);
const whole = span(offset, len);
Expand All @@ -62,8 +63,8 @@ fn readAt(f: File, buf: Buffer, offset: u64, len: usize, ctx: *anyopaque, pread:
const ask = whole - at;
const n = pread(ctx, f.fd, buf.ptr + at, ask, lo + @as(u64, @intCast(at)));
if (n < 0) {
if (std.c.errno(n) == .INTR) continue;
std.log.err("read of {d} bytes at {d} failed: {t}", .{ ask, lo + at, std.c.errno(n) });
if (platform.c.errno(n) == .INTR) continue;
std.log.err("read of {d} bytes at {d} failed: {t}", .{ ask, lo + at, platform.c.errno(n) });
return error.ReadFailed;
}
if (n == 0) return error.EndOfFile;
Expand All @@ -89,15 +90,15 @@ test "direct reads return the same bytes as buffered reads" {
var f = try File.open("/proc/self/exe");
defer f.close();
// The reference uses the page cache, so its unaligned reads do not inherit O_DIRECT.
var plain: File = .{ .fd = std.c.open("/proc/self/exe", .{ .ACCMODE = .RDONLY, .CLOEXEC = true }), .direct = false };
var plain: File = .{ .fd = platform.c.open("/proc/self/exe", .{ .ACCMODE = .RDONLY, .CLOEXEC = true }), .direct = false };
try std.testing.expect(plain.fd >= 0);
defer plain.close();
const buf = try gpa.alignedAlloc(u8, .fromByteUnits(alignment), 1 << 20);
defer gpa.free(buf);
const want = try gpa.alloc(u8, 1 << 19);
defer gpa.free(want);
for ([_][2]usize{ .{ 0, 1 }, .{ 1, 4095 }, .{ 4095, 2 }, .{ 12345, 100000 }, .{ 8192, 1 << 19 } }) |c| {
const n = std.c.pread(plain.fd, want.ptr, c[1], @intCast(c[0]));
const n = platform.c.pread(plain.fd, want.ptr, c[1], @intCast(c[0]));
try std.testing.expectEqual(@as(isize, @intCast(c[1])), n);
try std.testing.expectEqualSlices(u8, want[0..c[1]], try f.read(buf, c[0], c[1]));
}
Expand All @@ -111,7 +112,7 @@ const Script = struct {
calls: usize = 0,
bad: bool = false,

fn pread(ctx: *anyopaque, _: std.c.fd_t, buf: [*]u8, len: usize, offset: u64) isize {
fn pread(ctx: *anyopaque, _: platform.c.fd_t, buf: [*]u8, len: usize, offset: u64) isize {
const s: *Script = @ptrCast(@alignCast(ctx));
if (s.calls < s.offs.len) s.offs[s.calls] = offset;
s.calls += 1;
Expand Down
13 changes: 8 additions & 5 deletions zig/src/core/heat.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Opt-in wait before a prompt chunk when the hottest thermal zone is above a band.
const std = @import("std");
const platform = @import("sys");

pub const default_root = "/sys/class/thermal";

Expand Down Expand Up @@ -129,7 +130,7 @@ fn noteNoZone(root: []const u8) void {
}

fn envSpan(name: [*:0]const u8) ?[]const u8 {
const p = std.c.getenv(name) orelse return null;
const p = platform.c.getenv(name) orelse return null;
const s = std.mem.span(p);
if (s.len == 0) return null;
return s;
Expand Down Expand Up @@ -194,13 +195,15 @@ test "the chunk runs under the high band, and a hot reading waits until the low
try std.testing.expectEqual(@as(u32, 1), stuck.sleeps); // a cancel ends the wait after the pause it came in
}

extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: i32) i32;
extern "c" fn unsetenv(name: [*:0]const u8) i32;
const env = if (@import("builtin").os.tag == .windows) @import("sys").c else struct {
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: i32) i32;
extern "c" fn unsetenv(name: [*:0]const u8) i32;
};

fn putEnv(name: [*:0]const u8, value: ?[*:0]const u8) void {
if (value) |v| {
_ = setenv(name, v, 1);
} else _ = unsetenv(name);
_ = env.setenv(name, v, 1);
} else _ = env.unsetenv(name);
}

test "TF_HEAT_HIGH and TF_HEAT_LOW set the bands together, and TF_HEAT_ROOT the zones' folder" {
Expand Down
5 changes: 3 additions & 2 deletions zig/src/core/lanes/cost_cache.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Timed costs are measured once per engine build, chip and model shape, then read back by later loads.
const std = @import("std");
const platform = @import("sys");
const Allocator = std.mem.Allocator;

const magic = "TFWC2\n";
Expand Down Expand Up @@ -53,7 +54,7 @@ fn hashPart(h: *std.crypto.hash.sha2.Sha256, part: []const u8) void {
}

fn path(a: Allocator, k: [32]u8, suffix: []const u8) !?[]u8 {
const home = std.c.getenv("HOME") orelse return null;
const home = platform.c.getenv("HOME") orelse return null;
return try std.fmt.allocPrint(a, "{s}/.cache/tensorfold/window-costs/{s}{s}", .{ std.mem.span(home), std.fmt.bytesToHex(k, .lower), suffix });
}

Expand All @@ -78,7 +79,7 @@ pub fn save(comptime T: type, a: Allocator, io: std.Io, k: [32]u8, value: T) voi
const p = (path(a, k, ".bin") catch return) orelse return;
defer a.free(p);
std.Io.Dir.cwd().createDirPath(io, std.fs.path.dirname(p) orelse return) catch return;
const temp = std.fmt.allocPrint(a, "{s}.{d}.tmp", .{ p, std.c.getpid() }) catch return;
const temp = std.fmt.allocPrint(a, "{s}.{d}.tmp", .{ p, platform.c.getpid() }) catch return;
defer a.free(temp);
const bytes = std.mem.concat(a, u8, &.{ magic, std.mem.asBytes(&value) }) catch return;
defer a.free(bytes);
Expand Down
3 changes: 2 additions & 1 deletion zig/src/core/lanes/grammar.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Structured output: libtfgrammar (xgrammar, loaded at the first structured request) and a stream's grammar walk.

const std = @import("std");
const platform = @import("sys");
const builtin = @import("builtin");
const Allocator = std.mem.Allocator;

Expand Down Expand Up @@ -37,7 +38,7 @@ fn load(io: std.Io, a: Allocator) ?Fns {
library,
};
var dl = for (names) |name| {
break std.DynLib.open(name) catch continue;
break platform.DynLib.open(name) catch continue;
} else return null;
var f: Fns = undefined;
const info = @typeInfo(Fns).@"struct";
Expand Down
Loading