Skip to content

fetch-metallib: use the metal-cpp archive the Darkbloom sandbox image carries - #1814

Merged
davidtai merged 2 commits into
devfrom
fix/metal-cpp-from-sandbox-payload
Nov 5, 2026
Merged

davidtai merged 2 commits into
devfrom
fix/metal-cpp-from-sandbox-payload

Conversation

@davidtai

@davidtai davidtai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

MLX's CMake configure downloads metal-cpp_26.zip from developer.apple.com with FetchContent, and FetchContent does not try again. On Darkbloom macOS sandbox runners, that download ended early through the egress gateway. It failed shards on 2026-10-30, 2026-11-03 and 2026-11-05 (runs 41957288305 and 41971787801), always with transfer closed with … bytes remaining. See Layr-Labs/darkbloom-sandbox#299.

Layr-Labs/darkbloom-sandbox#301 puts that archive on the macOS sandbox payload disk, pinned by SHA-256 4df3c078…a3a4. This PR makes scripts/fetch-metallib.sh use the archive when it fits:

  • the archive file exists;
  • the nested MLX core (libs/mlx-swift/Source/Cmlx/mlx, 72dffa2d) names that exact archive;
  • its SHA-256 matches the pin;
  • it unzips to metal-cpp/Metal/Metal.hpp.

When all four hold, the script passes -DFETCHCONTENT_SOURCE_DIR_METAL_CPP=<build dir>/metal-cpp-archive/metal-cpp. Otherwise FetchContent downloads the archive as before. MLX_METAL_CPP_ARCHIVE names another local copy, which must have the same digest.

Before

flowchart LR
  A[fetch-metallib.sh: cache miss] --> B[cmake configure MLX]
  B --> C[FetchContent downloads metal-cpp_26.zip from developer.apple.com]
  C -->|transfer ends early| D[configure fails, shard fails]
  C -->|complete| E[build mlx.metallib]
Loading

After

flowchart LR
  A[fetch-metallib.sh: cache miss] --> P{payload archive present, named by this MLX, pinned digest?}
  P -->|yes| U[unzip into build dir] --> B1[cmake -DFETCHCONTENT_SOURCE_DIR_METAL_CPP] --> E[build mlx.metallib]
  P -->|no: GitHub-hosted, Blacksmith, older image, newer MLX| B2[cmake as before: FetchContent downloads] --> E
Loading

Checks

  • bash -n scripts/fetch-metallib.sh passes. The metal_cpp_args array expands with ${arr[@]+"${arr[@]}"}, so it is safe under set -u on macOS /bin/bash 3.2.
  • The consumer recipe is proven on the image side. darkbloom-sandbox's images/macos/tests/ci-compat.sh (provider: fix "stale state file" status when daemon is stopped — or actually running #301) configures MLX's exact FetchContent_Declare(metal_cpp URL …metal-cpp_26.zip) from the unzipped archive with FETCHCONTENT_FULLY_DISCONNECTED=ON.
  • On any runner without the archive, the script runs the same cmake command line as before. This PR's CI runs that path.
  • Docs: docs/developer/build.md (stamp 2026-11-05). Changelog: changelog.d/metal-cpp-from-the-sandbox-image.md.

Known limitations

  • One cold rebuild: the script's own SHA-256 is part of the metallib cache key (helper= in fetch-metallib.sh, HELPER_SHA in provider-release-build). After this merges, every lane rebuilds the metallib once. On Darkbloom runners, each of those rebuilds downloads metal-cpp until the payload disk from provider: fix "stale state file" status when daemon is stopped — or actually running #301 is rolled out. Merge after that rollout, or accept one cold round.
  • Version pin: a new MLX that names another archive (for example _27) falls back to the download until the image and the pin here move together.
  • This PR does not touch scripts/install-release-cmake.sh. It also downloads through the egress (curl: (18) on 2026-10-30 and 2026-11-03), even though the image already has the same CMake on PATH.

Refactor pass

The change is the narrowest one possible: one guarded branch before the existing cmake call, and no change to the cache logic, the lock or verification. I removed nothing.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… carries

MLX's configure downloads metal-cpp_26.zip from developer.apple.com with
FetchContent, which does not try again; through Darkbloom's sandbox egress
the download ended early in macOS jobs (Layr-Labs/darkbloom-sandbox#299).
The macOS sandbox payload disk now carries the archive, pinned by SHA-256
(Layr-Labs/darkbloom-sandbox#301). When it is the archive the nested MLX
core names and its digest matches, the script unzips it into the build
directory and passes -DFETCHCONTENT_SOURCE_DIR_METAL_CPP; anywhere else,
FetchContent downloads it as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Nov 5, 2026 12:26pm UTC
d-inference-console-ui-dev Error Error Nov 5, 2026 12:26pm UTC
d-inference-landing Ready Ready Preview Nov 5, 2026 12:26pm UTC
darkbloom-status Ready Ready Preview Nov 5, 2026 12:26pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 5, 2026 12:26pm UTC

Request Review

…build still fetches MLX's GitHub dependencies

Review: a local copy named by MLX_METAL_CPP_ARCHIVE was used only when its
file name was metal-cpp_26.zip, because the check grepped MLX's CMakeLists
for the copy's basename. It now looks for the fixed name, so any copy with
the pinned digest works. build.md said the build makes no download; MLX's
configure still fetches json, fmt and gguflib from GitHub: it makes no
download from developer.apple.com.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-landing — 96d13d0a Deployed Nov 5, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 96d13d0a Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 96d13d0a Deployed Nov 5, 2026 by vercel[bot]
Preview – darkbloom-status — 96d13d0a Deployed Nov 5, 2026 by vercel[bot]
Preview – d-inference — 96d13d0a Deployed Nov 5, 2026 by vercel[bot]
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.

1 participant