Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions docs/WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ floor) with Zig 0.17.0 from the portable zip, on main at 9d6f1d78c (2026-11-04):
source build gets it.
- The `python3` the tools' commands name may be the Microsoft Store alias on Windows; a python.org install is `python`.

### Field notes

- `tensorfold benchmark` is not supported on Windows; the command itself answers "not supported on Windows yet:
run tensorfold serve and a client against it". Measure with a client against `serve`.
- Under WDDM the CUDA free-memory query does not count other processes' allocations: `tf-cuda-test info` reported
`16375 MiB total, 15111 MiB free` while another process held 6,337 MiB by `nvidia-smi`. When another GPU process
is running, size from `nvidia-smi`, not the reported free figure.
- A clone made before `91e77c106` (`* text=auto eol=lf`, 2026-10-21) keeps CRLF in files unchanged since, because git
does not renormalise them. The build then panics at configure time with `... boundaries changed` (the panic text
now names line endings). `git add --renormalize .` alone updates only the index; the working tree needs
`git rm -r --cached . && git reset --hard` (which discards local edits) or a fresh clone.

### HIP

Add `-Dhip=true -Dhip-arch=<arch>` and name a HIP compiler; the build takes `hipcc.exe` first and `hipcc.bat` second,
Expand Down
1 change: 1 addition & 0 deletions tools/zig/env_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Functions reading the variable an argument names: file, function, argument, callers (CALLERS in env_names.py).
WRAPPERS = (
("zig/src/cli/hub.zig", "envValue", 1, "public"),
("zig/src/core/hub_cache.zig", "envValue", 1, (("zig/src/core/hub_cache.zig", r"(?<![\w.])envValue\(", 1),)),
("zig/src/cli/plan.zig", "f", 1, (("zig/src/cli/plan.zig", r"(?<![\w.])get\(", 1),)),
("zig/src/cli/pull.zig", "envValue", 1, "public"),
("zig/src/cli/pull_route.zig", "get", 1, "file"),
Expand Down
1 change: 1 addition & 0 deletions zig/build/checkpoint_config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub fn tests(b: *std.Build) void {
}

pub fn wire(b: *std.Build) void {
@import("hub_cache.zig").wire(b); // first: hub_cache reads checkpoint_config, so this walk below then wires it too
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;
Expand Down
8 changes: 4 additions & 4 deletions zig/build/cuda_fatbin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ pub fn fatbin(b: *std.Build, nvcc: []const u8, version: std.Build.LazyPath, k: K
run.addArg("-o");
const out = run.addOutputFileArg(b.fmt("{s}.fatbin", .{k.name}));
if (std.mem.eql(u8, k.name, "qwen4_gdn")) {
const text = @import("../src/families/flashnext/hybrid_sources.zig").Gdn.cuda(b.allocator, @embedFile("../kernels/cuda/flashnext_gdn.cu")) catch @panic("Flash Next GDN source changed; regenerate Qwen4 specialization");
const controlled = @import("../src/families/qwen4/gdn_control_source.zig").cuda(b.allocator, text) catch @panic("Qwen4 GDN control boundaries changed");
const text = @import("../src/families/flashnext/hybrid_sources.zig").Gdn.cuda(b.allocator, @embedFile("../kernels/cuda/flashnext_gdn.cu")) catch @panic("Flash Next GDN source changed; a stale CRLF checkout can read as changed; regenerate Qwen4 specialization");
const controlled = @import("../src/families/qwen4/gdn_control_source.zig").cuda(b.allocator, text) catch @panic("Qwen4 GDN control boundaries changed; a stale CRLF checkout can read as changed");
run.addFileArg(b.addWriteFiles().add("qwen4_gdn.cu", controlled));
} else if (std.mem.eql(u8, k.name, "qwen4_ple")) {
const text = @import("../src/families/flashnext/hybrid_ple_source.zig").cuda(b.allocator) catch @panic("Flash Next PLE source changed; update Qwen4 geometry adapter");
const controlled = @import("../src/families/qwen4/ple_control_source.zig").cuda(b.allocator, text) catch @panic("Qwen4 PLE controls changed");
const text = @import("../src/families/flashnext/hybrid_ple_source.zig").cuda(b.allocator) catch @panic("Flash Next PLE source changed; a stale CRLF checkout can read as changed; update Qwen4 geometry adapter");
const controlled = @import("../src/families/qwen4/ple_control_source.zig").cuda(b.allocator, text) catch @panic("Qwen4 PLE controls changed; a stale CRLF checkout can read as changed");
run.addFileArg(b.addWriteFiles().add("qwen4_ple.cu", controlled));
} else run.addFileArg(b.path(b.fmt("zig/kernels/cuda/{s}.cu", .{k.src orelse k.name})));
return out;
Expand Down
40 changes: 40 additions & 0 deletions zig/build/hub_cache.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! The cache-layout walk shared by the CLI and the native server, one module for every build consumer.

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;
// Generated modules do not read the cache layout.
if (m.root_source_file) |root| if (root == .src_path and !m.import_table.contains("hub_cache") and !std.mem.endsWith(u8, root.src_path.sub_path, "core/hub_cache.zig"))
m.addImport("hub_cache", w.reader(target));
for (m.import_table.values()) |dep| w.module(dep, target);
}

fn reader(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/core/hub_cache.zig"), .target = target, .link_libc = true });
return slot.value_ptr.*;
}
};
4 changes: 3 additions & 1 deletion zig/build/muse.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ pub fn tool(b: *std.Build, m: *std.Build.Module, strip: ?bool) void {
for ([_][]const u8{ "cuda", "core", "tp", "tp_kernel" }) |name| root.addImport(name, m.import_table.get(name).?);
root.addImport("muse_spark", m);
const exe = b.addExecutable(.{ .name = "tf-muse", .root_module = root });
b.installArtifact(exe);
// POSIX-only: the fabric and tp imports have no Windows port.
const os = if (m.resolved_target) |t| t.result.os.tag else b.graph.host.result.os.tag;
if (os != .windows) b.installArtifact(exe);
b.step("tf-muse", "Muse Spark's rank 1 (follow) and device checks").dependOn(&b.addInstallArtifact(exe, .{}).step);
}

Expand Down
5 changes: 3 additions & 2 deletions zig/build/qwen3_asr_cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ pub fn tool(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.built
const family = b.createModule(.{ .root_source_file = b.path("zig/src/families/qwen3_asr/qwen3_asr_cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core }, .{ .name = "qwen3_pass", .module = pass } } });
const main = b.createModule(.{ .root_source_file = b.path("zig/tests/qwen3_asr_cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .strip = strip, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "qwen3_asr", .module = family }, .{ .name = "tokenizer", .module = tokenizer } } });
const exe = b.addExecutable(.{ .name = "tf-qwen3-asr", .root_module = main });
b.installArtifact(exe);
// POSIX-only: qwen3_asr_cuda.zig reads CLOCK_MONOTONIC through std.c, which Windows lacks.
if (target.result.os.tag != .windows) b.installArtifact(exe);
b.step("tf-qwen3-asr", "Build tf-qwen3-asr, Qwen3-ASR's CUDA tower and language model on a clip").dependOn(&b.addInstallArtifact(exe, .{}).step);
const forced = b.createModule(.{ .root_source_file = b.path("zig/tests/qwen3_asr_forced.zig"), .target = target, .optimize = optimize, .link_libc = true, .strip = strip, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "qwen3_asr", .module = family } } });
const forced_exe = b.addExecutable(.{ .name = "tf-qwen3-asr-forced", .root_module = forced });
b.installArtifact(forced_exe);
if (target.result.os.tag != .windows) b.installArtifact(forced_exe);
b.step("tf-qwen3-asr-forced", "Build tf-qwen3-asr-forced, a clip teacher-forced on a case under the tie rule").dependOn(&b.addInstallArtifact(forced_exe, .{}).step);
}
2 changes: 1 addition & 1 deletion zig/build/qwen4_cuda_attention_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const std = @import("std");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 CUDA attention source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 CUDA attention source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_cuda_attention_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_gdn_cuda_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/flashnext/hybrid_sources.zig");
const ctl = @import("../src/families/qwen4/gdn_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 CUDA recurrence source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 CUDA recurrence source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_gdn_cuda_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_gdn_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
const gen = @import("../src/families/flashnext/hybrid_sources.zig");
const ctl = @import("../src/families/qwen4/gdn_control_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 GDN source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 GDN source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_gdn_native_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_hc_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
const hc = @import("../src/families/qwen4/metal_hc.zig");
const ctl = @import("../src/families/qwen4/hc_control_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 HC source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 HC source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_hc_native_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_metal_sources.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn steps(b: *std.Build) *std.Build.Step {
const emit = b.step("emit-qwen4-metal-sources", "Write Qwen4 runtime libraries and controls without compiling shaders");
const check = b.step("test-qwen4-metal-sources", "Compile generated Qwen4 Metal libraries without a device run");
const files = b.addWriteFiles();
const entries = @import("../src/families/qwen4/metal_source_inventory.zig").generate(b.allocator) catch |err| std.debug.panic("Qwen4 source inventory changed: {t}", .{err});
const entries = @import("../src/families/qwen4/metal_source_inventory.zig").generate(b.allocator) catch |err| std.debug.panic("Qwen4 source inventory changed: {t}; a stale CRLF checkout can read as changed", .{err});
const version = @import("metal_targets.zig").mlxMetalStd(b);
for (entries) |entry| {
const file = files.add(b.fmt("{s}.metal", .{entry.name}), entry.text);
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_node_attention_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
const gen = @import("../src/families/qwen4/metal_attention_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 tiny attention source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 tiny attention source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_node_attention.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_ple_cuda_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/flashnext/hybrid_ple_source.zig");
const ctl = @import("../src/families/qwen4/ple_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 CUDA lexical boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 CUDA lexical boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_ple_cuda_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_ple_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const cfg = @import("../src/families/qwen4/config.zig");
const sources = @import("../src/families/qwen4/metal_ple.zig");
const controls = @import("../src/families/qwen4/ple_control_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 PLE source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 PLE source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_ple_native_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_qsa_attn_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/qwen4/metal_attention_source.zig");
const ctl = @import("../src/families/qwen4/qsa_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 attention source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 attention source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_qsa_attn_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_qsa_norm_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/qwen4/metal_attention_source.zig");
const ctl = @import("../src/families/qwen4/qsa_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 QSA frontend boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 QSA frontend boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_qsa_norm_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_qsa_scores_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/qwen4/metal_attention_source.zig");
const ctl = @import("../src/families/qwen4/qsa_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 score source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 score source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_qsa_scores_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
2 changes: 1 addition & 1 deletion zig/build/qwen4_qsa_select_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const gen = @import("../src/families/qwen4/metal_attention_source.zig");
const ctl = @import("../src/families/qwen4/qsa_control_source.zig");
const edit = @import("../src/families/flashnext/geometry_source.zig");
pub fn wire(b: *std.Build, module: *std.Build.Module) void {
const text = generate(b.allocator) catch @panic("Qwen4 selection source boundaries changed");
const text = generate(b.allocator) catch @panic("Qwen4 selection source boundaries changed; a stale CRLF checkout can read as changed");
module.addIncludePath(b.path("zig/tests/qwen4"));
module.addCSourceFile(.{ .file = b.addWriteFiles().add("qwen4_qsa_select_host.cpp", text), .flags = &.{ "-std=c++20", "-fno-exceptions", "-fno-fast-math", "-ffp-contract=off", "-fno-strict-aliasing" } });
}
Expand Down
Loading
Loading