Skip to content

Upstream PR: macOS tests build without Xcode's Metal compiler - #3923

Closed
plotarmordev wants to merge 8 commits into
ashhart:mainfrom
plotarmordev:feat/98-upstream-pr-macos-tests-build-without-xc
Closed

plotarmordev wants to merge 8 commits into
ashhart:mainfrom
plotarmordev:feat/98-upstream-pr-macos-tests-build-without-xc

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

zig build test test-golden now builds and runs on a Mac without Xcode's offline Metal compiler (Command Line Tools only). It warns once with skipping offline Metal shader checks and embeds empty offline metallibs, so the CPU tests run and the Metal device checks still run against them; zig build native and every program that embeds those libraries (drama3-generate, drama3-metal-quant-check, tf-metal-tests, tf-dispatch-bench, tf-kernel-exact, tf-k3-check, tf-k3-serve-check, tf-k3-bench, tf-k3-cluster) stops with install Xcode instead of building a broken binary. The release archive path still compiles the real shaders, and Linux is unchanged — everything is inside metalTargets, which runs only for macOS. Nemotron's packed-metallib checks skip with a one-line reason when no prebuilt library is embedded.

How to check

  • Base: e3fb56cb09061a979cb02080601fc6f7870d3362 (your main; git merge-base of this head and main).
  • Head: 88663a13cb20a08d9fab1a1862888d98e4e77a39. Since 76a0b85f the only new commit moves nativeServer unchanged from zig/build/metal_targets.zig into a new zig/build/metal_server.zig (507 and 122 lines), so the lean checker is clean against the base again.
  • Machine: Apple M5 Ultra (Mac17,15), macOS 27.0 (26A425), Zig 0.17.0, Xcode Metal toolchain present.
  • At 88663a13, on that machine:
    • python3 tools/zig/lean_check.py: 221 problems, the same 221 as on the base; nothing new.
    • zig build test test-golden --summary all: 888/891 steps, 15099/15220 tests passed, 120 skipped, 1 failed. The failure is stage net: an unknown host is refused (zig/src/fabric/stage/net.zig:195), the resolver quirk described below; it fails the same way on the base.
  • The no-Xcode checks below (the shadowed xcrun run and the Command-Line-Tools-only Mac) were run at 76a0b85f; the only change since is the file split above.

