Skip to content

Fix Windows ARM64 native build: portable noinline and alignCast on DXGI vtable casts - #4991

Merged
ashhart merged 3 commits into
ashhart:mainfrom
niterider804:fix/windows-arm64-native-build
Nov 25, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
niterider804:fix/windows-arm64-native-build

Conversation

@niterider804

Copy link
Copy Markdown
Contributor

What this changes

Before: zig build native -Dsm=121 fails on Windows ARM64 (MSVC host compiler) at two places. After: it builds and the binary runs.

  1. zig/kernels/cuda/glm_index_rope.cuh:12: GCC's __attribute__((noinline)) becomes CUDA's portable __noinline__ (already used in window_rows.cuh and window_split.cuh). nvcc with MSVC rejects the GCC form, so glm_glue.fatbin and glm_index.fatbin fail.
  2. zig/src/server/device/read.zig (win.adapters): the four DXGI vtable casts become @ptrCast(@alignCast(...)). On aarch64-windows a function pointer has alignment 4, and Zig 0.17 rejects @ptrCast from *const anyopaque alone ("@ptrCast increases pointer alignment"). x86_64 needs no extra alignment, which is why the x86_64 CI check passes.

Checks on this head

  • Head commit: fc7c16b5e3 (one commit on ed70f71aa)
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: base 165 problems, head 165 problems, lean_new.py: 0 new (all 165 inherited).
  • Tests run, with the command and pass, fail and skip counts:
    • zig build native -Dsm=121 -Dstrip=true -Dnvcc=<CUDA 13.4>\bin\nvcc.exe on base ed70f71aa: fails, nvcc (glm_glue.fatbin) failure, nvcc (glm_index.fatbin) failure, exit 1.
    • The same command on this head: exit 0 in about 7 min.
    • tensorfold-native --version gives 1.3.4. tensorfold-native device --rescan (exercises the patched DXGI path) gives GPU 0: NVIDIA RTX Spark N1X ... sm_121 (from the driver).
    • zig fmt --check zig/src/server/device/read.zig: pass. git diff --check: pass.
  • CI: pending on this head.
  • Not run, and why:
    • zig build test test-golden: not run on this Windows ARM64 laptop. Neither change touches a host-test path that differs on Linux or macOS. CI covers those.
    • kernel-contract: not run, because the GPU was busy with another long job. I can run it on the N1X if wanted.

Receipt

  • Main against branch: main doesn't build on Windows ARM64, so there's no main-side number on this machine. __noinline__ is CUDA's documented function qualifier for the same no-inline hint; nvcc handles it on every host compiler, and the CUDA kernels already use it (window_rows.cuh, window_split.cuh). I expect no codegen change on Linux, but I haven't checked that there. @alignCast adds only a safety assertion.
  • Boxes it reaches: Windows ARM64 + CUDA (N1X). Any MSVC-host nvcc build of the GLM index and glue kernels.
  • New switch? None.
  • Environment: base ed70f71aa. Zig 0.17.0 (.zig-version), aarch64-windows. CUDA 13.4.92 Windows-on-Arm redist (nvcc V13.4.92). MSVC 14.44 HostARM64/arm64. NVIDIA RTX Spark N1X, sm_121, 128 GB unified. Windows 11 build 28000.
  • Paths and platforms the change reaches, which I ran and which I could not:
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: not run. No GLM checkpoint is on this machine, and the change doesn't alter arithmetic: the inlining hint keeps its meaning, and alignCast is an assertion.
  • Main against this branch, same machine and checkpoint: n/a, main doesn't build on this machine.
  • Decode speed before and after, from tools/bench_openai.py: n/a for the same reason. The v1.3.4 numbers with this patch are in Windows ARM64 (RTX Spark N1X) native build: two compile errors on v1.3.4 (glm_index_rope noinline, read.zig alignCast) #4967.
  • Prompt speed before and after: n/a, no change to prompt processing.
  • Licence of any new weights or drafter: n/a
Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered with the contract, and the kernel each one replaces: no kernel is added or replaced. Only the inline hint on the device helper glm_rope::turn is spelled portably.
  • A planted control for each new kernel, and each one fails as planted: n/a, no new kernel.
  • Each backend's SUMMARY line and exit status: not run (see Not run).
  • Chips I could not run: everything except sm_121.

Checklist

  • The title and description match the head commit, including the receipt and the stack.

  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new tests: this is a build fix. The base build failing and the head build passing are shown above.)

  • Comments and docstrings are one line. No measurements or history in the source.

  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.

  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Not run, see Exactness.)

  • No precision traded for speed. If the bits change, the description says which sums change and why.

  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. (n/a on this machine, see Receipt.)

@AIFlowML

Copy link
Copy Markdown
Contributor

I independently reproduced the Zig half on Apple silicon with Zig 0.17.0. I compiled a tiny exported wrapper around the production read.quick from zig/src/server/device/, passing the real platform module:

zig build-obj -lc -target aarch64-windows-gnu --dep sys \
  -Mroot=zig/src/server/device/dxgi_compile_probe.zig \
  -Msys=zig/src/platform/sys.zig -femit-bin=dxgi.obj

The wrapper body was return (read.quick(std.heap.page_allocator, io.*) catch return 0).ram;, with io: *const std.Io. On current main 4c79cfe346d3c239ff7dfd7aa694df799755bafa, this failed at read.zig:153 with the reported alignment increase from 1 to 4. On fc7c16b5e36b563bf78d4dab8e5232de1d416617 the same command emitted the ARM64 Windows object. The head test-merges cleanly into that main SHA. This isolates the production DXGI compile path. Your native Windows/CUDA build and device probe cover the rest.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @niterider804. The change is limited to the portable noinline spelling and four DXGI alignment assertions. The GLM arithmetic, vtable calls and valid x86_64 path stay unchanged in source. The supplied ARM64 build and device-probe results support the fix. This looks safe to land through the normal checks; it does not establish new GLM numerical qualification.

  • Synthena

@ashhart
ashhart force-pushed the fix/windows-arm64-native-build branch from fc7c16b to 784c162 Compare November 25, 2026 15:14
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

@niterider804, a follow-up from our landing CI: __noinline__ is a CUDA keyword, and glm_index_rope.cuh is also compiled by a host C++ emulator (tools/glm_index_emulate), where that keyword doesn't exist. So test-glm-rev25-host failed to compile.

We pushed one commit to your branch: the emulator's CUDA shim (tools/glm_index_emulate/cuda_runtime.h) now defines __noinline__ as __attribute__((noinline)), as it already does for the other CUDA keywords. Your change itself is unchanged, and this goes back into our landing queue.

  • Synthena

@ashhart
ashhart force-pushed the fix/windows-arm64-native-build branch from 784c162 to 7054bf4 Compare November 25, 2026 21:11
@ashhart
ashhart merged commit 69b1fdf into ashhart:main Nov 25, 2026
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @niterider804. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows ARM64 (RTX Spark N1X) native build: two compile errors on v1.3.4 (glm_index_rope noinline, read.zig alignCast)

3 participants