Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a3303c7
CUDA keyed graph cache and device arena, both off until a family inst…
jayleaton Oct 10, 2026
69e8a65
A failed CUDA kernel launch names its kernel and launch configuration…
jayleaton Oct 10, 2026
d7e89df
fix(cuda): correct RDMA VMM capability attribute
jrb-ai Oct 10, 2026
5826f89
Graph cache: a capture is freed until the map holds it, the keep floo…
jayleaton Oct 11, 2026
5806e55
CUDA arena: the address maps are rehashed before tombstones fill them
jayleaton Oct 11, 2026
d335520
Graph cache: TF_GRAPH_CACHE=0 or off runs every step eagerly in any f…
jayleaton Oct 14, 2026
864fe25
Graph cache: effective settings have one digest for ranks to compare …
jayleaton Oct 16, 2026
7ff83d8
Tensor parallelism across CUDA processes: bootstrap, NCCL, mailbox an…
jayleaton Oct 10, 2026
9af2ea2
TP tests: a drain on rank 0 then its clean stop ends rank 1's loop at…
jayleaton Oct 10, 2026
7c9a26e
TP RoCE: with no TF_TP_ROCE_HCA, each rank picks the ports on an IPv4…
jayleaton Oct 11, 2026
8ebb0be
TP README: when -Dtp-nvcc, TF_TP_ROCE_HCA, NCCL_IB_HCA, NCCL_SOCKET_I…
jayleaton Oct 11, 2026
e9e0056
TP test runner: a binary built without the mailbox kernel refuses the…
jayleaton Oct 11, 2026
0472cbf
TP RoCE: every RDMA post is bounds-checked before the verb, and peers…
jayleaton Oct 11, 2026
9688398
TP RoCE: no RDMA write past 1 MiB, and boot refuses any setting that …
jayleaton Oct 11, 2026
72132f0
TP RoCE: TF_TP_ROCE_CHUNKED_KB gathers strides past the slot in slot-…
jayleaton Oct 11, 2026
bf19238
TP RoCE: a failed transport halts its QPs, drains them and keeps its …
jayleaton Oct 11, 2026
beae7e8
TP RoCE: tf-tp-test failfast V transport checks the failed-transport …
jayleaton Oct 11, 2026
602aad5
Fix RoCE test smaps lookup for merged mappings
jayleaton Oct 11, 2026
890dfc6
TP RoCE: run_hosts.sh gives NCCL the RoCE picker's ports when neither…
jayleaton Oct 11, 2026
a3e2fb1
TP NCCL: all_reduce's doc says NCCL adds in its ring's order, so its …
jayleaton Oct 14, 2026
62a75ae
TP: keep Linux-only transport host tests off macOS builds
jayleaton Oct 15, 2026
e2504f6
TP: bootstrap compares the graph cache's effective settings, so a ran…
jayleaton Oct 16, 2026
5410eac
Session memory for paged-KV families: page pool, prefix trie, RAM res…
jayleaton Oct 10, 2026
0d0bdb2
Sessions: the page map is rehashed before tombstones fill it
jayleaton Oct 11, 2026
2cf61d3
Sessions: honor zero residency budgets and reserve uncapped requests
jayleaton Oct 15, 2026
dcdc30c
Keep the Linux NVMe lane test out of portable host tests
cwschroeder 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
6 changes: 6 additions & 0 deletions RUNBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ budget free for the next states.
`TF_HEAT_HIGH` and `TF_HEAT_LOW`, in degrees Celsius and set together, make each prompt chunk wait while the hottest
thermal zone (under `/sys/class/thermal`, or `TF_HEAT_ROOT`) is above the high band, until it is at or under the low one.
The server logs `heat_wait_s`, a cancel ends the wait, and the reply's tokens do not change.
`TF_GRAPH_CACHE=0` (or `off`, any case) runs every step eagerly in any family that installs the keyed CUDA graph cache,
without a rebuild. Set it alike on every tensor-parallel rank: an off rank never joins the cache's per-miss vote, so a
rank left on would wait at its first miss, and only the off rank logs the switch. Ranks that share a cache compare
`Settings.digest` of their effective settings at start, before building it, and refuse to start when they differ.
A tensor-parallel family passes its cache settings in the TP config; the bootstrap then compares them and refuses to
start on every rank, naming TF_GRAPH_CACHE among the settings that must match.
Archives whose names contain `host-only` are CPU verification artifacts and cannot serve CUDA inference.