Checks on this head

  • Head commit when these checks ran: 76a0b85f3760fb60c956ea6a910644d488d9f83c (the current head 88663a13 adds only the file split; see How to check)
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 222 problems on this head, 221 on the base. The one new finding is zig/build/metal_targets.zig: 624 lines (split past 600) — the file was exactly 600 lines on the base and this change adds 24.
  • Tests run, with the command and pass, fail and skip counts:
    • Run at 76a0b85f: zig build test test-golden, macOS 27 arm64 with the Metal toolchain present: 888/891 steps, 15099/15220 tests passed, 120 skipped, 1 failed — stage net: an unknown host is refused expects AddressUnresolved and gets AddressInUse because this machine's resolver (Tailscale 100.100.100.100) answers no-such-host.invalid with a fake 198.18 address. zig/src/fabric/stage/net.zig is untouched by this branch; this is a resolver quirk, not this change.
    • Run at 76a0b85f: same command with xcrun shadowed so -f metal fails (the Command-Line-Tools-only condition): warns once, zig build native stops with this program embeds compiled Metal shaders: install Xcode, and the suite runs 831/834 steps, 2329/2377 executed tests passed, 47 skipped (the extra skips are the Nemotron packed checks printing no prebuilt nemotron_packed.metallib (built without Xcode's Metal compiler)), same single DNS failure. Most steps reused the earlier run's cache; what re-ran is the graph whose inputs changed.
    • Run at 76a0b85f: the same change, run on a Mac with only the Command Line Tools (macOS 27, M5 Ultra): zig build test test-golden exits 0 with 391/391 steps and 5 skips, each printing its reason; each of the shader-embedding program steps exits 1 with install Xcode.
  • CI: expected green; the local DNS failure above cannot reproduce in CI (no Tailscale resolver answering .invalid).
  • Not run, and why: no GPU run — this is a build-graph change; the shader programs it gates are the GPU entry points, and each was verified to stop at the gate rather than run.

Receipt

This change cannot reach inference — it only decides which metallib the build embeds and which steps refuse to build without the offline compiler — so the inference checklist is n/a.

  • Main against branch: n/a, build-graph only.
  • Boxes it reaches: any macOS box without the Metal toolchain (Command Line Tools only); with the toolchain the graph is identical to main.
  • New switch? None.
  • Environment: macOS 27 arm64, Zig 0.17.0, Xcode with MetalToolchain 32023.922 present (and shadowed xcrun for the no-compiler runs); the Command-Line-Tools-only run was on an M5 Ultra, macOS 27, no Xcode.
  • Paths and platforms the change reaches, which I ran and which I could not: zig/build/metal_targets.zig, zig/build/drama3_metal.zig (both macOS-only in effect — metalTargets returns early off macOS) and zig/src/families/nemotron/kernels.zig test helpers; all exercised by the runs above. Linux and Windows paths are untouched.
  • Exactness: n/a, no inference path.
  • Main against this branch: n/a.
  • Decode speed before and after: n/a.
  • Prompt speed before and after: n/a.
  • Licence of any new weights or drafter: n/a.

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; the Nemotron packed checks now skip with a printed reason exactly when no prebuilt library is embedded — verified 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.

No visible change: nothing this PR changes shows on screen.

How to check

  • Base commit (main): 9e2a9bd7a93d3c6cd333d6db10a1bd05d7478145
  • Head commit: 92347ab6fe62be2f9de3ba5deafec47739a6c940
  • Machine: a Mac Studio M5 Ultra · macOS 27.0 (Command Line Tools only: DEVELOPER_DIR=/Library/Developer/CommandLineTools, no metal compiler) · Zig 0.17.0

Test results:

  • DEVELOPER_DIR=/Library/Developer/CommandLineTools zig build test test-golden at 8e5d8c996481 (older head): 15510 passed, 2 failed, 137 skipped
  • DEVELOPER_DIR=/Library/Developer/CommandLineTools zig build native at 8e5d8c996481 (older head): 12 passed, 1 failed, 0 skipped
  • DEVELOPER_DIR=/Library/Developer/CommandLineTools zig build test test-golden --summary all at 92347ab6fe62: 931 passed, 1 failed, 18 skipped

Failures named (counts in the block above):

  • 92347ab6fe62, test test-golden --summary all, 1 failed: stage net: an unknown host is refused (zig/src/fabric/stage/net.zig:195), the resolver quirk described above; this PR doesn't touch net.zig.
  • 8e5d8c996481, test test-golden, 2 failed: the same stage net test and its parent step.
  • 8e5d8c996481, zig build native, 1 failed: the intended refusal, this program embeds compiled Metal shaders: install Xcode.

Without xcrun's metal the test graph embeds empty offline metallibs and warns once;
the Metal device checks still run. zig build native stops with install Xcode, and the
release archive still compiles its shaders.

(cherry picked from commit 81ea8e3)
metalTargets compiles and installs drama3.metallib once and hands the test graph
the real or empty library, as it does for the others; dist passes the real one.

(cherry picked from commit 141ddc1)
native, drama3-generate, tf-metal-tests, tf-dispatch-bench and tf-kernel-exact embed
the empty metallibs, so each depends on one fail step instead of building broken.
The Nemotron packed checks skip with a reason when no prebuilt metallib is embedded.

(cherry picked from commit 0db612f)
…l compiler

Kimi K3 landed on main after the fork change: without xcrun's metal its tests embed
the empty metallib, and tf-k3-check, tf-k3-serve-check, tf-k3-bench, tf-k3-cluster
and drama3-metal-quant-check stop with install Xcode like the other shader programs.
zig/build/metal_targets.zig passed the lean check's 600 lines; the
tensorfold-native step and its host tests move to
zig/build/metal_server.zig, as cuda.zig owns its own nativeServer.
The function moves unchanged.
@plotarmordev

Copy link
Copy Markdown
Contributor Author

Fixed the zig lean-check failure: my last push pushed zig/build/metal_targets.zig past the 600-line limit. I moved nativeServer (the tensorfold-native step and its host tests) unchanged into a new zig/build/metal_server.zig, the way cuda.zig owns its own server build — metal_targets.zig is back under the limit and the build graph, the native refusal without Xcode's Metal compiler, and zig build test-cli all pass locally.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev. The file split resolves the lean failure cleanly, and the no-Xcode runs read well.

Two small things before it can ride a train:

  • the head no longer applies to today's main as-is: one hunk in zig/build/metal_targets.zig (the import block at the top) rejects on context drift; the other ten hunks and the kernels.zig test helpers apply clean. A trivial rebase, the one you already predict for the Idol PRs.
  • we have not seen CI on the new head yet; the local runs in the description are at the commit before the split. Please push and let the checks run, or post the run.

We were unable to run any macOS build on our side, so the head CI is the deciding check. Nothing else is open.

  • Synthena

…t/98-upstream-pr-macos-tests-build-without-xc
@plotarmordev

Copy link
Copy Markdown
Contributor Author

Thanks — done both. I merged your current main in rather than rebasing (my flow doesn't rebase a pushed branch), so the whole head applies cleanly now: the drifted metal_targets.zig import hunk landed without conflicts. CI is running on the new head 8e5d8c99.

I also re-ran the no-Xcode check on this head, with DEVELOPER_DIR=/Library/Developer/CommandLineTools so xcrun -f metal fails as on a Command-Line-Tools-only Mac: zig build test test-golden warns once (skipping offline Metal shader checks) and runs 852/855 steps, 15511/15649 tests passed, 137 skipped — the single failure is the known stage net: an unknown host is refused resolver quirk on this machine, unrelated to this change. zig build native stops with install Xcode as intended.

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev. The merged head applies cleanly, the file split is within the limit, and the updated no-Xcode results separate the expected native refusal from the test-suite result. The checks on 8e5d8c99 have finished green, so nothing is left: this goes on a landing train now.

  • Synthena

…t/98-upstream-pr-macos-tests-build-without-xc

# Conflicts:
#	zig/build/drama3_metal.zig
@AIFlowML

Copy link
Copy Markdown
Contributor

@plotarmordev @ashhart I checked the Command Line Tools path on a clean export of 92347ab6fe62, Apple M5 Max with Zig 0.17.0. With DEVELOPER_DIR=/Library/Developer/CommandLineTools, xcrun -f metal could not find the compiler, zig build native -Dcpu=apple_m1 exited 1 with the expected install Xcode message, and zig build test test-golden -Dcpu=apple_m1 --summary all warned once about offline Metal checks and ran the suite. Goldens passed. The overall result was 15,782 passed, 141 skipped and one failure.

My one failure was NondeterministicMemoryUsage in the load-prefetch allocation-failure test. I reproduced it on the exact merge base 2f0e12418a with zig build test-load-prefetch-host -Dcpu=apple_m1. The latest receipt also records one failed test. Could you name that test beside the count so reviewers can tell whether it's the earlier DNS failure or something else?

The exact head also test-merged cleanly against current main 5780a037c. The Command Line Tools behavior described here reproduced as intended.

Igor Lessio - AIFLOW LABS

@plotarmordev

Copy link
Copy Markdown
Contributor Author

Thanks @AIFlowML, that's a useful independent check, especially the clean test-merge against 5780a037c. The one failure in my latest receipt (92347ab6fe62, --summary all: 931 passed, 1 failed, 18 skipped) is the DNS test described in the PR, stage net: an unknown host is refused (zig/src/fabric/stage/net.zig:195): my machine's resolver answers .invalid hosts with an address. I've named it beside each failed count in the description. Your NondeterministicMemoryUsage in the load-prefetch allocation-failure test reproduces on the merge base 2f0e12418a as you found, so it's outside this change.

ashhart pushed a commit that referenced this pull request Nov 21, 2026
The Metal native server gets its own build file, Drama's metallib is passed in
and reuses metal_targets.embedded, and the shader, Kimi K3 and Drama quant
programs stop cleanly without Xcode's Metal compiler, so the macOS host tests
build with the Command Line Tools alone. #3923's six commits and its merges
of main, as one commit on today's main.
ashhart pushed a commit that referenced this pull request Nov 21, 2026
The Metal native server gets its own build file, Drama's metallib is passed in
and reuses metal_targets.embedded, and the shader, Kimi K3 and Drama quant
programs stop cleanly without Xcode's Metal compiler, so the macOS host tests
build with the Command Line Tools alone. #3923's six commits and its merges
of main, as one commit on today's main.
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@plotarmordev, thank you: this is on main now. #4218 landed it at 498761d under your name, with its changelog line, so macOS tests build without Xcode's Metal compiler. Closing this one in favour of that landing; it will be in the next release's notes with your handle.

  • Synthena

@ashhart ashhart closed this Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 21, 2026
…al_server.zig

Follows main's 498761d (build: macOS tests build without Xcode's Metal compiler, #3923), which moved
nativeServer from metal_targets.zig to metal_server.zig; #3025's test-gemma4-metal-vtable-host step goes there,
after test-drafter-skip-metal-host as before.
ashhart added a commit that referenced this pull request Nov 23, 2026
…al_server.zig

Follows main's 498761d (build: macOS tests build without Xcode's Metal compiler, #3923), which moved
nativeServer from metal_targets.zig to metal_server.zig; #3025's test-gemma4-metal-vtable-host step goes there,
after test-drafter-skip-metal-host as before.
ashhart added a commit that referenced this pull request Nov 23, 2026
…al_server.zig

Follows main's 498761d (build: macOS tests build without Xcode's Metal compiler, #3923), which moved
nativeServer from metal_targets.zig to metal_server.zig; #3025's test-gemma4-metal-vtable-host step goes there,
after test-drafter-skip-metal-host as before.
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.

3 participants