From 9207fc27ff9330e99e4a0d96a7145069b1a39c04 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:58:28 +0800 Subject: [PATCH 01/23] server: compile for aarch64-windows (POSIX modes, COM vtable alignment) --- zig/src/server/device/read.zig | 12 ++++++++---- zig/src/server/gpu_turn.zig | 8 +++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/zig/src/server/device/read.zig b/zig/src/server/device/read.zig index f8c72fcf99e..9592e330b5d 100644 --- a/zig/src/server/device/read.zig +++ b/zig/src/server/device/read.zig @@ -126,6 +126,10 @@ const win = struct { const Release = *const fn (*Com) callconv(.winapi) u32; const EnumAdapters1 = *const fn (*Com, u32, *?*Com) callconv(.winapi) i32; const GetDesc1 = *const fn (*Com, *Desc) callconv(.winapi) i32; + /// Entry `i` of `com`'s vtable as `F`; aarch64 code pointers are 4-aligned, the vtable's slots untyped. + fn method(comptime F: type, com: *Com, i: usize) F { + return @ptrCast(@alignCast(com.vtable[i])); + } fn regString(a: Allocator, comptime sub: []const u8, comptime value: []const u8) []const u8 { var buf: [256]u16 = undefined; @@ -145,16 +149,16 @@ const win = struct { var raw: ?*anyopaque = null; if (create(&iid_factory1, &raw) < 0) return &.{}; const factory: *Com = @ptrCast(@alignCast(raw orelse return &.{})); - defer _ = @as(Release, @ptrCast(factory.vtable[2]))(factory); + defer _ = method(Release, factory, 2)(factory); var out: std.ArrayList(parse.Adapter) = .empty; var i: u32 = 0; while (i < 16) : (i += 1) { var adapter: ?*Com = null; - if (@as(EnumAdapters1, @ptrCast(factory.vtable[12]))(factory, i, &adapter) < 0) break; + if (method(EnumAdapters1, factory, 12)(factory, i, &adapter) < 0) break; const ad = adapter orelse break; - defer _ = @as(Release, @ptrCast(ad.vtable[2]))(ad); + defer _ = method(Release, ad, 2)(ad); var d: Desc = undefined; - if (@as(GetDesc1, @ptrCast(ad.vtable[10]))(ad, &d) < 0) continue; + if (method(GetDesc1, ad, 10)(ad, &d) < 0) continue; const name = std.unicode.utf16LeToUtf8Alloc(a, std.mem.sliceTo(&d.description, 0)) catch ""; try out.append(a, .{ .name = name, .vendor = d.vendor, .device = d.device, .memory = d.dedicated_video, .software = (d.flags & 2) != 0 }); } diff --git a/zig/src/server/gpu_turn.zig b/zig/src/server/gpu_turn.zig index f16b328c398..f5a717499df 100644 --- a/zig/src/server/gpu_turn.zig +++ b/zig/src/server/gpu_turn.zig @@ -1,5 +1,6 @@ //! Speech holds a shared flock; batch work yields between short command buffers and tracks speech generations. const std = @import("std"); +const windows = @import("builtin").os.tag == .windows; pub const path = "/tmp/tensorfold-speech.lock"; @@ -48,7 +49,8 @@ fn open(io: std.Io, at: []const u8) !std.Io.File { return dir.openFile(io, at, .{}) catch |e| switch (e) { error.FileNotFound => { const file = try dir.createFile(io, at, .{ .read = true, .truncate = false }); - file.setPermissions(io, .fromMode(0o644)) catch {}; // past the creator's umask, so the other user opens it + // past the creator's umask, so the other user opens it; Windows has no mode bits + if (!windows) file.setPermissions(io, .fromMode(0o644)) catch {}; return file; }, else => e, @@ -62,7 +64,7 @@ pub fn mark(io: std.Io, at: []const u8) ?Mark { const file = marker(io, at) catch return null; defer file.close(io); const stat = file.stat(io) catch return null; - if (stat.kind != .file or stat.permissions.toMode() & 0o666 != 0o666) return null; + if (stat.kind != .file or (!windows and stat.permissions.toMode() & 0o666 != 0o666)) return null; var result: Mark = .{ .inode = stat.inode, .bytes = undefined }; if ((file.readPositionalAll(io, &result.bytes, 0) catch return null) != result.bytes.len) return null; const lock = open(io, at) catch return null; @@ -101,7 +103,7 @@ fn marker(io: std.Io, at: []const u8) !std.Io.File { return create_err; }; errdefer file.close(io); - try file.setPermissions(io, .fromMode(0o666)); + if (!windows) try file.setPermissions(io, .fromMode(0o666)); var bytes: [16]u8 = undefined; io.random(&bytes); try file.writePositionalAll(io, &bytes, 0); From 0294bef9c40f38093fa941bdcdf1e94439f06337 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:58:28 +0800 Subject: [PATCH 02/23] build: skip tf-muse on Windows, as its rank 1 follows over POSIX TP --- zig/build/muse.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zig/build/muse.zig b/zig/build/muse.zig index 82446e5f55d..c85fda00e4a 100644 --- a/zig/build/muse.zig +++ b/zig/build/muse.zig @@ -18,7 +18,9 @@ pub fn moduleOver(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std } /// tf-muse: rank 1 behind the server (`follow`) and the family's device checks; installed, and its own step. +/// Not on Windows: rank 1 follows over the POSIX TP session (tp.zig skips it there too). pub fn tool(b: *std.Build, m: *std.Build.Module, strip: ?bool) void { + if (m.resolved_target.?.result.os.tag == .windows) return; const root = b.createModule(.{ .root_source_file = b.path("zig/src/families/muse_spark/m1_main.zig"), .target = m.resolved_target, .optimize = m.optimize, .link_libc = true, .strip = strip }); for ([_][]const u8{ "cuda", "core", "tp", "tp_kernel" }) |name| root.addImport(name, m.import_table.get(name).?); root.addImport("muse_spark", m); From 57d20c4061a042aa03e37e69ea8cc475e435d08f Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:58:28 +0800 Subject: [PATCH 03/23] build: compile-native-cuda-windows also checks the sm_121 aarch64 product --- zig/build/product.zig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zig/build/product.zig b/zig/build/product.zig index 29031dd1e1e..a8106df96d4 100644 --- a/zig/build/product.zig +++ b/zig/build/product.zig @@ -166,16 +166,18 @@ fn cudaProduct(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu return exe; } -/// `compile-native-cuda-windows`: the Windows CUDA product checked by the compiler from any host, emitting nothing. +/// `compile-native-cuda-windows`: the Windows CUDA products checked by the compiler from any host, emitting nothing. pub fn windowsCompile(b: *std.Build) *std.Build.Step { - const target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v4 } }); const options = b.addOptions(); options.addOption([]const u8, "version", @import("../../build.zig.zon").version); options.addOption(bool, "is_release", false); options.addOption(bool, "slide_test_hooks", false); - const exe = cudaProduct(b, target, .ReleaseSafe, null, null, options, "120"); - const step = b.step("compile-native-cuda-windows", "Type-check the sm_120 Windows CUDA product (x86_64-windows-gnu), with empty kernel images"); - step.dependOn(&exe.step); // nothing asks for the binary, so the compiler checks without emitting or linking + const step = b.step("compile-native-cuda-windows", "Type-check the Windows CUDA products (sm_120 x86_64, sm_121 N1X aarch64), with empty kernel images"); + const x86 = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v4 } }); + const arm = b.resolveTargetQuery(.{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu }); + // nothing asks for the binaries, so the compiler checks without emitting or linking + step.dependOn(&cudaProduct(b, x86, .ReleaseSafe, null, null, options, "120").step); + step.dependOn(&cudaProduct(b, arm, .ReleaseSafe, null, null, options, "121").step); return step; } From d53f4d8cab393e6cbb6f001463effbe499a037d5 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:30:07 +0800 Subject: [PATCH 04/23] cuda: glm_index_rope's turn is __noinline__, which nvcc with cl.exe accepts; Windows fatbins pass /wd4819 --- zig/build/cuda_fatbin.zig | 5 +++-- zig/kernels/cuda/glm_index_rope.cuh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/zig/build/cuda_fatbin.zig b/zig/build/cuda_fatbin.zig index 302a152cd45..054b5502968 100644 --- a/zig/build/cuda_fatbin.zig +++ b/zig/build/cuda_fatbin.zig @@ -19,8 +19,9 @@ pub fn fatbin(b: *std.Build, nvcc: []const u8, version: std.Build.LazyPath, k: K const run = b.addSystemCommand(&.{ nvcc, "-fatbin" }); run.addFileInput(version); run.addArgs(&torch_flags); - // CUDA 13's headers with cl.exe need MSVC's conforming preprocessor and M_SQRT2's math define. - if (b.graph.host.result.os.tag == .windows) run.addArgs(&.{ "-Xcompiler=/Zc:preprocessor", "-D_USE_MATH_DEFINES" }); + // CUDA 13's headers with cl.exe need MSVC's conforming preprocessor and M_SQRT2's math define; under a CJK system + // code page, C4819 (a header character it cannot represent) buries the real errors in thousands of warnings. + if (b.graph.host.result.os.tag == .windows) run.addArgs(&.{ "-Xcompiler=/Zc:preprocessor", "-Xcompiler=/wd4819", "-D_USE_MATH_DEFINES" }); run.addArgs(k.flags); // Generated CUDA sources resolve the same maintained headers as checked-in units. run.addDirectoryArg2(b.path("zig/kernels/cuda"), .{ .prefix = "-I" }); diff --git a/zig/kernels/cuda/glm_index_rope.cuh b/zig/kernels/cuda/glm_index_rope.cuh index 7fd5c82882d..b05d782b5b8 100644 --- a/zig/kernels/cuda/glm_index_rope.cuh +++ b/zig/kernels/cuda/glm_index_rope.cuh @@ -9,7 +9,7 @@ namespace glm_rope { // Sine and cosine of pair i's angle pos inv[i], out of line: one copy of sincosf's large-angle path, not one a site. -static __device__ __attribute__((noinline)) void turn(int64_t pos, const float* inv, int i, float* s, float* c) { +static __device__ __noinline__ void turn(int64_t pos, const float* inv, int i, float* s, float* c) { sincosf(__fmul_rn((float)pos, inv[i]), s, c); } From 67ec38b1b557353198a57ac59afa3014200b9c36 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:57:40 +0800 Subject: [PATCH 05/23] docs: n1x-run.ps1 runs Inkling 2 Mini on the RTX Spark laptop in three short steps (build, 188 checks, 1/4-stream serving) --- docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 119 +++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 new file mode 100644 index 00000000000..92313be205a --- /dev/null +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -0,0 +1,119 @@ +# Inkling 2 Mini (revision ed40e7da62) whole on an RTX Spark N1X laptop, native Windows ARM64, run by its Codync bot: +# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step build|check|serve +# From a clean checkout with `vcvarsall arm64` set up and CUDA_PATH naming the windows-arm64 toolkit. Installs, downloads +# and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step stops itself well inside 10 minutes. +param( + [Parameter(Mandatory)][ValidateSet('build', 'check', 'serve')][string]$Step, + [string]$Model = 'C:\models\Inkling-2-Mini-ed40e7da62' +) +$ErrorActionPreference = 'Stop' +$out = Join-Path $env:TEMP 'inkling2-n1x' +New-Item -ItemType Directory -Force $out | Out-Null + +function Run([string]$exe, [string[]]$argv) { + Write-Output "> $exe $argv" + & $exe @argv + Write-Output "EXIT=$LASTEXITCODE" + if ($LASTEXITCODE) { exit $LASTEXITCODE } +} + +# The WDDM device pool the driver gives CUDA (the N1X shares it with the CPU; firmware sets its size), MiB +function Pool([string]$label) { + Write-Output "$label`: $(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader)" +} + +Run (Join-Path $env:CUDA_PATH 'bin\nvcc.exe') @('--version') +nvidia-smi --query-gpu=name,driver_version,power.limit,clocks.max.sm --format=csv,noheader +Write-Output "power plan: $(powercfg /getactivescheme)" +$test = 'zig-out\bin\tf-cuda-test.exe' +$server = 'zig-out\native\bin\tensorfold-native.exe' + +if ($Step -eq 'build') { + Run zig @('build', 'install', 'native', '-Dsm=121', "-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe", '-Doptimize=ReleaseFast') + exit 0 +} + +if ($Step -eq 'check') { + # 188's GB10 checks as they are: the served kernels, #4387's serving checks, the float64 reference + Run $test @('info') + Run $test @('kernel-contract', 'inkling2 loop') + $r = New-Object System.Random 4387 + (1..4200 | ForEach-Object { $r.Next(1000, 199000) }) -join ' ' | Set-Content -Encoding ascii "$out\ids.txt" + Run $test @('inkling2-serving', $Model, "$out\ids.txt") + $text = 'The three laws of thermodynamics, explained for a curious student:' + Run $test @('inkling2-mini-ref', $Model, '32', $text) + $env:INKLING2_REF_PLANT = '1' + & $test inkling2-mini-ref $Model 32 $text + Write-Output "planted control EXIT=$LASTEXITCODE (must be non-zero)" + Remove-Item Env:INKLING2_REF_PLANT + if (-not $LASTEXITCODE) { exit 1 } + exit 0 +} + +# serve: one server, 1 then 4 greedy streams of 256 tokens, first token and decode per stream, the pool's peak +Pool 'before the server' +$port = 8188 +$proc = Start-Process -FilePath $server -PassThru -NoNewWindow -RedirectStandardOutput "$out\server.log" ` + -RedirectStandardError "$out\server.err" -ArgumentList @('serve', "`"$Model`"", '--backend', 'cuda', + '--host', '127.0.0.1', '--port', $port, '--name', 'inkling-2-mini', '--parallel', '4', '--context', '8192', + '--no-update-check') +$loaded = [Diagnostics.Stopwatch]::StartNew() +try { + while ($true) { + try { Invoke-RestMethod "http://127.0.0.1:$port/v1/models" -TimeoutSec 5 | Out-Null; break } catch {} + if ($proc.HasExited -or $loaded.Elapsed.TotalSeconds -gt 240) { throw 'server did not answer /v1/models' } + Start-Sleep 1 + } + Write-Output ("RESULT n1x server ready in {0:N1} s" -f $loaded.Elapsed.TotalSeconds) + Pool 'server loaded' + Add-Type -AssemblyName System.Net.Http + $http = New-Object System.Net.Http.HttpClient + $http.Timeout = [TimeSpan]::FromMinutes(4) + $peak = 0 + foreach ($n in 1, 4) { + $clock = [Diagnostics.Stopwatch]::StartNew() + $body = '{"model":"inkling-2-mini","prompt":"Write a short Python function that computes the Fibonacci ' + + 'sequence and explain it.","max_tokens":256,"temperature":0,"ignore_eos":true,"stream":true,' + + '"stream_options":{"include_usage":true}}' + $calls = foreach ($i in 1..$n) { + $req = New-Object System.Net.Http.HttpRequestMessage 'Post', "http://127.0.0.1:$port/v1/completions" + $req.Content = New-Object System.Net.Http.StringContent $body, ([Text.Encoding]::UTF8), 'application/json' + $http.SendAsync($req, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead) + } + $streams = foreach ($c in $calls) { + $reader = New-Object IO.StreamReader $c.Result.Content.ReadAsStreamAsync().Result + @{ reader = $reader; first = $null; last = $null; tokens = $null } + } + # read the streams in turn: a reply's pieces wait in its socket, the clock stamps when each is read + while ($streams | Where-Object { $_.reader }) { + foreach ($s in $streams | Where-Object { $_.reader }) { + $line = $s.reader.ReadLine() + if ($null -eq $line -or $line -eq 'data: [DONE]') { $s.reader = $null; continue } + if (-not $line.StartsWith('data: ')) { continue } + $j = $line.Substring(6) | ConvertFrom-Json + if ($j.usage) { $s.tokens = $j.usage.completion_tokens } + if ($j.choices -and $j.choices[0].text) { + if ($null -eq $s.first) { $s.first = $clock.Elapsed.TotalSeconds } + $s.last = $clock.Elapsed.TotalSeconds + } + } + $used = [int](nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) + if ($used -gt $peak) { $peak = $used } + } + $total = 0 + foreach ($s in $streams) { + if ($s.tokens -ne 256) { throw "$n streams: a reply ended at $($s.tokens) tokens" } + $tps = ($s.tokens - 1) / ($s.last - $s.first) + $total += $s.tokens - 1 + Write-Output ("RESULT n1x {0} stream(s): first token {1:N3} s, decode {2:N1} tok/s" -f $n, $s.first, $tps) + } + $span = ($streams | ForEach-Object { $_.last } | Measure-Object -Maximum).Maximum - + ($streams | ForEach-Object { $_.first } | Measure-Object -Minimum).Minimum + Write-Output ("RESULT n1x {0} stream(s) total decode {1:N1} tok/s" -f $n, ($total / $span)) + } + Write-Output "RESULT n1x peak GPU memory sampled while decoding: $peak MiB" + Write-Output "RESULT n1x server process peak working set $([int]($proc.PeakWorkingSet64 / 1MB)) MiB" +} finally { + if (-not $proc.HasExited) { Stop-Process -Id $proc.Id } + Get-Content "$out\server.err" -Tail 20 +} From b2ddc3de043a4766be617a7156db7e162f4f4def Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:57:40 +0800 Subject: [PATCH 06/23] docs: Inkling 2 Mini recipe names the N1X differences and its pending laptop receipt --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 8 ++++ docs/recipes/inkling-2-mini-cuda/README.md | 41 ++++++++++++------- 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md new file mode 100644 index 00000000000..03f6766228a --- /dev/null +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -0,0 +1,8 @@ +# Inkling 2 Mini on the RTX Spark N1X laptop (native Windows ARM64): the Windows fixes and its run steps + +- Brings 189's Windows ARM64 fixes onto 188's Inkling 2 Mini engine: `__noinline__` in `glm_index_rope.cuh` and + `/wd4819` for nvcc with cl.exe, POSIX file modes and COM `@alignCast` in the server, no `tf-muse` on Windows, and + `compile-native-cuda-windows` checking the sm_121 aarch64 product. +- `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in three short steps + (build, 188's exactness checks, 1/4-stream serving with first token and the WDDM pool's peak), with no Python, installs + or downloads. No laptop receipt yet. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 9eddd6c13c0..ef5672fd2a2 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -31,18 +31,29 @@ Bandwidth limit: a decoded token reads about 5.55 GB of weights (core layers 3 p whole unembedding), so 273 GB/s caps one stream near 49 tok/s; 32.5 tok/s is 66% of it. #4387's own engine, removed here, gave 5.7 tok/s at one stream and 9.4 at four on the same GB10 (job `top-0759755a0515`). -## RTX Spark (N1X): what differs and what must change - -I see the same chip and memory model as the GB10: sm_121 and one unified pool, so the `-Dsm=121` kernel images are -the same. What differs is the host. RTX Spark runs Windows on Arm, with WSL2 as the -Linux route. From #1010 (`5b1f10812`) and #2107: - -- Native Windows builds as `aarch64-windows` with VS 2022 Build Tools' ARM64 C++ tools (`vcvarsall arm64`) as nvcc's - host compiler and the CUDA 13.4 `windows-arm64` redistributables (winget has no arm64 installer). Admission reads the - WDDM pool through `cuMemGetInfo_v2`, and `nvidia-smi`'s NPU row is filtered out. -- Under WSL2 `/proc/meminfo` is WSL's RAM (about 30 GiB of 128 GB), not the GPU's 96 GB WDDM pool; with - `WSL_DISTRO_NAME` set, admission reads the CUDA pool instead (`TENSORFOLD_UNIFIED_HOST_COUNTS` overrides it). -- For Mini on native Windows, I need the Inkling CUDA kernels compiled with MSVC as nvcc's host front end (only gcc 14 - has built them so far) and one load of the 18.9 GiB single-shard checkpoint through Windows' threaded reads. -- For Mini under WSL2, I need neither: it is the Linux build with gcc 14. Only the pool reading above differs. -- Either way, the GB10's exactness checks must be repeated on the N1X. No N1X run of Mini exists yet. +## RTX Spark (N1X): native Windows ARM64 on Net's laptop + +`n1x-run.ps1` runs the same checkpoint (`C:\models\Inkling-2-Mini-ed40e7da62`) on the laptop through its Codync bot +`codync@rtx-spark`, relayed by the Desk, one step a run, each under 10 minutes. It installs and downloads nothing; the +laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. + +1. `-Step build`: `zig build install native -Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and + `cl.exe` arm64 (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, + `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A clean build took 530-629 s there. +2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: + `kernel-contract "inkling2 loop"`, `inkling2-serving`, `inkling2-mini-ref` (32 greedy tokens equal to the float64 + reference) and its planted control, which must go red. +3. `-Step serve`: one server at `--parallel 4 --context 8192`, greedy 256-token streams at 1 and 4, first token and + decode a stream, total decode, ready time, and the peak of the WDDM pool (`nvidia-smi memory.used`, sampled while + decoding) and the server's working set. + +What differs from the GB10 and is not copied from it: + +- Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it + through `cuMemGetInfo_v2`. The 20 GB checkpoint leaves about 20 GiB of it for the cache and four streams. +- The power cap (42-49 W at about 2.1 GHz in HP Performance mode, near 1.4 GHz in power saving, from the 2026-11-04 + receipt in [WINDOWS.md](../../WINDOWS.md)) bounds decode, so each run prints the power plan, limit and SM clock. +- The bandwidth limit uses the laptop's own measured rate, not GB10's 273 GB/s. + +No laptop run of this branch has returned yet: the receipt (exact commands, exit codes, 1/4-stream tok/s, first-token +time, peak memory) and any N1X tuning wait on the Desk's relay to `codync@rtx-spark`. From e5db56009c9965685e9901d4aca92d00984b3602 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:06:31 +0800 Subject: [PATCH 07/23] tests: inkling2-mini-ref exits non-zero when its planted control differs; the GB10 script requires it --- docs/recipes/inkling-2-mini-cuda/run-script.sh | 6 +++++- zig/tests/cuda/inkling2_mini_tests.zig | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/run-script.sh b/docs/recipes/inkling-2-mini-cuda/run-script.sh index 8450321a0a3..a3c555b7bc7 100755 --- a/docs/recipes/inkling-2-mini-cuda/run-script.sh +++ b/docs/recipes/inkling-2-mini-cuda/run-script.sh @@ -41,7 +41,11 @@ python3 -c 'import random; r = random.Random(4387); print(" ".join(str(r.randran "$bin/tf-cuda-test" inkling2-serving "$model" "$out/ids.txt" text="The three laws of thermodynamics, explained for a curious student:" "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" -INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" +# the planted control must go red: tf-cuda-test exits non-zero when its tokens differ +if INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text"; then + echo "planted control stayed green" >&2 + exit 1 +fi mem() { echo "$1: host $(awk '/^MemTotal:/ {t = $2} /^MemAvailable:/ {a = $2} END {printf "used %d MiB, available %d MiB", (t - a) / 1024, a / 1024}' /proc/meminfo); GPU $(nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader | tr '\n' ' ')"; } mem "before the server" /work/sm121/native/bin/tensorfold-native serve "$model" --backend cuda --host 127.0.0.1 --port 8188 \ diff --git a/zig/tests/cuda/inkling2_mini_tests.zig b/zig/tests/cuda/inkling2_mini_tests.zig index 43bb5fdfb34..a56cb42c38b 100644 --- a/zig/tests/cuda/inkling2_mini_tests.zig +++ b/zig/tests/cuda/inkling2_mini_tests.zig @@ -274,6 +274,5 @@ pub fn reference(gpu: Gpu, model: []const u8, count_text: []const u8, text: []co const said = try tok.decode(gpa, all[ids.len..], false); defer gpa.free(said); std.debug.print("RESULT inkling2 mini vs float64 reference{s}: {d} of {d} greedy tokens differ, smallest reference margin {d:.4}: \"{s}\"\n", .{ if (plant) " (PLANTED: no messages)" else "", differ, count, smallest, said }); - if (plant) return check.expect(differ > 0, "inkling2 mini planted control: the reference without messages still agrees", .{}); try check.expect(differ == 0, "inkling2 mini greedy == reference: {d} of {d} tokens differ", .{ differ, count }); } From b8ebd6f13513a44d000aa612815ed351d4b3a8f4 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:06:31 +0800 Subject: [PATCH 08/23] contract: name the MLP128 tile's sm_120-only rule instead of the cluster path's sm_90 floor --- zig/tests/cuda/contract_tests.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zig/tests/cuda/contract_tests.zig b/zig/tests/cuda/contract_tests.zig index 87eb83ac66d..4b15e0a74b0 100644 --- a/zig/tests/cuda/contract_tests.zig +++ b/zig/tests/cuda/contract_tests.zig @@ -216,7 +216,8 @@ fn registered(gpu: check.Gpu, only: []const []const u8, t0: *i96) !g.Tally { defer for (&mm) |*m| m.deinit(); for (&mm) |*m| { const k = m.kernel() orelse { - std.debug.print("N/A {s}: cluster path needs sm_90 or newer, this GPU is sm_{d}\n", .{ mm_k.spec(m.kind).name, cap }); + const why = if (m.kind == .mlp128_bits or m.kind == .mlp128_fp64) "the MLP128 tile is served only on sm_120" else "cluster path needs sm_90 or newer"; + std.debug.print("N/A {s}: {s}, this GPU is sm_{d}\n", .{ mm_k.spec(m.kind).name, why, cap }); continue; }; if (cap < 90 and (m.kind == .lane_gemv or m.kind == .lane_gemv_split)) From 99bf65181ea110f2e772bb8d9ad87e54fb4cbae0 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:06:32 +0800 Subject: [PATCH 09/23] docs: n1x-run.ps1 queries the N1X by name, as the laptop's nvidia-smi also lists an NPU --- docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index 92313be205a..6f62aff42e8 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -17,13 +17,19 @@ function Run([string]$exe, [string[]]$argv) { if ($LASTEXITCODE) { exit $LASTEXITCODE } } +# nvidia-smi on the laptop also lists an NVIDIA NPU, so every query names the N1X by its index, found by name +$gpus = nvidia-smi --query-gpu=index,name --format=csv,noheader +$gpu = @($gpus | Where-Object { $_ -match 'N1X' }) +if ($gpu.Count -ne 1) { throw "want one N1X in nvidia-smi, got: $($gpus -join '; ')" } +$gpu = $gpu[0].Split(',')[0].Trim() + # The WDDM device pool the driver gives CUDA (the N1X shares it with the CPU; firmware sets its size), MiB function Pool([string]$label) { - Write-Output "$label`: $(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader)" + Write-Output "$label`: $(nvidia-smi -i $gpu --query-gpu=memory.used,memory.total --format=csv,noheader)" } Run (Join-Path $env:CUDA_PATH 'bin\nvcc.exe') @('--version') -nvidia-smi --query-gpu=name,driver_version,power.limit,clocks.max.sm --format=csv,noheader +nvidia-smi -i $gpu --query-gpu=name,driver_version,power.limit,clocks.max.sm --format=csv,noheader Write-Output "power plan: $(powercfg /getactivescheme)" $test = 'zig-out\bin\tf-cuda-test.exe' $server = 'zig-out\native\bin\tensorfold-native.exe' @@ -97,7 +103,7 @@ try { $s.last = $clock.Elapsed.TotalSeconds } } - $used = [int](nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) + $used = [int](nvidia-smi -i $gpu --query-gpu=memory.used --format=csv,noheader,nounits) if ($used -gt $peak) { $peak = $used } } $total = 0 From 2a37918af9d73ddd15a24c2d85fa8b0e27412eae Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:06:32 +0800 Subject: [PATCH 10/23] docs: Inkling 2 Mini N1X run 1 on the laptop: build and checks pass, serve stopped on the NPU row --- ...-inkling-2-mini-runs-on-net-s-rtx-spark-l.md | 6 +++++- docs/recipes/inkling-2-mini-cuda/README.md | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index 03f6766228a..d9a70b37cb4 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -5,4 +5,8 @@ `compile-native-cuda-windows` checking the sm_121 aarch64 product. - `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in three short steps (build, 188's exactness checks, 1/4-stream serving with first token and the WDDM pool's peak), with no Python, installs - or downloads. No laptop receipt yet. + or downloads; it queries the N1X by name, as the laptop's `nvidia-smi` also lists an NPU. Run 1 on the laptop: the + build and every check pass (32 of 32 greedy tokens equal the float64 reference); the tok/s receipt is next. +- `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does, and + the GB10 script requires that; the kernel contract says the MLP128 tile is served only on sm_120 instead of blaming + the cluster path on sm_121. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index ef5672fd2a2..993b613aa94 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -34,12 +34,14 @@ here, gave 5.7 tok/s at one stream and 9.4 at four on the same GB10 (job `top-07 ## RTX Spark (N1X): native Windows ARM64 on Net's laptop `n1x-run.ps1` runs the same checkpoint (`C:\models\Inkling-2-Mini-ed40e7da62`) on the laptop through its Codync bot -`codync@rtx-spark`, relayed by the Desk, one step a run, each under 10 minutes. It installs and downloads nothing; the -laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. +`codync@rtx-spark`, relayed by the Desk, one step a run; check and serve stop well inside 10 minutes. It installs and +downloads nothing; the laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not +`bench_concurrent.py`. 1. `-Step build`: `zig build install native -Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, - `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A clean build took 530-629 s there. + `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A clean build took 647 s there; a + rebuild after a pull reuses the cache. 2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: `kernel-contract "inkling2 loop"`, `inkling2-serving`, `inkling2-mini-ref` (32 greedy tokens equal to the float64 reference) and its planted control, which must go red. @@ -49,11 +51,16 @@ laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the scri What differs from the GB10 and is not copied from it: +- `nvidia-smi` there also lists an NVIDIA NPU, so the script finds the N1X by name and queries only its index; + `memory.used` over every device gave an array and stopped run 1's serve step. - Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it through `cuMemGetInfo_v2`. The 20 GB checkpoint leaves about 20 GiB of it for the cache and four streams. - The power cap (42-49 W at about 2.1 GHz in HP Performance mode, near 1.4 GHz in power saving, from the 2026-11-04 receipt in [WINDOWS.md](../../WINDOWS.md)) bounds decode, so each run prints the power plan, limit and SM clock. - The bandwidth limit uses the laptop's own measured rate, not GB10's 273 GB/s. -No laptop run of this branch has returned yet: the receipt (exact commands, exit codes, 1/4-stream tok/s, first-token -time, peak memory) and any N1X tuning wait on the Desk's relay to `codync@rtx-spark`. +Run 1 at `b2ddc3de` (clean tree): build exit 0 in 647 s; check: `kernel-contract "inkling2 loop"` 5/5 pass with both +controls red, `inkling2-serving` 3/3 pass (resumed equals fresh), `inkling2-mini-ref` 0 of 32 tokens differ (smallest +margin 0.110, 224.7 s), the planted control 6 of 32 differ; serve: ready in 55.3 s (19.82 GiB, 4 streams, 16 GiB prompt +cache, WDDM pool 2.7 to 23.3 GiB), first completion 200, then the NPU row above stopped the script before any tok/s. +The 1/4-stream receipt waits on run 2. From 226b907d789060ec33ef4c91945d1b7119194576 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 04:39:55 +0800 Subject: [PATCH 11/23] docs: GB10 job top-9defa53c0bfc confirms the planted control's non-zero exit --- docs/recipes/inkling-2-mini-cuda/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 993b613aa94..808a1b8dfb3 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -31,6 +31,9 @@ Bandwidth limit: a decoded token reads about 5.55 GB of weights (core layers 3 p whole unembedding), so 273 GB/s caps one stream near 49 tok/s; 32.5 tok/s is 66% of it. #4387's own engine, removed here, gave 5.7 tok/s at one stream and 9.4 at four on the same GB10 (job `top-0759755a0515`). +Job `top-9defa53c0bfc` at `2a37918af` reran it with the planted control's new exit: the control's 6 of 32 differing +tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one stream and 121.4 at four (3.59x). + ## RTX Spark (N1X): native Windows ARM64 on Net's laptop `n1x-run.ps1` runs the same checkpoint (`C:\models\Inkling-2-Mini-ed40e7da62`) on the laptop through its Codync bot From 484a03ca0f90b6396dca2ecefae9690254f9c594 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 05:25:13 +0800 Subject: [PATCH 12/23] docs: n1x-run.ps1 times serving from the server's done lines and runs the planted control as its own step --- docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 86 +++++++++----------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index 6f62aff42e8..a7c3d7dc62f 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -1,9 +1,9 @@ # Inkling 2 Mini (revision ed40e7da62) whole on an RTX Spark N1X laptop, native Windows ARM64, run by its Codync bot: -# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step build|check|serve +# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step build|check|control|serve # From a clean checkout with `vcvarsall arm64` set up and CUDA_PATH naming the windows-arm64 toolkit. Installs, downloads -# and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step stops itself well inside 10 minutes. +# and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step after a warm build stops inside 10 minutes. param( - [Parameter(Mandatory)][ValidateSet('build', 'check', 'serve')][string]$Step, + [Parameter(Mandatory)][ValidateSet('build', 'check', 'control', 'serve')][string]$Step, [string]$Model = 'C:\models\Inkling-2-Mini-ed40e7da62' ) $ErrorActionPreference = 'Stop' @@ -39,6 +39,7 @@ if ($Step -eq 'build') { exit 0 } +$text = 'The three laws of thermodynamics, explained for a curious student:' if ($Step -eq 'check') { # 188's GB10 checks as they are: the served kernels, #4387's serving checks, the float64 reference Run $test @('info') @@ -46,17 +47,25 @@ if ($Step -eq 'check') { $r = New-Object System.Random 4387 (1..4200 | ForEach-Object { $r.Next(1000, 199000) }) -join ' ' | Set-Content -Encoding ascii "$out\ids.txt" Run $test @('inkling2-serving', $Model, "$out\ids.txt") - $text = 'The three laws of thermodynamics, explained for a curious student:' Run $test @('inkling2-mini-ref', $Model, '32', $text) + exit 0 +} + +# The reference's planted control is its own step: the float64 reference takes 226 s on the N1X, twice is over 10 min. +# Alone, any non-zero exit (a bad path, no GPU) would pass it, so it also needs the plant's own differing tokens. +if ($Step -eq 'control') { $env:INKLING2_REF_PLANT = '1' - & $test inkling2-mini-ref $Model 32 $text - Write-Output "planted control EXIT=$LASTEXITCODE (must be non-zero)" - Remove-Item Env:INKLING2_REF_PLANT - if (-not $LASTEXITCODE) { exit 1 } + $ref = Start-Process -FilePath $test -Wait -PassThru -NoNewWindow -RedirectStandardError "$out\control.log" ` + -ArgumentList @('inkling2-mini-ref', "`"$Model`"", '32', "`"$text`"") + Get-Content "$out\control.log" + Write-Output "planted control EXIT=$($ref.ExitCode) (must be non-zero)" + $planted = Select-String -Path "$out\control.log" -Pattern '\(PLANTED: no messages\): [1-9]\d* of 32 greedy tokens differ' + if (-not $ref.ExitCode -or -not $planted) { exit 1 } exit 0 } -# serve: one server, 1 then 4 greedy streams of 256 tokens, first token and decode per stream, the pool's peak +# serve: one server, 1 then 4 greedy 256-token replies, timed by the server's own `done` lines (first token, decode): +# run 2's client timed itself, as PowerShell's line reads fell 4x behind the server's output Pool 'before the server' $port = 8188 $proc = Start-Process -FilePath $server -PassThru -NoNewWindow -RedirectStandardOutput "$out\server.log" ` @@ -72,54 +81,37 @@ try { } Write-Output ("RESULT n1x server ready in {0:N1} s" -f $loaded.Elapsed.TotalSeconds) Pool 'server loaded' + # nvidia-smi samples the pool every 500 ms in its own process for the whole run; its largest sample is the peak + $smi = Start-Process -FilePath nvidia-smi -PassThru -NoNewWindow -RedirectStandardOutput "$out\pool.csv" ` + -ArgumentList @('-i', $gpu, '--query-gpu=memory.used', '--format=csv,noheader,nounits', '-lms', '500') Add-Type -AssemblyName System.Net.Http $http = New-Object System.Net.Http.HttpClient $http.Timeout = [TimeSpan]::FromMinutes(4) - $peak = 0 + $body = '{"model":"inkling-2-mini","prompt":"Write a short Python function that computes the Fibonacci ' + + 'sequence and explain it.","max_tokens":256,"temperature":0,"ignore_eos":true}' foreach ($n in 1, 4) { - $clock = [Diagnostics.Stopwatch]::StartNew() - $body = '{"model":"inkling-2-mini","prompt":"Write a short Python function that computes the Fibonacci ' + - 'sequence and explain it.","max_tokens":256,"temperature":0,"ignore_eos":true,"stream":true,' + - '"stream_options":{"include_usage":true}}' + $before = @(Select-String -Path "$out\server.log" -Pattern '\] done ').Count $calls = foreach ($i in 1..$n) { - $req = New-Object System.Net.Http.HttpRequestMessage 'Post', "http://127.0.0.1:$port/v1/completions" - $req.Content = New-Object System.Net.Http.StringContent $body, ([Text.Encoding]::UTF8), 'application/json' - $http.SendAsync($req, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead) - } - $streams = foreach ($c in $calls) { - $reader = New-Object IO.StreamReader $c.Result.Content.ReadAsStreamAsync().Result - @{ reader = $reader; first = $null; last = $null; tokens = $null } - } - # read the streams in turn: a reply's pieces wait in its socket, the clock stamps when each is read - while ($streams | Where-Object { $_.reader }) { - foreach ($s in $streams | Where-Object { $_.reader }) { - $line = $s.reader.ReadLine() - if ($null -eq $line -or $line -eq 'data: [DONE]') { $s.reader = $null; continue } - if (-not $line.StartsWith('data: ')) { continue } - $j = $line.Substring(6) | ConvertFrom-Json - if ($j.usage) { $s.tokens = $j.usage.completion_tokens } - if ($j.choices -and $j.choices[0].text) { - if ($null -eq $s.first) { $s.first = $clock.Elapsed.TotalSeconds } - $s.last = $clock.Elapsed.TotalSeconds - } - } - $used = [int](nvidia-smi -i $gpu --query-gpu=memory.used --format=csv,noheader,nounits) - if ($used -gt $peak) { $peak = $used } + $http.PostAsync("http://127.0.0.1:$port/v1/completions", + (New-Object System.Net.Http.StringContent $body, ([Text.Encoding]::UTF8), 'application/json')) } + foreach ($c in $calls) { if (-not $c.Result.IsSuccessStatusCode) { throw "$n streams: $($c.Result.StatusCode)" } } + $done = @(Select-String -Path "$out\server.log" -Pattern '\] done ' | Select-Object -Skip $before) + if ($done.Count -ne $n) { throw "$n streams: want $n done lines, got $($done.Count)" } $total = 0 - foreach ($s in $streams) { - if ($s.tokens -ne 256) { throw "$n streams: a reply ended at $($s.tokens) tokens" } - $tps = ($s.tokens - 1) / ($s.last - $s.first) - $total += $s.tokens - 1 - Write-Output ("RESULT n1x {0} stream(s): first token {1:N3} s, decode {2:N1} tok/s" -f $n, $s.first, $tps) + foreach ($d in $done) { + if ($d.Line -notmatch 'tokens=256 .*ttft=([\d.]+) .*tok/s=([\d.]+)') { throw "not a 256-token reply: $($d.Line)" } + $total += [double]$Matches[2] + Write-Output "RESULT n1x $n stream(s): first token $($Matches[1]) s, decode $($Matches[2]) tok/s" } - $span = ($streams | ForEach-Object { $_.last } | Measure-Object -Maximum).Maximum - - ($streams | ForEach-Object { $_.first } | Measure-Object -Minimum).Minimum - Write-Output ("RESULT n1x {0} stream(s) total decode {1:N1} tok/s" -f $n, ($total / $span)) + Write-Output ("RESULT n1x {0} stream(s) total decode {1:N1} tok/s" -f $n, $total) } - Write-Output "RESULT n1x peak GPU memory sampled while decoding: $peak MiB" + $smi.Kill(); $smi.WaitForExit() + $peak = (Get-Content "$out\pool.csv" | ForEach-Object { [int]$_ } | Measure-Object -Maximum).Maximum + if (-not $peak) { throw "no samples in $out\pool.csv" } + Write-Output "RESULT n1x peak GPU memory sampled every 500 ms: $peak MiB" Write-Output "RESULT n1x server process peak working set $([int]($proc.PeakWorkingSet64 / 1MB)) MiB" } finally { - if (-not $proc.HasExited) { Stop-Process -Id $proc.Id } + foreach ($p in $proc, $smi) { if ($p -and -not $p.HasExited) { $p.Kill() } } Get-Content "$out\server.err" -Tail 20 } From df6af4786bbb22a54e862e13405209550187feed Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 05:25:13 +0800 Subject: [PATCH 13/23] docs: Inkling 2 Mini N1X run 2 receipt: checks pass, 32.2 tok/s at one stream, 117.0 at four --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 9 ++-- docs/recipes/inkling-2-mini-cuda/README.md | 53 +++++++++++++------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index d9a70b37cb4..08cfef94d50 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -3,10 +3,11 @@ - Brings 189's Windows ARM64 fixes onto 188's Inkling 2 Mini engine: `__noinline__` in `glm_index_rope.cuh` and `/wd4819` for nvcc with cl.exe, POSIX file modes and COM `@alignCast` in the server, no `tf-muse` on Windows, and `compile-native-cuda-windows` checking the sm_121 aarch64 product. -- `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in three short steps - (build, 188's exactness checks, 1/4-stream serving with first token and the WDDM pool's peak), with no Python, installs - or downloads; it queries the N1X by name, as the laptop's `nvidia-smi` also lists an NPU. Run 1 on the laptop: the - build and every check pass (32 of 32 greedy tokens equal the float64 reference); the tok/s receipt is next. +- `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in short steps + (build, 188's exactness checks, the reference's planted control, 1/4-stream serving timed by the server's own `done` + lines with the WDDM pool's peak), with no Python, installs or downloads; it queries the N1X by name, as the laptop's + `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 of 32 greedy tokens equal the float64 + reference), 32.2 tok/s at one stream and 117.0 total at four, first token 0.104 s, pool peak 23,335 MiB. - `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does, and the GB10 script requires that; the kernel contract says the MLP128 tile is served only on sm_120 instead of blaming the cluster path on sm_121. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 808a1b8dfb3..19f7ff15f23 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -37,33 +37,54 @@ tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one str ## RTX Spark (N1X): native Windows ARM64 on Net's laptop `n1x-run.ps1` runs the same checkpoint (`C:\models\Inkling-2-Mini-ed40e7da62`) on the laptop through its Codync bot -`codync@rtx-spark`, relayed by the Desk, one step a run; check and serve stop well inside 10 minutes. It installs and -downloads nothing; the laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not -`bench_concurrent.py`. +`codync@rtx-spark`, relayed by the Desk, one step a run. It installs and downloads nothing; the laptop has PowerShell +but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. 1. `-Step build`: `zig build install native -Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, - `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A clean build took 647 s there; a - rebuild after a pull reuses the cache. + `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A cold zig cache took 647 s (run 1) + and 901 s (run 2); a rebuild after a pull reuses the cache. 2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: - `kernel-contract "inkling2 loop"`, `inkling2-serving`, `inkling2-mini-ref` (32 greedy tokens equal to the float64 - reference) and its planted control, which must go red. -3. `-Step serve`: one server at `--parallel 4 --context 8192`, greedy 256-token streams at 1 and 4, first token and - decode a stream, total decode, ready time, and the peak of the WDDM pool (`nvidia-smi memory.used`, sampled while - decoding) and the server's working set. + `kernel-contract "inkling2 loop"`, `inkling2-serving` and `inkling2-mini-ref` (32 greedy tokens equal to the float64 + reference). +3. `-Step control`: the reference's planted control, which must exit non-zero with its tokens differing. +4. `-Step serve`: one server at `--parallel 4 --context 8192`, greedy 256-token replies at 1 and 4 streams; first token + and decode per stream come from the server's own `done` lines, with the ready time, the WDDM pool's peak + (`nvidia-smi -lms 500` in its own process) and the server's peak working set. What differs from the GB10 and is not copied from it: - `nvidia-smi` there also lists an NVIDIA NPU, so the script finds the N1X by name and queries only its index; `memory.used` over every device gave an array and stopped run 1's serve step. +- The host float64 reference takes 226 s on the laptop, so the planted control is its own step: run 2 ran both in + one step for 11 min 10 s. +- The serve step times replies from the server's log, not the client: run 2's client read the stream line by line and + spawned `nvidia-smi` per line, which put it at 6.7 tok/s at one stream while the server decoded at 32.2. - Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it through `cuMemGetInfo_v2`. The 20 GB checkpoint leaves about 20 GiB of it for the cache and four streams. - The power cap (42-49 W at about 2.1 GHz in HP Performance mode, near 1.4 GHz in power saving, from the 2026-11-04 receipt in [WINDOWS.md](../../WINDOWS.md)) bounds decode, so each run prints the power plan, limit and SM clock. -- The bandwidth limit uses the laptop's own measured rate, not GB10's 273 GB/s. -Run 1 at `b2ddc3de` (clean tree): build exit 0 in 647 s; check: `kernel-contract "inkling2 loop"` 5/5 pass with both -controls red, `inkling2-serving` 3/3 pass (resumed equals fresh), `inkling2-mini-ref` 0 of 32 tokens differ (smallest -margin 0.110, 224.7 s), the planted control 6 of 32 differ; serve: ready in 55.3 s (19.82 GiB, 4 streams, 16 GiB prompt -cache, WDDM pool 2.7 to 23.3 GiB), first completion 200, then the NPU row above stopped the script before any tok/s. -The 1/4-stream receipt waits on run 2. +Run 1 at `b2ddc3de` (clean tree): build exit 0; check passed as in run 2; serve was ready in 55.3 s, then the NPU row +above stopped the script before any tok/s. + +### Receipt: run 2 at `2a37918af`, one capped run + +Desk request `bb869e9b` on `codync@rtx-spark`, clean clone (`git status --porcelain` empty before and after the build), +`powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step `. This is one run +with these settings, not a benchmark. + +| Step | Exit | Time | Result | +|---|---|---|---| +| `build` | 0 | 15 min 1 s (cold cache) | no error lines | +| `check` (with the control, as it then was) | 0 | 11 min 10 s | `kernel-contract "inkling2 loop"` 5/5 pass gates 1-4, 2/2 controls red; `inkling2-serving` PASS (CUDA equals the host reference token for token, fresh equals resumed, admission); `inkling2-mini-ref` 0 of 32 tokens differ (smallest margin 0.110, 226 s); planted control 6 of 32 differ, exit 1 | +| `serve` | 0 | | ready in 58.4 s: 19.82 GiB model, 4 streams x 0.49 GiB at 8192, 16 GiB prompt cache | + +| Streams | First token | Decode a stream | Total decode | Failed | +|---|---|---|---|---| +| 1 | 0.104 s | 32.2 tok/s | 32.2 tok/s | 0 | +| 4 | 0.096-0.357 s | 28.8 / 29.1 / 29.4 / 29.7 tok/s | 117.0 tok/s (3.63x) | 0 | + +Times are the server's `done` lines (256 tokens each, `finish=length`). Peak GPU memory: the WDDM pool's largest +sample was 23,335 MiB (run 1 sampled 2.7 GiB before the server). The N1X decoded one stream as fast as GB10 (32.2 +against 32.5 tok/s) and four streams at 117.0 against 117.8. From b785448499dfa536f65056f60c5499157b76ee49 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:36:38 +0800 Subject: [PATCH 14/23] docs: the GB10 script's planted control needs its differing tokens, not only a non-zero exit --- docs/recipes/inkling-2-mini-cuda/run-script.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/run-script.sh b/docs/recipes/inkling-2-mini-cuda/run-script.sh index a3c555b7bc7..3d876f15de9 100755 --- a/docs/recipes/inkling-2-mini-cuda/run-script.sh +++ b/docs/recipes/inkling-2-mini-cuda/run-script.sh @@ -41,11 +41,14 @@ python3 -c 'import random; r = random.Random(4387); print(" ".join(str(r.randran "$bin/tf-cuda-test" inkling2-serving "$model" "$out/ids.txt" text="The three laws of thermodynamics, explained for a curious student:" "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" -# the planted control must go red: tf-cuda-test exits non-zero when its tokens differ -if INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text"; then +# the planted control must go red with its own differing tokens: a load or CUDA failure also exits non-zero +if INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" 2>"$out/control.log"; then echo "planted control stayed green" >&2 exit 1 fi +cat "$out/control.log" >&2 +grep -Eq '\(PLANTED: no messages\): [1-9][0-9]* of 32 greedy tokens differ' "$out/control.log" || + { echo "planted control failed before comparing tokens" >&2; exit 1; } mem() { echo "$1: host $(awk '/^MemTotal:/ {t = $2} /^MemAvailable:/ {a = $2} END {printf "used %d MiB, available %d MiB", (t - a) / 1024, a / 1024}' /proc/meminfo); GPU $(nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader | tr '\n' ' ')"; } mem "before the server" /work/sm121/native/bin/tensorfold-native serve "$model" --backend cuda --host 127.0.0.1 --port 8188 \ From a86ccbd1ef00b39f0440311d0c02c7f5cdb19731 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:36:38 +0800 Subject: [PATCH 15/23] docs: n1x-run.ps1 builds in two steps of at most 9 minutes (nvcc's images, then the Zig products) --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 17 +++++++------ docs/recipes/inkling-2-mini-cuda/README.md | 13 +++++----- docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 25 ++++++++++++++----- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index 08cfef94d50..db8d12c54e9 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -3,11 +3,12 @@ - Brings 189's Windows ARM64 fixes onto 188's Inkling 2 Mini engine: `__noinline__` in `glm_index_rope.cuh` and `/wd4819` for nvcc with cl.exe, POSIX file modes and COM `@alignCast` in the server, no `tf-muse` on Windows, and `compile-native-cuda-windows` checking the sm_121 aarch64 product. -- `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in short steps - (build, 188's exactness checks, the reference's planted control, 1/4-stream serving timed by the server's own `done` - lines with the WDDM pool's peak), with no Python, installs or downloads; it queries the N1X by name, as the laptop's - `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 of 32 greedy tokens equal the float64 - reference), 32.2 tok/s at one stream and 117.0 total at four, first token 0.104 s, pool peak 23,335 MiB. -- `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does, and - the GB10 script requires that; the kernel contract says the MLP128 tile is served only on sm_120 instead of blaming - the cluster path on sm_121. +- `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in steps of under + 10 minutes (nvcc's kernel images, the Zig build, 188's exactness checks, the reference's planted control, 1/4-stream + serving timed by the server's own `done` lines with the WDDM pool's peak), with no Python, installs or downloads; it + queries the N1X by name, as the laptop's `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 + of 32 greedy tokens equal the float64 reference), 32.2 tok/s at one stream and 117.0 total at four, first token + 0.104 s, pool peak 23,335 MiB. +- `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does; the + GB10 and N1X scripts require that exit and the plant's differing tokens, so a load or CUDA failure cannot pass it. + The kernel contract says the MLP128 tile is served only on sm_120 instead of blaming the cluster path on sm_121. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 19f7ff15f23..9d3fd89ff8c 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -40,10 +40,10 @@ tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one str `codync@rtx-spark`, relayed by the Desk, one step a run. It installs and downloads nothing; the laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. -1. `-Step build`: `zig build install native -Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and - `cl.exe` arm64 (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, - `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). A cold zig cache took 647 s (run 1) - and 901 s (run 2); a rebuild after a pull reuses the cache. +1. `-Step fatbins`, then `-Step build`: `zig build fatbins`, then `zig build install native`, both `-Dsm=121 + -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 (`vcvarsall arm64`). 189's + Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, `/wd4819`, POSIX file modes and COM + `@alignCast` in the server, no `tf-muse`). Each stops at 9 min; a cut-off step resumes from the zig cache. 2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: `kernel-contract "inkling2 loop"`, `inkling2-serving` and `inkling2-mini-ref` (32 greedy tokens equal to the float64 reference). @@ -56,8 +56,9 @@ What differs from the GB10 and is not copied from it: - `nvidia-smi` there also lists an NVIDIA NPU, so the script finds the N1X by name and queries only its index; `memory.used` over every device gave an array and stopped run 1's serve step. -- The host float64 reference takes 226 s on the laptop, so the planted control is its own step: run 2 ran both in - one step for 11 min 10 s. +- A cold build took 647 s (run 1) and 901 s (run 2) in one piece, over a run's 10 minutes, so nvcc's kernel images are + their own step. The host float64 reference takes 226 s on the laptop, so the planted control is its own step: run 2 + ran both in one step for 11 min 10 s. - The serve step times replies from the server's log, not the client: run 2's client read the stream line by line and spawned `nvidia-smi` per line, which put it at 6.7 tok/s at one stream while the server decoded at 32.2. - Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index a7c3d7dc62f..b47cc61603a 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -1,9 +1,9 @@ # Inkling 2 Mini (revision ed40e7da62) whole on an RTX Spark N1X laptop, native Windows ARM64, run by its Codync bot: -# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step build|check|control|serve +# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step fatbins|build|check|control|serve # From a clean checkout with `vcvarsall arm64` set up and CUDA_PATH naming the windows-arm64 toolkit. Installs, downloads -# and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step after a warm build stops inside 10 minutes. +# and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step stops itself inside 10 minutes. param( - [Parameter(Mandatory)][ValidateSet('build', 'check', 'control', 'serve')][string]$Step, + [Parameter(Mandatory)][ValidateSet('fatbins', 'build', 'check', 'control', 'serve')][string]$Step, [string]$Model = 'C:\models\Inkling-2-Mini-ed40e7da62' ) $ErrorActionPreference = 'Stop' @@ -34,9 +34,22 @@ Write-Output "power plan: $(powercfg /getactivescheme)" $test = 'zig-out\bin\tf-cuda-test.exe' $server = 'zig-out\native\bin\tensorfold-native.exe' -if ($Step -eq 'build') { - Run zig @('build', 'install', 'native', '-Dsm=121', "-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe", '-Doptimize=ReleaseFast') - exit 0 +# A cold build ran 15 min in one piece (run 2), so it is two steps: nvcc's 147 kernel images, then the Zig products over +# them from the cache. Each stops at 9 min; a step cut off resumes from the cache when it runs again. +if ($Step -in 'fatbins', 'build') { + $targets = if ($Step -eq 'fatbins') { @('fatbins') } else { @('install', 'native') } + $argv = $targets + @('-Dsm=121', "`"-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe`"", '-Doptimize=ReleaseFast') + Write-Output "> zig build $argv" + $clock = [Diagnostics.Stopwatch]::StartNew() + $zig = Start-Process -FilePath zig -ArgumentList (@('build') + $argv) -PassThru -NoNewWindow + $null = $zig.Handle # without a handle taken now, .NET Framework loses the exit code once the process ends + if (-not $zig.WaitForExit(540000)) { + & taskkill /T /F /PID $zig.Id | Out-Null + Write-Output "EXIT=timeout after 9 min: run -Step $Step again to resume from the cache" + exit 1 + } + Write-Output ("EXIT={0} in {1:N0} s" -f $zig.ExitCode, $clock.Elapsed.TotalSeconds) + exit $zig.ExitCode } $text = 'The three laws of thermodynamics, explained for a curious student:' From 26de83095a7a46c997de54b1c58dd84b22924a2d Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 08:10:27 +0800 Subject: [PATCH 16/23] docs: n1x-run.ps1 keeps its zig build targets an array, as run 3's fatbins step ran 'fatbins-Dsm=121' --- docs/recipes/inkling-2-mini-cuda/README.md | 4 ++++ docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 9d3fd89ff8c..fbc635434e5 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -69,6 +69,10 @@ What differs from the GB10 and is not copied from it: Run 1 at `b2ddc3de` (clean tree): build exit 0; check passed as in run 2; serve was ready in 55.3 s, then the NPU row above stopped the script before any tok/s. +Run 3 at `a86ccbd1` (request `39062c42`, clean tree): `-Step fatbins` exited 1 in 20 s with `no such step: +fatbins-Dsm=121`, as PowerShell unrolled the one-element target list to a string that `+` then appended to; the +script now keeps it an array. + ### Receipt: run 2 at `2a37918af`, one capped run Desk request `bb869e9b` on `codync@rtx-spark`, clean clone (`git status --porcelain` empty before and after the build), diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index b47cc61603a..18ee524e6f1 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -37,7 +37,8 @@ $server = 'zig-out\native\bin\tensorfold-native.exe' # A cold build ran 15 min in one piece (run 2), so it is two steps: nvcc's 147 kernel images, then the Zig products over # them from the cache. Each stops at 9 min; a step cut off resumes from the cache when it runs again. if ($Step -in 'fatbins', 'build') { - $targets = if ($Step -eq 'fatbins') { @('fatbins') } else { @('install', 'native') } + # @() keeps 'fatbins' an array: an if's one-element result unrolls to a string, and + would then append to it + $targets = @(if ($Step -eq 'fatbins') { 'fatbins' } else { 'install', 'native' }) $argv = $targets + @('-Dsm=121', "`"-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe`"", '-Doptimize=ReleaseFast') Write-Output "> zig build $argv" $clock = [Diagnostics.Stopwatch]::StartNew() From 0e5960ed7380fe2ba9dbc01b8d28b11287359065 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 09:30:55 +0800 Subject: [PATCH 17/23] build: tf-cuda-test step installs the CUDA runner alone --- zig/build/cuda.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zig/build/cuda.zig b/zig/build/cuda.zig index 05ee2b2fb7f..0ea2240f270 100644 --- a/zig/build/cuda.zig +++ b/zig/build/cuda.zig @@ -138,7 +138,9 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu runner.addImport("moss_image_cuda", b.createModule(.{ .root_source_file = b.path("zig/src/families/moss_image/cuda_kernels.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{.{ .name = "cuda", .module = cuda }} })); runner.addImport("prompt_pages", b.createModule(.{ .root_source_file = b.path("zig/src/native/cuda_prompt_pages.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "engine_api", .module = mods.api }, .{ .name = "core", .module = mods.core } } })); // TF_KV_SHARE's store, for the pages checks const runner_exe = b.addExecutable(.{ .name = "tf-cuda-test", .root_module = runner }); - b.installArtifact(runner_exe); + const runner_install = b.addInstallArtifact(runner_exe, .{}); + b.getInstallStep().dependOn(&runner_install.step); + b.step("tf-cuda-test", "Build and install tf-cuda-test alone").dependOn(&runner_install.step); // tf-cuda-limits: kernel-contract-limits alone, built without the contracts' test sources const limits_exe = b.addExecutable(.{ .name = "tf-cuda-limits", .root_module = b.createModule(.{ .root_source_file = b.path("zig/tests/cuda/limits_main.zig"), .target = target, .optimize = optimize, .link_libc = true, .strip = strip, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = mods.core } } }) }); b.step("tf-cuda-limits", "Build kernel-contract-limits alone: the fatbins' launches against their records, no GPU").dependOn(&b.addInstallArtifact(limits_exe, .{}).step); From 2ce7e54c18c7eace585564bb84c6ea083f2eaab4 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 09:30:55 +0800 Subject: [PATCH 18/23] docs: n1x-run.ps1 builds tf-cuda-test and tensorfold-native a step each, as run 4's install native ran past 9 min twice --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 10 +++++----- docs/recipes/inkling-2-mini-cuda/README.md | 19 +++++++++++++------ docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 16 ++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index db8d12c54e9..a679b4c6b8d 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -4,11 +4,11 @@ `/wd4819` for nvcc with cl.exe, POSIX file modes and COM `@alignCast` in the server, no `tf-muse` on Windows, and `compile-native-cuda-windows` checking the sm_121 aarch64 product. - `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in steps of under - 10 minutes (nvcc's kernel images, the Zig build, 188's exactness checks, the reference's planted control, 1/4-stream - serving timed by the server's own `done` lines with the WDDM pool's peak), with no Python, installs or downloads; it - queries the N1X by name, as the laptop's `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 - of 32 greedy tokens equal the float64 reference), 32.2 tok/s at one stream and 117.0 total at four, first token - 0.104 s, pool peak 23,335 MiB. + 10 minutes (nvcc's kernel images, `tf-cuda-test` alone through the new `zig build tf-cuda-test` step, the server, + 188's exactness checks, the reference's planted control, 1/4-stream serving timed by the server's own `done` lines + with the WDDM pool's peak), with no Python, installs or downloads; it queries the N1X by name, as the laptop's + `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 of 32 greedy tokens equal the float64 + reference), 32.2 tok/s at one stream and 117.0 total at four, first token 0.104 s, pool peak 23,335 MiB. - `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does; the GB10 and N1X scripts require that exit and the plant's differing tokens, so a load or CUDA failure cannot pass it. The kernel contract says the MLP128 tile is served only on sm_120 instead of blaming the cluster path on sm_121. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index fbc635434e5..647f960892a 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -40,10 +40,11 @@ tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one str `codync@rtx-spark`, relayed by the Desk, one step a run. It installs and downloads nothing; the laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. -1. `-Step fatbins`, then `-Step build`: `zig build fatbins`, then `zig build install native`, both `-Dsm=121 - -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 (`vcvarsall arm64`). 189's - Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, `/wd4819`, POSIX file modes and COM - `@alignCast` in the server, no `tf-muse`). Each stops at 9 min; a cut-off step resumes from the zig cache. +1. `-Step fatbins`, `-Step runner`, then `-Step server`: `zig build fatbins`, `zig build tf-cuda-test`, then `zig + build native`, each `-Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 + (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, `/wd4819`, + POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). Each stops at 9 min; a cut-off step resumes from + the zig cache. 2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: `kernel-contract "inkling2 loop"`, `inkling2-serving` and `inkling2-mini-ref` (32 greedy tokens equal to the float64 reference). @@ -57,8 +58,9 @@ What differs from the GB10 and is not copied from it: - `nvidia-smi` there also lists an NVIDIA NPU, so the script finds the N1X by name and queries only its index; `memory.used` over every device gave an array and stopped run 1's serve step. - A cold build took 647 s (run 1) and 901 s (run 2) in one piece, over a run's 10 minutes, so nvcc's kernel images are - their own step. The host float64 reference takes 226 s on the laptop, so the planted control is its own step: run 2 - ran both in one step for 11 min 10 s. + their own step; `install` also builds a dozen products this card never runs (run 4 below), so the runner and the + server are a step each. The host float64 reference takes 226 s on the laptop, so the planted control is its own + step: run 2 ran both in one step for 11 min 10 s. - The serve step times replies from the server's log, not the client: run 2's client read the stream line by line and spawned `nvidia-smi` per line, which put it at 6.7 tok/s at one stream while the server decoded at 32.2. - Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it @@ -73,6 +75,11 @@ Run 3 at `a86ccbd1` (request `39062c42`, clean tree): `-Step fatbins` exited 1 i fatbins-Dsm=121`, as PowerShell unrolled the one-element target list to a string that `+` then appended to; the script now keeps it an array. +Run 4 at `26de8309` (request `407e1d7b`, clean tree): `-Step fatbins` exited 0 in 83 s with 143 images; `-Step build` +(`install native`) stopped at 9 min twice without a compile error, building `tf-drama-quant`, `tf-qwen35-learn` and +the rest of `install` beside the two binaries the checks and serving run. Cold aarch64-windows ReleaseFast +cross-compiles on a Mac took 104 s for `tf-cuda-test` and 129 s for `tensorfold-native`, each on one core. + ### Receipt: run 2 at `2a37918af`, one capped run Desk request `bb869e9b` on `codync@rtx-spark`, clean clone (`git status --porcelain` empty before and after the build), diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index 18ee524e6f1..430982d291a 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -1,9 +1,9 @@ # Inkling 2 Mini (revision ed40e7da62) whole on an RTX Spark N1X laptop, native Windows ARM64, run by its Codync bot: -# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step fatbins|build|check|control|serve +# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step fatbins|runner|server|check|control|serve # From a clean checkout with `vcvarsall arm64` set up and CUDA_PATH naming the windows-arm64 toolkit. Installs, downloads # and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step stops itself inside 10 minutes. param( - [Parameter(Mandatory)][ValidateSet('fatbins', 'build', 'check', 'control', 'serve')][string]$Step, + [Parameter(Mandatory)][ValidateSet('fatbins', 'runner', 'server', 'check', 'control', 'serve')][string]$Step, [string]$Model = 'C:\models\Inkling-2-Mini-ed40e7da62' ) $ErrorActionPreference = 'Stop' @@ -34,12 +34,12 @@ Write-Output "power plan: $(powercfg /getactivescheme)" $test = 'zig-out\bin\tf-cuda-test.exe' $server = 'zig-out\native\bin\tensorfold-native.exe' -# A cold build ran 15 min in one piece (run 2), so it is two steps: nvcc's 147 kernel images, then the Zig products over -# them from the cache. Each stops at 9 min; a step cut off resumes from the cache when it runs again. -if ($Step -in 'fatbins', 'build') { - # @() keeps 'fatbins' an array: an if's one-element result unrolls to a string, and + would then append to it - $targets = @(if ($Step -eq 'fatbins') { 'fatbins' } else { 'install', 'native' }) - $argv = $targets + @('-Dsm=121', "`"-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe`"", '-Doptimize=ReleaseFast') +# A cold build ran 15 min in one piece (run 2) and `install native` twice ran past 9 min (run 4), building a dozen +# products this card does not run, so each step builds one thing: nvcc's 147 kernel images, then tf-cuda-test, then +# tensorfold-native. Each stops at 9 min; a step cut off resumes from the cache when it runs again. +$targets = @{ fatbins = 'fatbins'; runner = 'tf-cuda-test'; server = 'native' } +if ($targets.ContainsKey($Step)) { + $argv = @($targets[$Step], '-Dsm=121', "`"-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe`"", '-Doptimize=ReleaseFast') Write-Output "> zig build $argv" $clock = [Diagnostics.Stopwatch]::StartNew() $zig = Start-Process -FilePath zig -ArgumentList (@('build') + $argv) -PassThru -NoNewWindow From 2aa2a8cae34e9273124d0cc2ec3936a48927d6c8 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:25:43 +0800 Subject: [PATCH 19/23] build: key CUDA images by nvcc's bytes, as the side-effect nvcc --version capture missed every image's cache --- zig/build/cuda.zig | 24 +++++++----------------- zig/build/cuda_contract_deepseek.zig | 4 ++-- zig/build/cuda_fatbin.zig | 6 ++++-- zig/build/dsv41_images.zig | 5 ++--- zig/build/h3_image_cuda.zig | 4 ++-- zig/build/h3_image_decoder_cuda.zig | 2 +- zig/build/h3_image_prompt_cuda.zig | 2 +- zig/build/product.zig | 7 +------ 8 files changed, 20 insertions(+), 34 deletions(-) diff --git a/zig/build/cuda.zig b/zig/build/cuda.zig index 0ea2240f270..d76e5ead7f7 100644 --- a/zig/build/cuda.zig +++ b/zig/build/cuda.zig @@ -59,19 +59,13 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu const prebuilt = opts.fatbins; const sms = opts.sms; const strip = opts.strip; - // the compiler's version text is an input of every fatbin, so a new nvcc rebuilds them all - const version: ?std.Build.LazyPath = if (prebuilt == null and nvcc != null) blk: { - const run = b.addSystemCommand(&.{ nvcc.?, "--version" }); - run.has_side_effects = true; - break :blk run.captureStdOut(.{}); - } else null; var images: [kernels.len]?std.Build.LazyPath = @splat(null); const fatbin_step = b.step("fatbins", "Build and install the CUDA kernel fatbins alone"); for (kernels, &images) |k, *image| { if (prebuilt) |dir| { image.* = b.graph.cwdRelativePath(b.pathJoin(&.{ dir, b.fmt("{s}.fatbin", .{k.name}) })); } else if (nvcc) |tool| { - image.* = fatbin(b, tool, version.?, catalog.nativeFp(b.allocator, k, opts.native_fp_decode), sms); + image.* = fatbin(b, tool, catalog.nativeFp(b.allocator, k, opts.native_fp_decode), sms); } if (image.*) |file| fatbin_step.dependOn(&b.addInstallFile(file, b.fmt("fatbin/{s}.fatbin", .{k.name})).step); } @@ -82,17 +76,13 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu b.step("check-pdl-loads", "No global read before a dependent launch's wait in the GLM images and qmmf (needs -Dnvcc)").dependOn(&check.step); } // MiniMax H3's kernel image: its library and the contract's runner take it - const h3_image = if (nvcc) |tool| fatbin(b, tool, version orelse blk: { - const run = b.addSystemCommand(&.{ tool, "--version" }); - run.has_side_effects = true; - break :blk run.captureStdOut(.{}); - }, .{ .name = "h3", .flags = &.{"-O3"} }, sms) else null; + const h3_image = if (nvcc) |tool| fatbin(b, tool, .{ .name = "h3", .flags = &.{"-O3"} }, sms) else null; @import("h3_host.zig").library(b, target, optimize, h3_image); // MiniMax-H3-Image's decoder, prompt and modulation kernel images, built to the served flags, for the contract const h3_image_fatbins: [3]?std.Build.LazyPath = if (nvcc) |tool| .{ - fatbin(b, tool, version.?, .{ .name = "h3_image_decoder", .flags = &.{ "-O3", "--fmad=false" }, .min_sm = 80 }, sms), - fatbin(b, tool, version.?, .{ .name = "h3_image_prompt", .flags = &.{"-O3"}, .min_sm = 80 }, sms), - fatbin(b, tool, version.?, .{ .name = "h3_image_modulation", .flags = &.{ "-O3", "--fmad=false" } }, sms), + fatbin(b, tool, .{ .name = "h3_image_decoder", .flags = &.{ "-O3", "--fmad=false" }, .min_sm = 80 }, sms), + fatbin(b, tool, .{ .name = "h3_image_prompt", .flags = &.{"-O3"}, .min_sm = 80 }, sms), + fatbin(b, tool, .{ .name = "h3_image_modulation", .flags = &.{ "-O3", "--fmad=false" } }, sms), } else .{ null, null, null }; const cuda = @import("cuda_runtime.zig").runtimeWithTargets(b, target, optimize, if (nvcc != null or prebuilt != null) &images else &.{}, null, if (nvcc != null and prebuilt == null) sms else ""); const mods = family(b, target, optimize, cuda, draft_ids); @@ -154,10 +144,10 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu _ = startup.getEmittedBin(); b.step("compile-modelopt-startup", "Compile actual native startup with test-only absent GPU images").dependOn(&startup.step); const controls_file = opts.contract_controls; - const controls = if (controls_file) |file| b.graph.cwdRelativePath(file) else if (nvcc) |tool| fatbin(b, tool, version.?, .{ .name = "contract_controls", .src = "contract_controls_set", .flags = &.{"-O3"} }, sms) else null; + const controls = if (controls_file) |file| b.graph.cwdRelativePath(file) else if (nvcc) |tool| fatbin(b, tool, .{ .name = "contract_controls", .src = "contract_controls_set", .flags = &.{"-O3"} }, sms) else null; const contract_images = @import("qwen_contract.zig").images(b, runner_exe, controls, h3_image, h3_image_fatbins, kernels, &images); contract_images.dependOn(fatbin_step); - @import("cuda_contract_deepseek.zig").images(b, runner_exe, contract_images, kernels, &images, prebuilt, nvcc, version, sms, opts.cuobjdump); + @import("cuda_contract_deepseek.zig").images(b, runner_exe, contract_images, kernels, &images, prebuilt, nvcc, sms, opts.cuobjdump); @import("dsv41_serve.zig").install(b, target, optimize, cuda, nvcc != null or prebuilt != null); @import("hy4_cuda.zig").install(b, target, optimize, cuda, mods.core); const server_exe = nativeServer(b, target, optimize, cuda, mods.core, mods.lanes, mods.nemotron, mods.heat, mods.qwen35, mods.qwen_vision, mods.tokenizer, mods.living, build_options, true, strip); diff --git a/zig/build/cuda_contract_deepseek.zig b/zig/build/cuda_contract_deepseek.zig index 612f29bb0da..d4b0e6020ed 100644 --- a/zig/build/cuda_contract_deepseek.zig +++ b/zig/build/cuda_contract_deepseek.zig @@ -1,7 +1,7 @@ //! DeepSeek contract images use the same built artifacts as their named installs. const std = @import("std"); const list = @import("dsv41_units.zig"); -pub fn images(b: *std.Build, runner: *std.Build.Step.Compile, install: *std.Build.Step, kernels: anytype, files: []const ?std.Build.LazyPath, prebuilt: ?[]const u8, nvcc: ?[]const u8, version: ?std.Build.LazyPath, sms: []const u8, cuobjdump: ?[]const u8) void { +pub fn images(b: *std.Build, runner: *std.Build.Step.Compile, install: *std.Build.Step, kernels: anytype, files: []const ?std.Build.LazyPath, prebuilt: ?[]const u8, nvcc: ?[]const u8, sms: []const u8, cuobjdump: ?[]const u8) void { const empty = b.addWriteFiles().add("empty-contract-deepseek.fatbin", ""); for (list.units ++ list.optional) |k| { const common = for (kernels, 0..) |known, i| { @@ -10,7 +10,7 @@ pub fn images(b: *std.Build, runner: *std.Build.Step.Compile, install: *std.Buil const file = if (common) |i| files[i] else if (prebuilt) |dir| b.graph.cwdRelativePath(b.pathJoin(&.{ dir, b.fmt("{s}.fatbin", .{k.name}) })) else if (nvcc) |tool| - @import("cuda.zig").fatbin(b, tool, version.?, k, sms) + @import("cuda.zig").fatbin(b, tool, k, sms) else null; runner.root_module.addAnonymousImport(b.fmt("contract_fatbin_{s}", .{k.name}), .{ .root_source_file = file orelse empty }); diff --git a/zig/build/cuda_fatbin.zig b/zig/build/cuda_fatbin.zig index 054b5502968..74930b171bc 100644 --- a/zig/build/cuda_fatbin.zig +++ b/zig/build/cuda_fatbin.zig @@ -9,7 +9,7 @@ pub const Target = catalog.Target; pub const Profile = catalog.Profile; pub const profile = catalog.profile; -pub fn fatbin(b: *std.Build, nvcc: []const u8, version: std.Build.LazyPath, k: Kernel, sms: []const u8) std.Build.LazyPath { +pub fn fatbin(b: *std.Build, nvcc: []const u8, k: Kernel, sms: []const u8) std.Build.LazyPath { var choices = std.mem.tokenizeScalar(u8, sms, ','); var any = false; while (choices.next()) |sm| { @@ -17,7 +17,9 @@ pub fn fatbin(b: *std.Build, nvcc: []const u8, version: std.Build.LazyPath, k: K } if (!any) return b.addWriteFiles().add(b.fmt("unsupported-{s}.fatbin", .{k.name}), ""); const run = b.addSystemCommand(&.{ nvcc, "-fatbin" }); - run.addFileInput(version); + // nvcc's own bytes key every image, so a new compiler rebuilds them; a side-effect `nvcc --version` capture is + // rewritten each build and missed every image's cache + run.addFileInput(.{ .cwd_relative = nvcc }); run.addArgs(&torch_flags); // CUDA 13's headers with cl.exe need MSVC's conforming preprocessor and M_SQRT2's math define; under a CJK system // code page, C4819 (a header character it cannot represent) buries the real errors in thousands of warnings. diff --git a/zig/build/dsv41_images.zig b/zig/build/dsv41_images.zig index 6ebcc7dd8d3..7d38e9d3e39 100644 --- a/zig/build/dsv41_images.zig +++ b/zig/build/dsv41_images.zig @@ -22,9 +22,8 @@ pub fn images(b: *std.Build, nvcc: ?[]const u8, prebuilt: ?[]const u8) ?*const I path.* = if (std.Io.Dir.cwd().access(b.graph.io, file, .{})) |_| b.graph.cwdRelativePath(file) else |_| null; } } else if (nvcc) |compiler| { - const version = b.addSystemCommand(&.{ compiler, "--version" }).captureStdOut(.{}); - for (list.units, &result.units) |unit, *path| path.* = cuda_build.fatbin(b, compiler, version, unit, "121"); - for (list.optional, &result.optional) |unit, *path| path.* = cuda_build.fatbin(b, compiler, version, unit, "121"); + for (list.units, &result.units) |unit, *path| path.* = cuda_build.fatbin(b, compiler, unit, "121"); + for (list.optional, &result.optional) |unit, *path| path.* = cuda_build.fatbin(b, compiler, unit, "121"); } else { step.dependOn(&b.addFail("fatbins-dsv41 needs -Ddsv41-nvcc=PATH or -Ddsv41-fatbins=DIR").step); return null; diff --git a/zig/build/h3_image_cuda.zig b/zig/build/h3_image_cuda.zig index 6129407dc54..f2efe59124c 100644 --- a/zig/build/h3_image_cuda.zig +++ b/zig/build/h3_image_cuda.zig @@ -3,12 +3,12 @@ const std = @import("std"); pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, opts: @import("options.zig").Cuda, test_step: *std.Build.Step) void { - const image = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, b.addSystemCommand(&.{ nvcc, "--version" }).captureStdOut(.{}), .{ .name = "h3", .flags = &.{"-O3"} }, opts.sms) else b.addWriteFiles().add("h3-compile-only.fatbin", ""); + const image = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, .{ .name = "h3", .flags = &.{"-O3"} }, opts.sms) else b.addWriteFiles().add("h3-compile-only.fatbin", ""); const cuda = @import("cuda.zig").runtime(b, target, optimize, &.{}); const core = @import("h3_host.zig").coreModule(b, target); const h3 = b.createModule(.{ .root_source_file = b.path("zig/src/families/h3/cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "core", .module = core } } }); h3.addAnonymousImport("fatbin_h3", .{ .root_source_file = image }); - const modulation = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, b.addSystemCommand(&.{ nvcc, "--version" }).captureStdOut(.{}), .{ .name = "h3_image_modulation", .flags = &.{ "-O3", "--fmad=false" } }, opts.sms) else b.addWriteFiles().add("h3-modulation-compile-only.fatbin", ""); + const modulation = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, .{ .name = "h3_image_modulation", .flags = &.{ "-O3", "--fmad=false" } }, opts.sms) else b.addWriteFiles().add("h3-modulation-compile-only.fatbin", ""); h3.addAnonymousImport("fatbin_h3_modulation", .{ .root_source_file = modulation }); const exe = b.addExecutable(.{ .name = "tf-h3-image-cuda", .root_module = b.createModule(.{ .root_source_file = b.path("zig/tests/h3_image_cuda.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "h3cuda", .module = h3 }, diff --git a/zig/build/h3_image_decoder_cuda.zig b/zig/build/h3_image_decoder_cuda.zig index 3c59229649a..863c4cdba89 100644 --- a/zig/build/h3_image_decoder_cuda.zig +++ b/zig/build/h3_image_decoder_cuda.zig @@ -3,7 +3,7 @@ const std = @import("std"); pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, opts: @import("options.zig").Cuda, test_step: *std.Build.Step) void { // no FMA contraction: the norms', attention's and SwiGLU's fp32 multiply-adds round as the host reference's do - const image = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, b.addSystemCommand(&.{ nvcc, "--version" }).captureStdOut(.{}), .{ .name = "h3_image_decoder", .flags = &.{ "-O3", "--fmad=false" }, .min_sm = 80 }, opts.sms) else b.addWriteFiles().add("h3-image-decoder-compile-only.fatbin", ""); + const image = if (opts.nvcc) |nvcc| @import("cuda_fatbin.zig").fatbin(b, nvcc, .{ .name = "h3_image_decoder", .flags = &.{ "-O3", "--fmad=false" }, .min_sm = 80 }, opts.sms) else b.addWriteFiles().add("h3-image-decoder-compile-only.fatbin", ""); const cuda = @import("cuda.zig").runtime(b, target, optimize, &.{}); const core = @import("h3_host.zig").coreModule(b, target); const writer = b.createModule(.{ .root_source_file = b.path("zig/src/picture_writer.zig"), .target = target, .optimize = optimize }); diff --git a/zig/build/h3_image_prompt_cuda.zig b/zig/build/h3_image_prompt_cuda.zig index cd4593d26d6..720577fb72b 100644 --- a/zig/build/h3_image_prompt_cuda.zig +++ b/zig/build/h3_image_prompt_cuda.zig @@ -6,7 +6,7 @@ const std = @import("std"); /// selftest against the float64 host reference. pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, opts: @import("options.zig").Cuda, test_step: *std.Build.Step) void { const image = if (opts.nvcc) |nvcc| - @import("cuda_fatbin.zig").fatbin(b, nvcc, b.addSystemCommand(&.{ nvcc, "--version" }).captureStdOut(.{}), .{ .name = "h3_image_prompt", .flags = &.{"-O3"}, .min_sm = 80 }, opts.sms) + @import("cuda_fatbin.zig").fatbin(b, nvcc, .{ .name = "h3_image_prompt", .flags = &.{"-O3"}, .min_sm = 80 }, opts.sms) else b.addWriteFiles().add("h3-image-prompt-compile-only.fatbin", ""); const cuda = @import("cuda.zig").runtime(b, target, optimize, &.{}); diff --git a/zig/build/product.zig b/zig/build/product.zig index a8106df96d4..f11e4aee9aa 100644 --- a/zig/build/product.zig +++ b/zig/build/product.zig @@ -132,18 +132,13 @@ fn cudaServer(b: *std.Build, o: Options, build_options: *std.Build.Step.Options, /// The CUDA server; with neither nvcc nor prebuilt images, every image is an empty file, for a compile-only check. fn cudaProduct(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, nvcc: ?[]const u8, prebuilt: ?[]const u8, build_options: *std.Build.Step.Options, sm: []const u8) *std.Build.Step.Compile { const cuda_build = @import("cuda.zig"); - const version: ?std.Build.LazyPath = if (nvcc) |tool| blk: { - const run = b.addSystemCommand(&.{ tool, "--version" }); - run.has_side_effects = true; - break :blk run.captureStdOut(.{}); - } else null; const target_sm = catalog.Target.parse(sm); var images: [catalog.kernels.len]?std.Build.LazyPath = @splat(null); const check = b.addRunArtifact(b.addExecutable(.{ .name = "check-product-fatbins", .root_module = b.createModule(.{ .root_source_file = b.path("zig/build/check_product_fatbins.zig"), .target = b.graph.host }) })); const empty = b.addWriteFiles(); for (catalog.kernels, &images) |k, *image| { if (nvcc) |tool| { - image.* = @import("cuda_fatbin.zig").fatbin(b, tool, version.?, k, sm); + image.* = @import("cuda_fatbin.zig").fatbin(b, tool, k, sm); } else if (prebuilt == null) { image.* = empty.add(b.fmt("{s}.fatbin", .{k.name}), ""); } else { From 2c9228a88424493e3d67b29d963844816712444f Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:25:43 +0800 Subject: [PATCH 20/23] docs: n1x-run.ps1 builds tf-cuda-test's 37 contract images as their own step and logs zig's output, as run 5's runner stopped twice silently --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 9 +++++--- docs/recipes/inkling-2-mini-cuda/README.md | 22 ++++++++++++++----- docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 22 ++++++++++++------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index a679b4c6b8d..b09c9313966 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -4,11 +4,14 @@ `/wd4819` for nvcc with cl.exe, POSIX file modes and COM `@alignCast` in the server, no `tf-muse` on Windows, and `compile-native-cuda-windows` checking the sm_121 aarch64 product. - `docs/recipes/inkling-2-mini-cuda/n1x-run.ps1` runs Mini on the laptop through `codync@rtx-spark` in steps of under - 10 minutes (nvcc's kernel images, `tf-cuda-test` alone through the new `zig build tf-cuda-test` step, the server, - 188's exactness checks, the reference's planted control, 1/4-stream serving timed by the server's own `done` lines - with the WDDM pool's peak), with no Python, installs or downloads; it queries the N1X by name, as the laptop's + 10 minutes (nvcc's kernel images, the contract images `tf-cuda-test` embeds, `tf-cuda-test` alone through the new + `zig build tf-cuda-test` step, the server, 188's exactness checks, the reference's planted control, 1/4-stream + serving timed by the server's own `done` lines with the WDDM pool's peak), with no Python, installs or downloads; each + build step logs zig's output; it queries the N1X by name, as the laptop's `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 of 32 greedy tokens equal the float64 reference), 32.2 tok/s at one stream and 117.0 total at four, first token 0.104 s, pool peak 23,335 MiB. - `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does; the GB10 and N1X scripts require that exit and the plant's differing tokens, so a load or CUDA failure cannot pass it. The kernel contract says the MLP128 tile is served only on sm_120 instead of blaming the cluster path on sm_121. +- CUDA kernel images are keyed by nvcc's own bytes instead of a side-effect `nvcc --version` capture, which was + rewritten every build and so missed every image's cache: each warm build ran nvcc on all of them again. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 647f960892a..d2fd6f3525d 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -40,10 +40,11 @@ tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one str `codync@rtx-spark`, relayed by the Desk, one step a run. It installs and downloads nothing; the laptop has PowerShell but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_concurrent.py`. -1. `-Step fatbins`, `-Step runner`, then `-Step server`: `zig build fatbins`, `zig build tf-cuda-test`, then `zig - build native`, each `-Dsm=121 -Doptimize=ReleaseFast` with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 - (`vcvarsall arm64`). 189's Windows fixes are on this branch (`__noinline__` in `glm_index_rope.cuh`, `/wd4819`, - POSIX file modes and COM `@alignCast` in the server, no `tf-muse`). Each stops at 9 min; a cut-off step resumes from +1. `-Step fatbins`, `-Step images`, `-Step runner`, then `-Step server`: `zig build fatbins`, `zig build + kernel-contract-fatbins`, `zig build tf-cuda-test`, then `zig build native`, each `-Dsm=121 -Doptimize=ReleaseFast` + with the CUDA 13.5 `windows-arm64` nvcc and `cl.exe` arm64 (`vcvarsall arm64`). 189's Windows fixes are on this + branch (`__noinline__` in `glm_index_rope.cuh`, `/wd4819`, POSIX file modes and COM `@alignCast` in the server, no + `tf-muse`). Each stops at 9 min and prints its log's tail and the images installed; a cut-off step resumes from the zig cache. 2. `-Step check`: 188's GB10 checks unchanged, so the laptop's output is held to the host reference the same way: `kernel-contract "inkling2 loop"`, `inkling2-serving` and `inkling2-mini-ref` (32 greedy tokens equal to the float64 @@ -59,8 +60,9 @@ What differs from the GB10 and is not copied from it: `memory.used` over every device gave an array and stopped run 1's serve step. - A cold build took 647 s (run 1) and 901 s (run 2) in one piece, over a run's 10 minutes, so nvcc's kernel images are their own step; `install` also builds a dozen products this card never runs (run 4 below), so the runner and the - server are a step each. The host float64 reference takes 226 s on the laptop, so the planted control is its own - step: run 2 ran both in one step for 11 min 10 s. + server are a step each, and the 37 images only `tf-cuda-test` embeds (DeepSeek's EXL3 units, the contract's + controls, H3) are a step before the runner (run 5 below). The host float64 reference takes 226 s on the laptop, so + the planted control is its own step: run 2 ran both in one step for 11 min 10 s. - The serve step times replies from the server's log, not the client: run 2's client read the stream line by line and spawned `nvidia-smi` per line, which put it at 6.7 tok/s at one stream while the server decoded at 32.2. - Memory is the WDDM pool the firmware gives CUDA (51,816 MiB on this laptop), not `/proc/meminfo`; admission reads it @@ -80,6 +82,14 @@ Run 4 at `26de8309` (request `407e1d7b`, clean tree): `-Step fatbins` exited 0 i the rest of `install` beside the two binaries the checks and serving run. Cold aarch64-windows ReleaseFast cross-compiles on a Mac took 104 s for `tf-cuda-test` and 129 s for `tensorfold-native`, each on one core. +Run 5 at `2ce7e54c` (request `4fbd4d3b`, clean tree): `-Step fatbins` exited 0 in 122 s with nothing changed since +run 4's, and `-Step runner` stopped at 9 min twice with no output, while `-Step server` exited 0 in 449 s. Every +warm build had run nvcc on every image again: each image's cache key held a side-effect `nvcc --version` capture, +rewritten each build, so no step resumed. Images are now keyed by nvcc's own bytes (a second `fatbins +kernel-contract-fatbins` with a stand-in nvcc makes 0 of its 180 calls), the runner's 37 nvcc-only images are their +own step, and each build step logs zig's output. Serve passed again: ready in 55.2 s, 32.2 tok/s at one stream (first +token 0.098 s), 115.4 total at four, pool peak 23,119 MiB; check and control did not run without `tf-cuda-test`. + ### Receipt: run 2 at `2a37918af`, one capped run Desk request `bb869e9b` on `codync@rtx-spark`, clean clone (`git status --porcelain` empty before and after the build), diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index 430982d291a..348d4b221a1 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -1,9 +1,9 @@ # Inkling 2 Mini (revision ed40e7da62) whole on an RTX Spark N1X laptop, native Windows ARM64, run by its Codync bot: -# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step fatbins|runner|server|check|control|serve +# powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step fatbins|images|runner|server|check|control|serve # From a clean checkout with `vcvarsall arm64` set up and CUDA_PATH naming the windows-arm64 toolkit. Installs, downloads # and deletes nothing outside .\zig-out and $env:TEMP\inkling2-n1x. Each step stops itself inside 10 minutes. param( - [Parameter(Mandatory)][ValidateSet('fatbins', 'runner', 'server', 'check', 'control', 'serve')][string]$Step, + [Parameter(Mandatory)][ValidateSet('fatbins', 'images', 'runner', 'server', 'check', 'control', 'serve')][string]$Step, [string]$Model = 'C:\models\Inkling-2-Mini-ed40e7da62' ) $ErrorActionPreference = 'Stop' @@ -35,17 +35,23 @@ $test = 'zig-out\bin\tf-cuda-test.exe' $server = 'zig-out\native\bin\tensorfold-native.exe' # A cold build ran 15 min in one piece (run 2) and `install native` twice ran past 9 min (run 4), building a dozen -# products this card does not run, so each step builds one thing: nvcc's 147 kernel images, then tf-cuda-test, then -# tensorfold-native. Each stops at 9 min; a step cut off resumes from the cache when it runs again. -$targets = @{ fatbins = 'fatbins'; runner = 'tf-cuda-test'; server = 'native' } +# products this card does not run, so each step builds one thing: nvcc's 143 kernel images, the 37 contract images +# tf-cuda-test embeds (DeepSeek's EXL3 units, controls, H3: run 5's runner step ran nvcc on them and stopped twice), +# then tf-cuda-test, then tensorfold-native. Each stops at 9 min; a step cut off resumes from the cache when it runs +# again, and its log's tail and the images installed so far show how far it got. +$targets = @{ fatbins = 'fatbins'; images = 'kernel-contract-fatbins'; runner = 'tf-cuda-test'; server = 'native' } if ($targets.ContainsKey($Step)) { $argv = @($targets[$Step], '-Dsm=121', "`"-Dnvcc=$env:CUDA_PATH\bin\nvcc.exe`"", '-Doptimize=ReleaseFast') Write-Output "> zig build $argv" $clock = [Diagnostics.Stopwatch]::StartNew() - $zig = Start-Process -FilePath zig -ArgumentList (@('build') + $argv) -PassThru -NoNewWindow + $zig = Start-Process -FilePath zig -ArgumentList (@('build') + $argv) -PassThru -NoNewWindow ` + -RedirectStandardOutput "$out\$Step.out" -RedirectStandardError "$out\$Step.log" $null = $zig.Handle # without a handle taken now, .NET Framework loses the exit code once the process ends - if (-not $zig.WaitForExit(540000)) { - & taskkill /T /F /PID $zig.Id | Out-Null + $done = $zig.WaitForExit(540000) + if (-not $done) { & taskkill /T /F /PID $zig.Id | Out-Null; $zig.WaitForExit() } + Get-Content "$out\$Step.out", "$out\$Step.log" -Tail 30 + Write-Output "zig-out\fatbin: $(@(Get-ChildItem zig-out\fatbin -Filter *.fatbin -ErrorAction SilentlyContinue).Count) images" + if (-not $done) { Write-Output "EXIT=timeout after 9 min: run -Step $Step again to resume from the cache" exit 1 } From ed0a7028e8b6f309cdef0e6fe019389426286f76 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:16:16 +0800 Subject: [PATCH 21/23] docs: Inkling 2 Mini N1X run 6 receipt: all seven steps exit 0, 32.3 tok/s at one stream, 115.8 at four --- ...nkling-2-mini-runs-on-net-s-rtx-spark-l.md | 5 ++-- docs/recipes/inkling-2-mini-cuda/README.md | 30 ++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md index b09c9313966..26a6ed2ff96 100644 --- a/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md +++ b/changelog.d/243-inkling-2-mini-runs-on-net-s-rtx-spark-l.md @@ -8,8 +8,9 @@ `zig build tf-cuda-test` step, the server, 188's exactness checks, the reference's planted control, 1/4-stream serving timed by the server's own `done` lines with the WDDM pool's peak), with no Python, installs or downloads; each build step logs zig's output; it queries the N1X by name, as the laptop's - `nvidia-smi` also lists an NPU. Run 2 on the laptop: every check passes (32 of 32 greedy tokens equal the float64 - reference), 32.2 tok/s at one stream and 117.0 total at four, first token 0.104 s, pool peak 23,335 MiB. + `nvidia-smi` also lists an NPU. Run 6 on the laptop: all seven steps exit 0, every check passes (32 of 32 greedy + tokens equal the float64 reference), 32.3 tok/s at one stream and 115.8 total at four, first token 0.099 s, pool + peak 23,324 MiB. - `tf-cuda-test inkling2-mini-ref` exits non-zero when its planted control differs, as every other failure does; the GB10 and N1X scripts require that exit and the plant's differing tokens, so a load or CUDA failure cannot pass it. The kernel contract says the MLP128 tile is served only on sm_120 instead of blaming the cluster path on sm_121. diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index d2fd6f3525d..53494b13000 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -73,6 +73,9 @@ What differs from the GB10 and is not copied from it: Run 1 at `b2ddc3de` (clean tree): build exit 0; check passed as in run 2; serve was ready in 55.3 s, then the NPU row above stopped the script before any tok/s. +Run 2 at `2a37918a` (request `bb869e9b`, clean tree): one 15-minute `build` and one `check` with the control (11 min +10 s), both exit 0 with run 6's results; serve 32.2 tok/s at one stream, 117.0 total at four, pool peak 23,335 MiB. + Run 3 at `a86ccbd1` (request `39062c42`, clean tree): `-Step fatbins` exited 1 in 20 s with `no such step: fatbins-Dsm=121`, as PowerShell unrolled the one-element target list to a string that `+` then appended to; the script now keeps it an array. @@ -90,23 +93,30 @@ kernel-contract-fatbins` with a stand-in nvcc makes 0 of its 180 calls), the run own step, and each build step logs zig's output. Serve passed again: ready in 55.2 s, 32.2 tok/s at one stream (first token 0.098 s), 115.4 total at four, pool peak 23,119 MiB; check and control did not run without `tf-cuda-test`. -### Receipt: run 2 at `2a37918af`, one capped run +### Receipt: run 6 at `2c9228a8`, one capped run -Desk request `bb869e9b` on `codync@rtx-spark`, clean clone (`git status --porcelain` empty before and after the build), +Desk run on `codync@rtx-spark`, relayed by Capri, 24 Nov 13:56:50-14:27:27, warm folder `tf243-a86c`, clean tree. +`vcvarsall arm64` 0, cl 14.44.35207 HostARM64, nvcc 13.5 V13.5.37, zig 0.17.0; N1X sm_121, 48 SMs, 51,816 MiB, +driver 621.01, power plan Balanced. Each step is `powershell -ExecutionPolicy Bypass -File docs\recipes\inkling-2-mini-cuda\n1x-run.ps1 -Step `. This is one run with these settings, not a benchmark. | Step | Exit | Time | Result | |---|---|---|---| -| `build` | 0 | 15 min 1 s (cold cache) | no error lines | -| `check` (with the control, as it then was) | 0 | 11 min 10 s | `kernel-contract "inkling2 loop"` 5/5 pass gates 1-4, 2/2 controls red; `inkling2-serving` PASS (CUDA equals the host reference token for token, fresh equals resumed, admission); `inkling2-mini-ref` 0 of 32 tokens differ (smallest margin 0.110, 226 s); planted control 6 of 32 differ, exit 1 | -| `serve` | 0 | | ready in 58.4 s: 19.82 GiB model, 4 streams x 0.49 GiB at 8192, 16 GiB prompt cache | +| `fatbins` | 0 | 84 s | 143 images | +| `images` | 0 | 151 s | 180 images | +| `runner` | 0 | 493 s | `tf-cuda-test` | +| `server` | 0 | 347 s | `tensorfold-native` | +| `check` | 0 | | `kernel-contract "inkling2 loop"` 5/5 pass gates 1-4, 2/2 controls red, 0 limit problems (101,376 B shared, 1024 threads; MLP128 sm_120 only); `inkling2-serving` PASS (CUDA equals the host reference token for token, fresh equals resumed, 2 lanes share rounds and a 3rd waits at 17.60 GiB weights); `inkling2-mini-ref` 0 of 32 greedy tokens differ (smallest margin 0.110) | +| `control` | 0 | | planted control 6 of 32 differ (positions 15, 18, 19, 38, 39, 42), its exit non-zero as required | +| `serve` | 0 | | ready in 58.5 s | | Streams | First token | Decode a stream | Total decode | Failed | |---|---|---|---|---| -| 1 | 0.104 s | 32.2 tok/s | 32.2 tok/s | 0 | -| 4 | 0.096-0.357 s | 28.8 / 29.1 / 29.4 / 29.7 tok/s | 117.0 tok/s (3.63x) | 0 | +| 1 | 0.099 s | 32.3 tok/s | 32.3 tok/s | 0 | +| 4 | 0.087-0.356 s | 28.5 / 28.8 / 29.1 / 29.4 tok/s | 115.8 tok/s (3.59x) | 0 | -Times are the server's `done` lines (256 tokens each, `finish=length`). Peak GPU memory: the WDDM pool's largest -sample was 23,335 MiB (run 1 sampled 2.7 GiB before the server). The N1X decoded one stream as fast as GB10 (32.2 -against 32.5 tok/s) and four streams at 117.0 against 117.8. +Times are the server's `done` lines (256 tokens each). Peak GPU memory: the WDDM pool went from 2,714 MiB before the +server to 23,315 MiB after load and peaked at 23,324 MiB; the server's working set peaked at 3,973 MiB. The server +warned that `tfgrammar.dll` is missing (a source build). As deployments, not chips: this laptop decoded one stream at +32.3 tok/s against GB10's 32.5, and four at 115.8 against 117.8. From abc67b2d21d798f8914ac1b8cc13e117cc89b612 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:54:30 +0800 Subject: [PATCH 22/23] docs: bound N1X check, control and serve steps at 9 min like the builds, and drop run-script's redundant background planted run, per review --- docs/recipes/inkling-2-mini-cuda/README.md | 3 ++ docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 | 46 +++++++++++++------ .../recipes/inkling-2-mini-cuda/run-script.sh | 5 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index 04d5748cd26..c6693bcb897 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -64,6 +64,9 @@ but no Python or WSL, so the 1/4-stream client is the script's own, not `bench_c and decode per stream come from the server's own `done` lines, with the ready time, the WDDM pool's peak (`nvidia-smi -lms 500` in its own process) and the server's peak working set. +Steps 2-4 share the builds' 9-minute deadline: each `tf-cuda-test` call, the 240 s server-load wait and each request +is bounded by the step's remaining time, and a killed call prints its log's tail like a build step's. + What differs from the GB10 and is not copied from it: - `nvidia-smi` there also lists an NVIDIA NPU, so the script finds the N1X by name and queries only its index; diff --git a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 index 348d4b221a1..76ccc5bfb06 100644 --- a/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 +++ b/docs/recipes/inkling-2-mini-cuda/n1x-run.ps1 @@ -59,15 +59,35 @@ if ($targets.ContainsKey($Step)) { exit $zig.ExitCode } +# check, control and serve share the same 9-minute deadline the build steps enforce, so a stalled check, reference +# or request cannot run past the step's stated 10-minute bound +$clock = [Diagnostics.Stopwatch]::StartNew() +function Left() { [Math]::Max(1, 540000 - [int]$clock.ElapsedMilliseconds) } +# One tf-cuda-test call under the deadline, its output and error logged like a build step's. -FailOk hands the exit +# code back in $script:last instead of stopping, for the control that must exit non-zero. +function Timed([string[]]$argv, [string]$log, [switch]$FailOk) { + Write-Output "> $test $argv" + $p = Start-Process -FilePath $test -PassThru -NoNewWindow -RedirectStandardOutput "$out\$log.out" ` + -RedirectStandardError "$out\$log.err" ` + -ArgumentList @(($argv | ForEach-Object { if ($_ -match ' ') { "`"$_`"" } else { $_ } })) + $null = $p.Handle # as with the build steps, the handle must be taken for the exit code + $done = $p.WaitForExit((Left)) + if (-not $done) { & taskkill /T /F /PID $p.Id | Out-Null; $p.WaitForExit() } + Get-Content "$out\$log.out", "$out\$log.err" -Tail 30 -ErrorAction SilentlyContinue + $script:last = if ($done) { $p.ExitCode } else { 124 } + Write-Output "EXIT=$script:last$(if (-not $done) { ' (timeout: the step deadline passed)' })" + if ($script:last -and -not $FailOk) { exit $script:last } +} + $text = 'The three laws of thermodynamics, explained for a curious student:' if ($Step -eq 'check') { # 188's GB10 checks as they are: the served kernels, #4387's serving checks, the float64 reference - Run $test @('info') - Run $test @('kernel-contract', 'inkling2 loop') + Timed @('info') 'info' + Timed @('kernel-contract', 'inkling2 loop') 'contract' $r = New-Object System.Random 4387 (1..4200 | ForEach-Object { $r.Next(1000, 199000) }) -join ' ' | Set-Content -Encoding ascii "$out\ids.txt" - Run $test @('inkling2-serving', $Model, "$out\ids.txt") - Run $test @('inkling2-mini-ref', $Model, '32', $text) + Timed @('inkling2-serving', $Model, "$out\ids.txt") 'serving' + Timed @('inkling2-mini-ref', $Model, '32', $text) 'ref' exit 0 } @@ -75,12 +95,10 @@ if ($Step -eq 'check') { # Alone, any non-zero exit (a bad path, no GPU) would pass it, so it also needs the plant's own differing tokens. if ($Step -eq 'control') { $env:INKLING2_REF_PLANT = '1' - $ref = Start-Process -FilePath $test -Wait -PassThru -NoNewWindow -RedirectStandardError "$out\control.log" ` - -ArgumentList @('inkling2-mini-ref', "`"$Model`"", '32', "`"$text`"") - Get-Content "$out\control.log" - Write-Output "planted control EXIT=$($ref.ExitCode) (must be non-zero)" - $planted = Select-String -Path "$out\control.log" -Pattern '\(PLANTED: no messages\): [1-9]\d* of 32 greedy tokens differ' - if (-not $ref.ExitCode -or -not $planted) { exit 1 } + Timed @('inkling2-mini-ref', $Model, '32', $text) 'control' -FailOk + Write-Output "planted control EXIT=$script:last (must be non-zero)" + $planted = Select-String -Path "$out\control.err" -Pattern '\(PLANTED: no messages\): [1-9]\d* of 32 greedy tokens differ' + if (-not $script:last -or -not $planted) { exit 1 } exit 0 } @@ -92,24 +110,24 @@ $proc = Start-Process -FilePath $server -PassThru -NoNewWindow -RedirectStandard -RedirectStandardError "$out\server.err" -ArgumentList @('serve', "`"$Model`"", '--backend', 'cuda', '--host', '127.0.0.1', '--port', $port, '--name', 'inkling-2-mini', '--parallel', '4', '--context', '8192', '--no-update-check') -$loaded = [Diagnostics.Stopwatch]::StartNew() try { while ($true) { try { Invoke-RestMethod "http://127.0.0.1:$port/v1/models" -TimeoutSec 5 | Out-Null; break } catch {} - if ($proc.HasExited -or $loaded.Elapsed.TotalSeconds -gt 240) { throw 'server did not answer /v1/models' } + if ($proc.HasExited -or $clock.Elapsed.TotalSeconds -gt 240) { throw 'server did not answer /v1/models' } Start-Sleep 1 } - Write-Output ("RESULT n1x server ready in {0:N1} s" -f $loaded.Elapsed.TotalSeconds) + Write-Output ("RESULT n1x server ready in {0:N1} s" -f $clock.Elapsed.TotalSeconds) Pool 'server loaded' # nvidia-smi samples the pool every 500 ms in its own process for the whole run; its largest sample is the peak $smi = Start-Process -FilePath nvidia-smi -PassThru -NoNewWindow -RedirectStandardOutput "$out\pool.csv" ` -ArgumentList @('-i', $gpu, '--query-gpu=memory.used', '--format=csv,noheader,nounits', '-lms', '500') Add-Type -AssemblyName System.Net.Http + # a request gets the step's remaining budget (run 6 used under 40 s of it), not a free 4 minutes $http = New-Object System.Net.Http.HttpClient - $http.Timeout = [TimeSpan]::FromMinutes(4) $body = '{"model":"inkling-2-mini","prompt":"Write a short Python function that computes the Fibonacci ' + 'sequence and explain it.","max_tokens":256,"temperature":0,"ignore_eos":true}' foreach ($n in 1, 4) { + $http.Timeout = [TimeSpan]::FromMilliseconds((Left)) $before = @(Select-String -Path "$out\server.log" -Pattern '\] done ').Count $calls = foreach ($i in 1..$n) { $http.PostAsync("http://127.0.0.1:$port/v1/completions", diff --git a/docs/recipes/inkling-2-mini-cuda/run-script.sh b/docs/recipes/inkling-2-mini-cuda/run-script.sh index a63881172f7..311a8245208 100755 --- a/docs/recipes/inkling-2-mini-cuda/run-script.sh +++ b/docs/recipes/inkling-2-mini-cuda/run-script.sh @@ -44,10 +44,7 @@ mkdir -p "$out" python3 -c 'import random; r = random.Random(4387); print(" ".join(str(r.randrange(1000, 199000)) for _ in range(4200)))' >"$out/ids.txt" "$bin/tf-cuda-test" inkling2-serving "$model" "$out/ids.txt" text="The three laws of thermodynamics, explained for a curious student:" -# the float64 reference runs on one host core: its planted control runs beside it, and each must exit 0 -INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" >"$out/planted.log" 2>&1 & -planted=$! -trap 'kill $planted 2>/dev/null || :' EXIT +# the float64 reference must exit 0 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" # the planted control must go red with its own differing tokens: a load or CUDA failure also exits non-zero if INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" 2>"$out/control.log"; then From 1964849d10af8793435846d06d95562bf8be2c64 Mon Sep 17 00:00:00 2001 From: netrunner <299844489+plotarmordev@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:11:36 +0800 Subject: [PATCH 23/23] docs: run-script's one planted control runs beside the float64 reference again: after it, job top-3546b0a66f9b ran out of its 600 s in the 4-stream bench --- docs/recipes/inkling-2-mini-cuda/README.md | 4 ++++ docs/recipes/inkling-2-mini-cuda/run-script.sh | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/recipes/inkling-2-mini-cuda/README.md b/docs/recipes/inkling-2-mini-cuda/README.md index c6693bcb897..f841ee66a10 100644 --- a/docs/recipes/inkling-2-mini-cuda/README.md +++ b/docs/recipes/inkling-2-mini-cuda/README.md @@ -44,6 +44,10 @@ here, gave 5.7 tok/s at one stream and 9.4 at four on the same GB10 (job `top-07 Job `top-9defa53c0bfc` at `2a37918af` reran it with the planted control's new exit: the control's 6 of 32 differing tokens exit non-zero and the script goes on, ending 0 with 33.8 tok/s at one stream and 121.4 at four (3.59x). +Job `top-3546b0a66f9b` at `abc67b2d` ran the planted control after the reference instead of beside it: 0 and 6 of 32 +differed as before (154.9 s and 150.8 s), 32.9 tok/s at one stream, then the 600 s window closed in the 4-stream +bench. The script runs its one planted control beside the reference. + ## RTX Spark (N1X): native Windows ARM64 on Net's laptop `n1x-run.ps1` runs the same checkpoint (`C:\models\Inkling-2-Mini-ed40e7da62`) on the laptop through its Codync bot diff --git a/docs/recipes/inkling-2-mini-cuda/run-script.sh b/docs/recipes/inkling-2-mini-cuda/run-script.sh index 311a8245208..1905b7375cf 100755 --- a/docs/recipes/inkling-2-mini-cuda/run-script.sh +++ b/docs/recipes/inkling-2-mini-cuda/run-script.sh @@ -44,14 +44,18 @@ mkdir -p "$out" python3 -c 'import random; r = random.Random(4387); print(" ".join(str(r.randrange(1000, 199000)) for _ in range(4200)))' >"$out/ids.txt" "$bin/tf-cuda-test" inkling2-serving "$model" "$out/ids.txt" text="The three laws of thermodynamics, explained for a curious student:" -# the float64 reference must exit 0 +# the float64 reference runs on one host core, so its one planted control runs beside it: one after the other left +# the 600 s window in the 4-stream bench (job top-3546b0a66f9b). The reference must exit 0, the control non-zero. +INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" >"$out/control.log" 2>&1 & +planted=$! +trap 'kill $planted 2>/dev/null || :' EXIT "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" -# the planted control must go red with its own differing tokens: a load or CUDA failure also exits non-zero -if INKLING2_REF_PLANT=1 "$bin/tf-cuda-test" inkling2-mini-ref "$model" 32 "$text" 2>"$out/control.log"; then +if wait $planted; then echo "planted control stayed green" >&2 exit 1 fi cat "$out/control.log" >&2 +# a load or CUDA failure also exits non-zero, so the control must show its own differing tokens grep -Eq '\(PLANTED: no messages\): [1-9][0-9]* of 32 greedy tokens differ' "$out/control.log" || { echo "planted control failed before comparing tokens" >&2; exit 1; } mem() { echo "$1: host $(awk '/^MemTotal:/ {t = $2} /^MemAvailable:/ {a = $2} END {printf "used %d MiB, available %d MiB", (t - a) / 1024, a / 1024}' /proc/meminfo); GPU $(nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader | tr '\n' ' ')"; }