Skip to content

Windows: explicit instantiations repeat __restrict__, and GLM's NCCL defaults go through sys.c - #1213

Open
wesley4546 wants to merge 2 commits into
ashhart:mainfrom
wesley4546:windows-build-restrict-setenv
Open

wesley4546 wants to merge 2 commits into
ashhart:mainfrom
wesley4546:windows-build-restrict-setenv

Conversation

@wesley4546

Copy link
Copy Markdown

What this changes

Makes the native Windows build from docs/WINDOWS.md compile and link again, in two commits. Explicit kernel instantiations now repeat their definitions' __restrict__, and GLM's openRank sets its NCCL defaults through sys.c. Fixes #1210.

  • cuda: explicit instantiations repeat their kernels' __restrict__, so nvcc with cl.exe compiles them: 103 instantiations in 20 .cu files, some inside #defines. Only parameter lists change; the lines are rewrapped where they passed 120 columns. exl3_block/x3ld_epi.cu is fixed through its includes.
  • glm cuda: openRank's NCCL defaults go through sys.c, so tensorfold-native links on Windows: env is @import("sys").c on Windows (the _putenv_s wrapper in win_clock.zig) and the existing extern "c" fn setenv elsewhere, the pattern heat.zig and flashnext/cuda_lanes.zig already use.

On Linux the change is a no-op: all 125 release fatbins are byte-identical before and after (below).

Receipt

  • Environment:
    • TensorFold c9fab624 plus these two commits.
    • Windows: Windows 11 x86_64, RTX 5090 (sm_120), driver 610.88, Zig 0.17.0, MSVC 19.44, CUDA 13.0.2 (V13.0.88). 13.4 (V13.4.59) was also checked for the kernel compile.
    • Linux: DGX Spark (GB10), Ubuntu 24.04 aarch64, GCC 13.3, CUDA 13.0 (V13.0.88), Zig 0.17.0.
    • Checkpoint: mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3.
  • Exactness:
    • Linux: zig build fatbins fatbins-dsv41 -Dsm=80,86,120,121 at c9fab624 and at this branch, each in its own worktree and cache. Both give the same 125 fatbins, all byte-identical (cmp), including the 21 built from the changed files.
    • Windows (--context 8192 --no-thinking, greedy, drafts on): for one prose and one code prompt, a repeated request and a "draft": false request return the same text as the drafted one. main can't build on Windows, so there is no before.
  • Decode speed: n/a. The Linux fatbins don't change, and on Windows there is no before to compare.
  • Prompt speed: n/a, for the same reason.
  • Tests run:
    • Windows, zig build test test-kernel-contract test-golden fuzz-cortheon: 283/283 steps, 3290 passed, 0 failed, 62 skipped.
    • Windows, plain zig build: passes.
    • zig fmt --check and git diff --check: clean.
    • tools/zig/lean_check.py: 447 findings on c9fab624 and 447 on this branch, none new.
    • tf-cuda-test on the RTX 5090, all passing:
suite result
info sm_120, 170 SMs, kernels embedded
smoke 7/7
graph 3/3
launch-ex 3/3
ptx 1/1
symbols 1/1
cublaslt 1/1
norms, norm-rows 1/1, 1/1
sample 2/2
glue 1,470/1,470 byte-equal
quant-ref 4/4
affine8 1/1
modelopt 5/5
exlr8 7/7
  • Not run, and why:
    • kernel-contract on sm_120: not run yet. No kernel is added, and the bits don't change on Linux.
    • Metal: I have no Apple hardware, and no Metal code changes.
    • Speed benchmarks: there is no Windows baseline, and Linux is byte-identical.

Checklist

  • 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. (Linux images unchanged; drafted equals "draft": false checked on Windows.)
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No new kernel, and the images don't change. sm_120 not run, see above.)
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new tests; see the note on CI below.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

Notes

…nvcc with cl.exe compiles them

With cl.exe as nvcc's host compiler, an explicit instantiation whose pointer parameters lack the
definition's __restrict__ matches no template ("no instance of function template ... matches the
specified type"). 21 kernel files failed that way on Windows with nvcc 13.0 and 13.4; GCC hosts
accepted them. 103 instantiations in 20 files now name the same parameter types as their definitions.

Refs ashhart#1210
…tive links on Windows

The Windows C runtime has no setenv. The declaration follows heat.zig and flashnext's cuda_lanes.zig:
sys.c (win_clock.zig's _putenv_s wrapper) on Windows, the C library's setenv elsewhere.

Refs ashhart#1210
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: zig build native fails on main (c9fab624): 21 CUDA kernels' explicit instantiations omit __restrict__, and GLM's setenv doesn't link

1 participant