Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
36b254f
hy4_flash: paged absorbed MLA + C1/C2 CUDA kernels, contracts, and 5-…
GrgaPalcic Nov 25, 2026
abe1b68
hy4_flash(cuda): forward C1 list, add long-list & C2 variant byte-mat…
GrgaPalcic Nov 25, 2026
6294aa1
hy4_flash(cuda): evaluate C1 fp64 reference on all 6 cases and poison…
GrgaPalcic Nov 26, 2026
62b0a21
hy4_flash: adapt paged MLA series to main
ashhart Nov 26, 2026
cf21b6a
hy4_flash(cuda): zero hi roped plane in null-CSv C2 absorb and poison…
GrgaPalcic Nov 26, 2026
838c137
hy4_flash(cuda): update 5-SM register records for hy4c2_absorb_d1_x a…
GrgaPalcic Nov 26, 2026
b110608
hy4_flash: adapt contract cleanup and kernels hash pin to current main
ashhart Nov 27, 2026
345f306
hy4_flash: preserve route/rows cleanup with paged MLA
ashhart Nov 27, 2026
254102f
changelog: #5109 under Unreleased
ashhart Nov 29, 2026
cb74575
tests: compile every runtime Metal source (#4593)
ashhart Nov 27, 2026
5a75080
tests: expose MLX options in LFM2 recording (#4593)
ashhart Nov 27, 2026
9e27d55
tests: complete runtime Metal source coverage (#4593)
ashhart Nov 27, 2026
9e459bd
tests: require exact Metal source options (#4593)
ashhart Nov 27, 2026
5374d06
fix Metal runtime source coverage
ashhart Nov 27, 2026
240da3c
rebase: register Metal sources added on main
ashhart Nov 28, 2026
4a065c1
tests: cover Metal source OS gates
ashhart Nov 28, 2026
759c46b
tests: avoid logging the planted Metal source failure
ashhart Nov 28, 2026
0698374
changelog: #5347's line from lines/5347.txt in place of its own
ashhart Nov 29, 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
7 changes: 5 additions & 2 deletions .github/workflows/no-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ jobs:
path: .zig-cache
key: zig-build-v3-Windows-0.17.0-${{ github.sha }}${{ github.event_name == 'schedule' && '-nightly' || '' }}
# The release's own path check on each platform's dist server (no fatbins), so a leak fails here, not at release.
# Pull requests check Linux x86_64 only; main's pushes and the nightly run check all three platforms.
# Pull requests check Linux x86_64 and macOS; main's pushes and the nightly run also check Linux arm64.
release-paths:
if: ${{ !(startsWith(github.head_ref, 'lead/train-') && github.event.pull_request.head.repo.full_name == github.repository) }} # a landing train's tip: see the note above jobs
strategy:
fail-fast: false
matrix:
os: ${{ github.event_name != 'pull_request' && fromJSON('["macos-26", "ubuntu-24.04", "ubuntu-24.04-arm"]') || fromJSON('["ubuntu-24.04"]') }}
os: ${{ github.event_name != 'pull_request' && fromJSON('["macos-26", "ubuntu-24.04", "ubuntu-24.04-arm"]') || fromJSON('["macos-26", "ubuntu-24.04"]') }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
Expand Down Expand Up @@ -354,6 +354,9 @@ jobs:
- name: Metal toolchain
if: runner.os == 'macOS'
run: xcrun -sdk macosx metal -v || { xcodebuild -downloadComponent MetalToolchain && xcrun -sdk macosx metal -v; }
- name: Compile every runtime Metal source
if: runner.os == 'macOS'
run: zig build test-metal-compile --summary all
- name: zig build check-release-paths
run: zig build -Dfixed-cpu check-release-paths
- name: Save the build cache
Expand Down
19 changes: 5 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Tests: `zig build test-metal-compile` now runs in pull-request macOS CI and compiles every runtime Metal source with its loader's options and defines; exact host provenance rejects unregistered exports, wrong compiler options or altered prefixes, with a planted duplicate-attribute compiler failure (refs #4593).

- Hy4 Flash CUDA gains paged absorbed MLA and C1/C2 kernels with exact paging/indexed-list contracts and five-SM launch records (#5109). Thanks to @GrgaPalcic.

- Serve: with `--execution-witness` and `--confidential`, the witness snapshot and each reply's binding carry `"confidential": true` and the preparation hash binds the flag; witnesses without `--confidential` are unchanged (thanks @kotevcode).

- `tools/bench_cache_agents.py run --trace agent_edits` replays agent conversations after a history edit: at the midpoint each conversation's first user message is rewritten and its history regrown (#5450, thanks @devopsfortunato).

- MiniMax-H3-Image on Metal: edits run end to end with TensorFold's own tools: Qwen3-VL's vision tower takes opt-in DeepStack taps, and `tf-h3-image-vision` reads a reference image and writes its prompt rows and DeepStack features; Qwen 3.5 checkpoints load exactly as before (#2810).



- Metal: the bf16 SiLU and the tanh GELU's inner term come from one shader source shared by the core, Qwen vision, Gemma 4 vision and Llama glue kernels; outputs are unchanged (#5204, thanks @jschmied).

- Reports: the serving line, `/v1/load` and `/stats` now show the draft model's KV cache size, dtype and scope next to the target's, for every family with a drafter or MTP head (#4538).



- Qwen 3.5 on CUDA: SenseNova-Loop-9B (`sensenova_loop`) serves in BF16, text only, on the looped schedule (physical layers 0-3, 4-27 twice, 28-31) with its mHC stream routing, one copy of the weights and a cache slot per execution; drafts, vision, pipeline stages and tensor parallel are refused for it, and other Qwen checkpoints run as before (#3723, refs #3717). Thanks to @Maxrio9.
- Docs: `docs/environment-names.md` lists `TF_CUDA_QWEN_PROMPT_STAGES2` and `TF_Q27_METAL4`, so the environment-names check passes on main again (#5575).

- Tokenizer: `o200k` and Inkling 2 ByteLevel-BPE tokenizers use a streaming pre-tokenizer, a reusable BPE and a deterministic parallel encode in place of the generic regex path; tokens are bit-for-bit the same as the generic path (thanks @BlivionIaG).

- Inkling 2 Mini: `--thinking-budget` and `thinking.budget_tokens` now close thinking at the budget and the model goes on to answer; with no budget, replies are unchanged (#5402). Thanks @fcossutta. Thanks @fcossutta for the report.



- Tests: the CUDA execution-witness test rewrites its cubin with a different size, so it no longer depends on two writes landing in different timestamp ticks (#5522).

- Server: under `--confidential`, errors and log lines carry fixed messages, allowed codes and a request id, never request text (#5348, part of #5176). Thanks to @kotevcode.



- Flash Next CUDA: the rows store sizes its staging permit from the served window instead of a fixed 1 GiB, so kept states past about 31K tokens are no longer skipped with `StagingFull` (thanks @shantanugoel).

- Inkling 2 on CUDA: an EXL3 launch that runs a layer's five input projections (q, gate, r, k and v) as one rotation and one linear launch, each member computed exactly as by its own launch, passes gates 1 to 4 of the kernel contract with planted controls; nothing serves it yet (#4874, refs #3476).



- Qwen3.8-27B-class Metal: the startup memory margin is an eighth of the Metal working set (1-8 GiB) instead of a fixed 8 GiB, and a prompt frame that cannot fit 512 rows steps down to 128, so 16 GB and 24 GB Macs can serve the 4-bit 9B; Macs with a working set of 64 GiB or more keep the 8 GiB margin (#4158, thanks @jayleaton).

- App: models downloaded through the app stay in the list on engine 1.3.0 and later (the parser reads `startup budget:`), and drafter-only checkpoints are hidden from the model picker (#4407; thanks @devopsfortunato).
Expand All @@ -47,14 +41,10 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- Flash Next on CUDA: TFQ3 host-dequantized BF16 slices are freed with the two-byte alignment they were allocated with (#5467, fixes #5459, thanks @devopsfortunato).



- GLM CUDA: `--prompt-cache-disk` (and `--learn-conversations`) now keeps full GLM-5.3 conversation states on disk; the image reads the latent row width, pool size and which caches keep index keys from the state, so GLM-5.3-Flash images are unchanged (thanks @bjornmonnens).

- App: the room's Final readiness panel now shows the moderator's final-gate verdict, so it can no longer show all green while the room has not reached FINAL (thanks @devopsfortunato).



- CLI: a failed first reply from `tensorfold start` reports the server's refusal text reliably on a loaded machine, with a 30-second bound so unattended runs never hang (#5379).

- Multi-GPU groups: every rank connection (the `fabric/tp` bootstrap, GLM's and Nemotron's liveness lines, the HIP link and the Flash Next pair) proves a shared key with a fresh nonce and an HMAC before its first byte, and a connection that fails is closed without stopping the group; ranks on more than one host need the key from `TF_RANK_SECRET_FILE` or `--rank-secret` (#3041).
Expand Down Expand Up @@ -242,6 +232,7 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- Inkling 2 on CUDA: DSpark kernels draft every open stream in one pass; drafted output stays byte-identical to plain decoding (#4858). Thanks to @ajensenwaud.

- Tests: `zig build test-metal-compile` now runs in pull-request macOS CI and compiles every runtime Metal source with its loader's options and defines; exact host provenance rejects unregistered exports, wrong compiler options or altered prefixes, with a planted duplicate-attribute compiler failure (refs #4593).
- Tests: the `--listen-fd` check counts a connection the server closes before the request is sent as refused, so that race no longer fails the suite (#5273, refs #5183).

- Flash Next on CUDA: greedy drafts beside another open stream use `TF_FLASHNEXT_CONFIDENCE`, the same stop rule as a lone stream; token verification is unchanged (#5265).
Expand Down
13 changes: 13 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ pub fn build(b: *std.Build) void {
step5_mods.sources.addImport("nemotron_packed_metallib", embedded(b, empty, "nemotron_packed.metallib"));
@import("zig/build/step5_host.zig").steps(b, step5_mods.metal, step5_mods.engine, step5_mods.lanes);
@import("zig/build/qwen35_cache_host.zig").compileHost(b, step5_mods.metal, step5_mods.engine, step5_mods.lanes);
} else if (target.result.os.tag == .macos) {
const cross_mods = metalEngineModules(b, target, .Debug, draft_ids);
// Object-only checks need no Apple SDK link inputs.
cross_mods.metal.frameworks.clearRetainingCapacity();
cross_mods.metal.link_objects.clearRetainingCapacity();
const empty = b.addWriteFiles().add("runtime-cross-no-shaders.metallib", "");
cross_mods.sources.addImport("nemotron_packed_metallib", embedded(b, empty, "nemotron_packed.metallib"));
@import("zig/build/metal_prompt_sources.zig").steps(b, cross_mods.metal, cross_mods.engine, test_step);
} else {
const runtime_mods = metalEngineModules(b, b.graph.host, .Debug, draft_ids);
const empty = b.addWriteFiles().add("runtime-coverage-no-shaders.metallib", "");
runtime_mods.sources.addImport("nemotron_packed_metallib", embedded(b, empty, "nemotron_packed.metallib"));
@import("zig/build/metal_prompt_sources.zig").hostSteps(b, runtime_mods.metal, runtime_mods.engine, test_step);
}
@import("zig/build/h3_host.zig").tests(b, target, test_step);
@import("zig/build/h3_image_prompt.zig").tests(b, target, test_step);
Expand Down
1 change: 1 addition & 0 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
runner.addImport("hy4_engram_fp8", b.createModule(.{ .root_source_file = b.path("zig/src/families/hy4_flash/engram_fp8_cuda.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("ernie5_5_index_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/ernie5_5/cuda_index.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("ernie5_5_mhc_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/ernie5_5/cuda_mhc.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("hy4_mla_paged_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/hy4_flash/mla_paged_cuda.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "cuda", .module = cuda }} }));
runner.addImport("gemma4_cuda", @import("gemma4_cuda.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
runner.addImport("spark25", @import("spark25.zig").module(b, target, optimize, cuda, mods.core, mods.lanes));
// the served family and its engine, for the dots runner
Expand Down
3 changes: 3 additions & 0 deletions zig/build/cuda_kernels.zig
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ pub const kernels = [_]Kernel{
.{ .name = "hy4_dfly2_glue", .src = "hy4_flash/dfly2_glue", .flags = glue },
.{ .name = "ernie5_5_index", .src = "ernie5_5/index", .flags = &.{"-O3"} }, // ours: ERNIE 5.5's DSA key lists
.{ .name = "ernie5_5_mhc", .src = "ernie5_5/mhc", .flags = &.{"-O3"} }, // ours: ERNIE 5.5's mHC pre side
.{ .name = "hy4_mla_paged", .src = "hy4_flash/mla_paged", .flags = glue },
.{ .name = "hy4_mla_attn_paged", .src = "hy4_flash/mla_attn_paged", .flags = glue },
.{ .name = "hy4_mla_c2", .src = "hy4_flash/mla_c2", .flags = glue },
.{ .name = "minimax_m3", .flags = glue }, // ours: MiniMax-M3.1-Flash's glue (norms, RoPE prep, routing, DSpark, tower RoPE)
.{ .name = "minimax_m3_attn", .flags = glue }, // ours: MiniMax-M3.1-Flash's indexer and block-sparse attention
.{ .name = "idol", .flags = glue }, // ours: Idol's denoiser glue and its fp16 head-64 attention
Expand Down
80 changes: 60 additions & 20 deletions zig/build/metal_prompt_sources.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
//! Runtime source assembly is device-free; the compiler gate requires a device and submits no work.
const std = @import("std");

pub fn steps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module, host_tests: *std.Build.Step) void {
fn inventoryModule(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module) *std.Build.Module {
const target = metal.resolved_target orelse b.graph.host;
const assembly = b.createModule(.{ .root_source_file = b.path("zig/runtime_sources/assembly_metal.zig"), .imports = &.{.{ .name = "real_metal", .module = metal }} });
const inventory = b.createModule(.{ .root_source_file = b.path("zig/metal_runtime_inventory.zig"), .target = target, .optimize = .debug, .link_libc = true });
var imports = engine.import_table.iterator();
while (imports.next()) |entry| inventory.addImport(entry.key_ptr.*, entry.value_ptr.*);
inventory.addImport("metal", assembly);
inventory.addImport("core", inventory);
inline for (.{ "bf16_topk_gpu", "tree_round_gpu", "tree_commit_gpu", "draft_ops" }, .{ "bf16_topk_sources", "tree_round_sources", "tree_commit_sources", "draft_ops_sources" }) |owner, name| {
inventory.addImport(name, engine.import_table.get(owner).?.import_table.get(name).?);
}
inventory.addImport("h3_kernels", b.createModule(.{ .root_source_file = b.path("zig/kernels/metal/h3/kernels.zig") }));
return inventory;
}

fn coverageSteps(b: *std.Build, inventory: *std.Build.Module, host_tests: *std.Build.Step) *std.Build.Step.Run {
const run = b.addRunArtifact(b.addTest(.{ .root_module = inventory, .filters = &.{"Metal runtime source"} }));
host_tests.dependOn(&run.step);
b.step("test-metal-source-registry-host", "Every exported Metal source is assembled or explicitly excluded").dependOn(&run.step);
return run;
}

fn modeSteps(b: *std.Build, inventory: *std.Build.Module, host_tests: *std.Build.Step) *std.Build.Step.Run {
const run = b.addRunArtifact(b.addTest(.{ .root_module = inventory, .filters = &.{"Metal runtime source modes:"} }));
host_tests.dependOn(&run.step);
b.step("test-metal-runtime-source-modes-host", "Runtime libraries match their loaders' device capability gates").dependOn(&run.step);
return run;
}

const Loader = struct { host: *std.Build.Step.Compile, run: *std.Build.Step.Run };
fn loaderSteps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module, host_tests: *std.Build.Step) Loader {
const target = metal.resolved_target orelse b.graph.host;
const recording = b.createModule(.{ .root_source_file = b.path("zig/lfm2_recording_metal.zig"), .imports = &.{.{ .name = "real_metal", .module = metal }} });
const loader_host = b.addTest(.{ .root_module = b.createModule(.{
.root_source_file = b.path("zig/lfm2_runtime_sources_host.zig"),
.target = b.graph.host,
.target = target,
.optimize = .debug,
.link_libc = true,
.imports = &.{
Expand All @@ -16,24 +47,25 @@ pub fn steps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module,
const loader_run = b.addRunArtifact(loader_host);
host_tests.dependOn(&loader_run.step);
b.step("test-lfm2-runtime-sources-host", "LFM2 source inventory equals its recording loader without a device").dependOn(&loader_run.step);
const assembly = b.createModule(.{ .root_source_file = b.path("zig/runtime_sources/assembly_metal.zig"), .imports = &.{.{ .name = "real_metal", .module = metal }} });
const inventory = b.createModule(.{ .root_source_file = b.path("zig/metal_runtime_inventory.zig"), .target = b.graph.host, .optimize = .debug, .link_libc = true });
var imports = engine.import_table.iterator();
while (imports.next()) |entry| inventory.addImport(entry.key_ptr.*, entry.value_ptr.*);
inventory.addImport("metal", assembly);
inventory.addImport("core", inventory);
inline for (.{ "bf16_topk_gpu", "tree_round_gpu", "tree_commit_gpu", "draft_ops" }, .{ "bf16_topk_sources", "tree_round_sources", "tree_commit_sources", "draft_ops_sources" }) |owner, name| {
inventory.addImport(name, engine.import_table.get(owner).?.import_table.get(name).?);
}
inventory.addImport("h3_kernels", b.createModule(.{ .root_source_file = b.path("zig/kernels/metal/h3/kernels.zig") }));
const mode_run = b.addRunArtifact(b.addTest(.{ .root_module = inventory, .filters = &.{"Metal runtime source modes:"} }));
host_tests.dependOn(&mode_run.step);
b.step("test-metal-runtime-source-modes-host", "Runtime libraries match their loaders' device capability gates").dependOn(&mode_run.step);
return .{ .host = loader_host, .run = loader_run };
}

pub fn hostSteps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module, host_tests: *std.Build.Step) void {
_ = loaderSteps(b, metal, engine, host_tests);
const inventory = inventoryModule(b, metal, engine);
_ = modeSteps(b, inventory, host_tests);
_ = coverageSteps(b, inventory, host_tests);
}
pub fn steps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module, host_tests: *std.Build.Step) void {
const loader = loaderSteps(b, metal, engine, host_tests);
const target = metal.resolved_target orelse b.graph.host;
const inventory = inventoryModule(b, metal, engine);
const mode_run = modeSteps(b, inventory, host_tests);
const coverage_run = coverageSteps(b, inventory, host_tests);
const root = b.createModule(.{
.root_source_file = b.path("zig/metal_runtime_sources_test.zig"),
.target = b.graph.host,
.target = target,
.optimize = .debug,
.link_libc = true,
.imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "inventory", .module = inventory } },
});
const options = b.addOptions();
Expand All @@ -43,14 +75,22 @@ pub fn steps(b: *std.Build, metal: *std.Build.Module, engine: *std.Build.Module,
const run = b.addRunArtifact(tests);
run.has_side_effects = true;
const step = b.step("test-metal-runtime-sources", "Compile every family's runtime source libraries; device required, no dispatch");
step.dependOn(&loader_run.step);
step.dependOn(&loader.run.step);
step.dependOn(&mode_run.step);
step.dependOn(&coverage_run.step);
step.dependOn(&run.step);
b.step("test-metal-compile", "Compile every runtime Metal source with a planted compiler-error control").dependOn(step);
b.step("test-nemotron-prefill-metal-sources", "Alias for the complete runtime Metal source compiler gate").dependOn(step);
b.step("build-metal-runtime-sources", "Build the source gate executable without opening a device").dependOn(&tests.step);
const loader_object = b.addTest(.{ .root_module = loader.host.root_module, .filters = &.{"LFM2 runtime inventory:"}, .emit_object = true });
const sources_object = b.addTest(.{ .root_module = root, .filters = &.{"Metal runtime source compile gate:"}, .emit_object = true });
_ = loader_object.getEmittedBin();
_ = sources_object.getEmittedBin();
const compile_step = b.step("build-metal-runtime-sources", "Compile both runtime Metal source test objects without linking or execution");
compile_step.dependOn(&loader_object.step);
compile_step.dependOn(&sources_object.step);
const emit_root = b.createModule(.{
.root_source_file = b.path("zig/metal_runtime_sources_emit.zig"),
.target = b.graph.host,
.target = target,
.optimize = .debug,
.link_libc = true,
.imports = &.{.{ .name = "inventory", .module = inventory }},
Expand Down
1 change: 1 addition & 0 deletions zig/kernels/cuda/contract_controls_set.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
#include "contract_int4_controls.cuh"
#include "contract_hy4_engram_fp8_controls.cuh"
#include "contract_mhc_controls.cuh"
#include "contract_hy4_mla_paged_controls.cuh"
Loading
Loading