## Flash Next and paired Metal serving
Expand Down
6 changes: 6 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ values agree within fp16/bf16 rounding (under 0.01 on random groups), not bit fo
dequant are written for TensorFold and checked against an independent reference of that arithmetic. The native engine
has no quantized KV cache and refuses `--kv-dtype`.

The Zig tensor-parallel fabric's RoCE path (`zig/src/fabric/tp/mailbox.cu`, `roce.zig`, `roce_verbs.zig`) adapts
the one-shot all-gather protocol of [b12x](https://github.com/local-inference-lab/b12x)'s RoCEnante
(`b12x/comm/roce/`, PRs #295 and #315): a device-resident epoch, sequence flags after each payload, two slots by
sequence parity and a timeout that fails the transport. Copyright 2026 Luke Alonso and the b12x contributors,
Apache License 2.0 (see [the license text](LICENSES/Apache-2.0.txt)); b12x ships no NOTICE file.

## Vendored code and weights

In the Python engine, frozen at 0.6.6, `src/tensorfold/drafters/vendor/z_lab_dflash/model_mlx.py` is the unmodified
Expand Down
4 changes: 4 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const counters_build = @import("zig/build/metal_counters.zig");
const exl3_build = @import("zig/build/exl3.zig");
const exlr8_build = @import("zig/build/exlr8.zig");
const golden_build = @import("zig/build/golden.zig");
const tp_build = @import("zig/build/tp.zig");
const sessions_build = @import("zig/build/sessions.zig");

comptime {
const required = std.mem.trim(u8, @embedFile(".zig-version"), "\r\n");
Expand Down Expand Up @@ -189,6 +191,8 @@ pub fn build(b: *std.Build) void {
test_step.dependOn(&warning_run.step);
b.step("test-learn-warning", "CPU production-log refusal, backoff and recovery test").dependOn(&warning_run.step);
grammar_build.steps(b, target, xgrammar);
tp_build.add(b, target, optimize, test_step);
sessions_build.add(b, test_step);
}

/// `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
20 changes: 20 additions & 0 deletions zig/build/sessions.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Session memory: portable bookkeeping tests everywhere, NVMe tier tests on Linux.

const std = @import("std");

pub fn module(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
return b.createModule(.{ .root_source_file = b.path("zig/src/sessions/sessions.zig"), .target = target, .optimize = optimize, .link_libc = true });
}

pub fn add(b: *std.Build, test_step: *std.Build.Step) void {
const host = b.graph.host;
const tests = if (host.result.os.tag == .linux) module(b, host, .debug) else b.createModule(.{
.root_source_file = b.path("zig/src/sessions/portable_test.zig"),
.target = host,
.optimize = .debug,
.link_libc = true,
});
const run = b.addRunArtifact(b.addTest(.{ .root_module = tests }));
b.step("test-sessions", "Session memory's host tests: pool, prefix trie, RAM tier, NVMe tier on Linux (no GPU)").dependOn(&run.step);
test_step.dependOn(&run.step);
}
61 changes: 61 additions & 0 deletions zig/build/tp.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//! Tensor parallelism's build: Linux host tests, and on Linux the `tf-tp-test` GPU runner with the mailbox kernel.

const std = @import("std");

/// The CUDA runtime without the engine's kernels (tp only needs the driver, memory, streams and NCCL).
fn runtime(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
const options = b.addOptions();
options.addOption(bool, "with_kernels", false);
const cuda = b.createModule(.{ .root_source_file = b.path("zig/src/cuda/root.zig"), .target = target, .optimize = optimize, .link_libc = true });
cuda.addOptions("kernel_options", options);
cuda.addImport("stagger", b.createModule(.{ .root_source_file = b.path("zig/src/core/stagger.zig"), .target = target, .optimize = optimize }));
return cuda;
}

/// The `tp` module over `cuda` (an engine passes its own runtime module); verbs (zig/src/fabric/verbs.zig) for RoCE.
pub fn module(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module) *std.Build.Module {
const m = b.createModule(.{ .root_source_file = b.path("zig/src/fabric/tp/tp.zig"), .target = target, .optimize = optimize, .link_libc = true });
m.addImport("cuda", cuda);
m.addImport("verbs", b.createModule(.{ .root_source_file = b.path("zig/src/fabric/verbs.zig"), .target = target, .optimize = optimize, .link_libc = true }));
return m;
}

/// mailbox.cu as a fatbin: sm_120 (RTX PRO 6000), sm_121 (GB10), and compute_90 PTX for anything else.
fn mailboxFatbin(b: *std.Build, nvcc: []const u8) std.Build.LazyPath {
const run = b.addSystemCommand(&.{ nvcc, "-fatbin", "-O3", "-std=c++17", "-gencode=arch=compute_120,code=sm_120", "-gencode=arch=compute_121,code=sm_121", "-gencode=arch=compute_90,code=compute_90", "-o" });
const out = run.addOutputFileArg("tp_mailbox.fatbin");
run.addFileArg(b.path("zig/src/fabric/tp/mailbox.cu"));
return out;
}

/// `pub const mailbox: []const u8`, the fatbin's bytes or empty.
fn kernelModule(b: *std.Build, image: ?std.Build.LazyPath) *std.Build.Module {
const wf = b.addWriteFiles();
if (image) |file| {
_ = wf.addCopyFile(file, "tp_mailbox.fatbin");
// the driver takes 8-byte aligned images (Module.load refuses others); @embedFile alone promises nothing
return b.createModule(.{ .root_source_file = wf.add("tp_kernel.zig", "const bytes align(16) = @embedFile(\"tp_mailbox.fatbin\").*;\npub const mailbox: []const u8 = &bytes;\n") });
}
return b.createModule(.{ .root_source_file = wf.add("tp_kernel.zig", "pub const mailbox: []const u8 = \"\";\n") });
}

pub fn add(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, test_step: *std.Build.Step) void {
const host = b.graph.host;
if (host.result.os.tag == .linux) {
const tests = b.addRunArtifact(b.addTest(.{ .root_module = module(b, host, .debug, runtime(b, host, .debug)) }));
b.step("test-tp", "Tensor parallelism's host tests: bootstrap, fate channel, in-process ranks (no GPU)").dependOn(&tests.step);
test_step.dependOn(&tests.step);
}
if (target.result.os.tag != .linux) return;
const nvcc = b.option([]const u8, "tp-nvcc", "nvcc that builds the TP mailbox kernel");
const prebuilt = b.option([]const u8, "tp-fatbin", "absolute path of a prebuilt tp_mailbox.fatbin to embed");
const image: ?std.Build.LazyPath = if (prebuilt) |p| b.graph.cwdRelativePath(p) else if (nvcc) |tool| mailboxFatbin(b, tool) else null;
const cuda = runtime(b, target, optimize);
const runner = b.createModule(.{ .root_source_file = b.path("zig/src/fabric/tp/gpu_main.zig"), .target = target, .optimize = optimize, .link_libc = true });
runner.addImport("cuda", cuda);
runner.addImport("tp", module(b, target, optimize, cuda));
runner.addImport("tp_kernel", kernelModule(b, image));
const exe = b.addExecutable(.{ .name = "tf-tp-test", .root_module = runner });
b.installArtifact(exe);
b.step("tf-tp-test", "TP=2 on two GPUs: bootstrap, every collective bit-exact, graph capture, fail-fast, latency").dependOn(&b.addInstallArtifact(exe, .{}).step);
}
9 changes: 9 additions & 0 deletions zig/src/cuda/abi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub const DeviceAttribute = enum(c_int) {
compute_capability_minor = 76,
max_shared_memory_per_multiprocessor = 81,
max_shared_memory_per_block_optin = 97,
virtual_memory_management_supported = 102,
gpu_direct_rdma_with_cuda_vmm_supported = 110,
};

pub const FunctionAttribute = enum(c_int) {
Expand Down Expand Up @@ -241,3 +243,10 @@ comptime {
std.debug.assert(@sizeOf(KernelNodeParams) == 72 and @offsetOf(KernelNodeParams, "params") == 40);
std.debug.assert(@sizeOf(ExecUpdateResultInfo) == 24);
}

test "CUDA device attribute matches the RDMA VMM capability ABI" {
// CUDA's CUdevice_attribute assigns 110 to RDMA VMM support; 126 is the memory sync domain count.
try @import("std").testing.expectEqual(@as(c_int, 110), @backingInt(
DeviceAttribute.gpu_direct_rdma_with_cuda_vmm_supported,
));
}
Loading
Loading