Skip to content

CI (dev): build each lane once on a large Mac, test on small ones - #1817

Merged
davidtai merged 8 commits into
devfrom
ci/build-once
Nov 5, 2026
Merged

davidtai merged 8 commits into
devfrom
ci/build-once

Conversation

@davidtai

@davidtai davidtai commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Goal

David, 2026-11-05: "we need smaller sizes while preserving CI time". Ruling: build once on a big machine, ship the test products to small machines, keep CI on dev pull requests and pushes. This is Plan B of the VM sizing analysis, plus its Phase 0 sampler.

What changes

  • Build once. build-cluster and build-provider build each lane once on blacksmith-12vcpu-macos-27 and upload the debug products (scripts/ci-test-products.py through .github/actions/provider-ci-products). Each test job needs: the build job of its lane, downloads the products with the matched mlx.metallib and resource bundles, and runs the existing --skip-build commands. No test job compiles a package.
  • Why two build jobs, not one. GitHub starts a job only when every job it needs: is done. With one build job, the cluster tests would wait for the provider build and the release compiles (warm about 19.7 min critical path, cold about 30 min). With the cluster lane in its own job, the cluster tests start when the cluster products are up.
  • Cluster Release Build Checks (cluster-release-checks) runs the capability and prefill release compiles (--jobs 12) on Blacksmith, in a job that no test job waits for. Its failure skips no test job. The gate requires it. It saves the metadata build cache on push, as before.
  • Refresh build caches is gone. A push whose tree a pull request run already tested runs the build jobs of the components it changed, without an upload; they save the caches as before.
  • Fixed path. SwiftPM products hold absolute paths (#filePath, resource bundle paths, local package paths in workspace-state.json). Blacksmith checks out to /Users/runner/_work/d-inference/d-inference, Darkbloom to /Users/runner/actions-runner/_work/d-inference/d-inference. The first step of every job that builds or runs products replaces the workspace with a link to /private/tmp/dinf. Every later step starts in the workspace; the kernel resolves the link, so getcwd, SwiftPM, the compiler, Python and the tests see only /private/tmp/dinf. No step, composite action or cache path changes. The Swift build cache keys bind the resolved checkout (provider-ci-cache.py), so the first runs on this branch build cold.
  • What the archive holds. The lane's .build without the compile intermediates (<Target>.build, ModuleCache, index, Modules): test bundles, executables, resource bundles, the staged metallib, checkouts, repositories and workspace-state.json. tar plus zstd, uploaded with compression-level: 0, kept 1 day. The test job refuses products of another commit or of another Swift, Xcode or SDK version, warns when only the builds of those versions differ, and never unpacks over a build.
  • Splits.
    • Cluster runtime base (968 s, serial) splits by model family. The Gemma 4 suites (GEMMA_SUITES, 592 of 970 s in job 127128309712) run alone on new shard 3 as base-gemma. The rest stays in base on shard 1, before the share probe. Each family still shares one process. audit fails when a Gemma suite is missing from GEMMA_SUITES.
    • Cluster Focused Checks has 2 shards: shard 1 runs the plan's runner scripts (528 s); shard 2 runs the stage metadata, GPT-OSS, Nemotron, provisioning and onboarding runners (468 s).
    • Provider shard weights are measured again from run 42029278469 (provider-test-shards.py weights): 80 suites were missing, so selection 6/6 took them all (245 s against 65 s). The last shard's audit now warns (report-only) about unweighted serial suites.
  • Routing. Only the 7 blocking test jobs ask Darkbloom: test-cluster-1..3, test-cluster-focused (2 jobs on the lane the approval names), test-provider-1..2, critical path first. They fit the per-run cap of 8. The build jobs, Cluster Release Build Checks and Cluster GPU Tests (18.5 to 24.7 GiB peaks) use blacksmith-12vcpu-macos-27 directly. The size label plumbing was dropped, as ruled. darkbloom-route.yml is unchanged.
  • Phase 0 sampler (report-only). Every macOS job runs scripts/ci-resource-sampler.py: every 5 s it records memory in use (active, wired and compressed pages from vm_stat), the memory pressure level, busy vCPUs and the largest process (ps). It prints the peaks to the log and the step summary, and uploads resource-samples-<job>-<index>. Its steps cannot fail a job: the report ends in || true and the upload is the only continue-on-error step. The hand-off prints the archive size and the upload and download times.

Every test selection, guard and pin is kept: the lock-retry guard, the share probe alone after base on its shard, the parity counts, the plan audits, the native gates, coverage, and the Provider Tests truth table, which now has the release checks as a fourth lane.

Before / after

Before is measured: runs 41992571131 (warm) and 42025284502 (cold), all on Blacksmith 12 vCPU. After is measured on this PR's green run 42041608780, which built cold (the cache keys now bind /private/tmp/dinf, and a pull request saves no cache). In that run, 5 test lanes ran on Darkbloom 12 vCPU / 32 GiB sandboxes (the approval is not yet re-pinned to 4 vCPU / 16 GiB), and the 2 focused lanes fell back to Blacksmith (lane_not_enabled: the approval does not name test-cluster-focused-1 and -2 yet). Warm rows for "after" are the measured jobs minus the measured cold compile and metallib steps, plus the warm compile times of run 41992571131. Rows at 4 vCPU count the 7 test lanes at the approved size and the build-stage and GPU jobs at 12 vCPU.

State Layout macOS jobs per run vCPU-min per run Gating critical path (min)
warm before 7 1,110 19.15
warm after, test lanes at 4 vCPU (estimate) 12 about 668 about 19.2 on Darkbloom hosts, about 16.8 on Blacksmith hosts
cold before 7 1,358 23.52
cold after, as run (every VM 12 vCPU) 12 1,402 22.3
cold after, test lanes at 4 vCPU 12 824 22.3

The gating critical path is Build cluster test products (4.48 min cold), the job start (0.62 min) and Cluster Runtime Tests shard 2 (17.22 min on Darkbloom; 14.85 min with its build on Blacksmith before). Darkbloom's host is slower than Blacksmith's for that serial shard, as the sizing analysis expected; splitting shard 2's two groups would shorten it at the cost of one more lane.

Per job, run 42041608780

Job Runner Minutes Peak memory in use (GiB) Largest process RSS (GiB) Busy vCPUs mean / p95 / max
Build cluster test products Blacksmith 12 / 48 4.48 13.98 6.31 (air-lld) 4.13 / 11.82 / 11.91
Build provider test products Blacksmith 12 / 48 7.45 18.75 6.33 (air-lld) 5.71 / 11.84 / 11.93
Cluster Release Build Checks Blacksmith 12 / 48 7.33 11.33 4.03 (swift-frontend) 2.80 / 11.45 / 12.02
Provider Unit Tests 1 Darkbloom 12 / 32 9.03 16.85 14.96 (swiftpm-testing-helper) 1.32 / 3.41 / 5.26
Provider Unit Tests 2 Darkbloom 12 / 32 9.45 15.37 2.14 1.28 / 4.33 / 7.35
Cluster Runtime Tests 1 Darkbloom 12 / 32 7.45 13.21 1.22 1.58 / 4.34 / 5.81
Cluster Runtime Tests 2 Darkbloom 12 / 32 17.22 21.54 0.96 1.75 / 3.29 / 4.95
Cluster Runtime Tests 3 (Gemma 4) Darkbloom 12 / 32 11.43 16.75 0.87 1.36 / 3.11 / 4.73
Cluster Focused Checks 1 Blacksmith 12 / 48 (fallback) 9.53 9.12 0.69 0.65 / 1.81 / 5.31
Cluster Focused Checks 2 Blacksmith 12 / 48 (fallback) 8.12 9.22 0.33 0.44 / 1.40 / 1.99
Cluster GPU Tests 1 Blacksmith 12 / 48 16.70 16.74 1.53 0.96 / 1.23 / 4.36
Cluster GPU Tests 2 Blacksmith 12 / 48 8.62 32.80 0.65 1.02 / 2.29 / 5.69

"Memory in use" is active, wired and compressed pages, file cache included; the pressure level stayed 1 (normal) in every job.

Products Compressed Pack Upload Download (Darkbloom) Download (Blacksmith) Extract
cluster 515.3 MiB 1.8 s 10.3 s 39.0 to 60.8 s 82.1 to 88.8 s 3.3 to 3.7 s
provider 1,060.6 MiB 3.0 s 16.1 s 76.9 to 106.7 s - 5.1 to 7.3 s

Findings for the sizing decision:

  • The test phases need few cores: busy vCPUs p95 is 1.4 to 4.3 in every test job.
  • Provider shard 1 has one test process at 14.96 GiB RSS, and Cluster Runtime Tests 2 reaches 21.54 GiB in use. Both are above 16 GiB; at the approved 4 vCPU / 16 GiB they may page or fail. This needs a check before the approval moves to 16 GiB.
  • Provider selection 6/6 now takes 112 s (245 s before); the two provider shards end within 0.4 min of each other.
  • The Darkbloom image has the release build of Xcode 27.2 (27B52, Swift 6.4.2.1.9, SDK 26B118); the Blacksmith image has a pre-release build (27B5038j, Swift 6.4.2.1.4, SDK 26B5110a). The versions match, so the test jobs run the products and warn.

Hooked up

  • build-cluster, build-provider: .github/workflows/provider-tests.yml; each runs provider-ci-build, then provider-ci-products (direction: upload) when its component's tests run.
  • test-provider needs: build-provider; test-cluster and test-cluster-gpu needs: build-cluster; each downloads with provider-ci-products (direction: download, step id test-products), and every test step's condition reads steps.test-products.outcome.
  • test-cluster-focused: both shards read lane test-cluster-focused, requested for 2 jobs in provider-plan.yml.
  • cluster-release-checks: in the gate's needs and its CLUSTER_RELEASE_RESULT check.
  • Fixed-path step: first step of build-cluster, build-provider, test-provider, test-cluster, test-cluster-gpu.
  • base-gemma: scripts/cluster-test-plan.py SELECTIONS (blocking shard 3), test-cluster matrix [1, 2, 3], route lane test-cluster-3.
  • Focused shards: matrix [1, 2], route lanes test-cluster-focused-1, -2.
  • Weights: scripts/provider-test-shard-weights.json (read by provider-test-shards.py args and audit-job); the unweighted-suite warning runs in audit-job of the last shard.
  • Sampler: start step after checkout and report/upload as the last two steps of all 7 macOS jobs.
  • Self-tests in the gate's Check the CI plans: test-ci-test-products.py, test-ci-resource-sampler.py (new), with the updated test-provider-ci-workflow.py, test-cluster-test-plan.py, test-provider-test-shards.py, test-ci-component-paths.py, test-darkbloom-route.py.
  • Classifier: the new action and scripts are provider and cluster inputs (ci-component-paths.py); docs-impact maps them to build.md and test.md.
  • Docs: docs/developer/build.md (Build Once, routing, caching), docs/developer/test.md; changelog changelog.d/ci-build-once.md.

Diagrams

Before:

flowchart LR
  P[plan + route] --> T1["Provider 1-2<br/>build + test"]
  P --> C1["Cluster runtime 1-2<br/>build + test"]
  P --> G1["Cluster GPU 1-2<br/>build + test"]
  P --> F["Focused<br/>release compile + runners"]
  T1 & C1 & F --> Gate[Provider Tests]
Loading

After:

flowchart LR
  P[plan + route] --> BC["build-cluster<br/>(Blacksmith 12 vCPU)"]
  P --> BP["build-provider<br/>(Blacksmith 12 vCPU)"]
  P --> R["cluster-release-checks<br/>(Blacksmith 12 vCPU)"]
  P --> F["Focused 1-2<br/>(routed)"]
  BC -- cluster products --> C["Cluster runtime 1-3<br/>(routed)"]
  BC -- cluster products --> G["Cluster GPU 1-2<br/>(Blacksmith)"]
  BP -- provider products --> T["Provider 1-2<br/>(routed)"]
  T & C & F & R --> Gate[Provider Tests]
Loading

Validation

  • No build or test ran on a laptop. The Python self-tests run in this PR's gate.
  • Run 42041608780 is green: every test job ran the build jobs' products with --skip-build at /private/tmp/dinf, on Darkbloom (5 lanes) and on Blacksmith. The GPU shards failed exactly the 6 selections they fail on dev (runs 41992571131 and 42029278469), so the handed-off products behave as the products built in place.
  • Static checks before push: YAML parse of the edited workflows and action; Python syntax of every edited script; cited doc paths exist.
  • Focused lanes: the approval lists the lane names of the earlier layout (test-cluster-1 to -3, test-cluster-focused), so test-cluster-3 routed and test-cluster-focused-1, -2 fell back (lane_not_enabled). Both focused shards now read the approved lane test-cluster-focused, requested with count: 2 (a lane is granted whole for its count). No approval change.
  • The first focused run on a Darkbloom VM (run 42046597342) failed OwnerWriterWakeTests: "Renewal interval drifted: 5016.940 ms". The writer waits on a semaphore until the renewal is due and schedules the next from its send time, so each interval is 5 s plus one timer wake latency; the test allowed a fixed 15 ms (Blacksmith's latency). The test now measures this host's wake latency during the same window (same primitive, user-interactive priority) and allows that worst wake plus 5 ms, at least 15 ms and below the 50 ms idle bound, so a writer that rests a whole idle wait still fails. On Darkbloom: worst wake 20.0 ms in 346 waits, interval 5008.3 ms.
  • Run 42051112088 is green with all 7 test jobs on Darkbloom (6 lanes). Cluster Runtime Tests shard 2 took 24.7 min there because the existing lock-retry guard ran base-batch-session twice (SwiftPM build database locked on attempt 1, every test passed).
  • Limits: the Darkbloom lanes ran at 12 vCPU / 32 GiB; the 4 vCPU / 16 GiB shape is not yet measured.
  • The focused runners still compile their own small source closures with swiftc; they are the checks themselves, so they stay in the test jobs.
  • Refactor pass: not run by a separate subagent in this session (no delegation tool here); owned by the coordinating parent.

🤖 Generated with Claude Code

- Build cluster test products and Build provider test products build each
  lane once on blacksmith-12vcpu-macos-27 and upload the debug products
  (scripts/ci-test-products.py, .github/actions/provider-ci-products). The
  test jobs need their lane's build job, download its products and run them
  with swift test --skip-build; they compile no package and refuse products
  of another commit or toolchain.
- The jobs of the products work at one fixed path, /private/tmp/dinf: their
  first step links the workspace to it, because SwiftPM's products hold
  absolute paths and Blacksmith and Darkbloom check out to different paths.
- Cluster Release Build Checks runs the capability and prefill release
  compiles on a large Mac, in a job no test job waits for; the gate requires
  it. Refresh build caches is gone: the build jobs refresh the caches of a
  tested push.
- Cluster Runtime Tests: 3 shards; the Gemma 4 base suites run alone on
  shard 3. Cluster Focused Checks: 2 shards. Provider shard weights measured
  again from run 42029278469; the last shard's audit warns about unweighted
  suites.
- Only the 7 blocking test lanes ask Darkbloom; the build jobs, the release
  build checks and Cluster GPU Tests stay on Blacksmith.
- Every macOS job samples memory and CPU (scripts/ci-resource-sampler.py,
  report-only) and prints the peaks; the hand-off prints archive sizes and
  transfer times.

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 5:28pm UTC
d-inference-console-ui-dev Error Error Nov 5, 2026 5:28pm UTC
d-inference-landing Ready Ready Preview Nov 5, 2026 5:28pm UTC
darkbloom-status Ready Ready Preview Nov 5, 2026 5:28pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 5, 2026 5:28pm UTC

Request Review

The Target line names the host's macOS version, which differs between
runner images without changing the products.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run 42037827790: the Blacksmith image builds with Xcode 27.2 build
27B5038j (Swift 6.4.2.1.4, SDK 26B5110a); the Darkbloom image has the
release build 27B52 (Swift 6.4.2.1.9, SDK 26B118). The versions are
equal, so the test job runs the products and warns; another Swift, Xcode
or SDK version or another commit still fails the job.

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

The approval lists the lane names of the earlier layout (test-cluster-1
to -3, test-cluster-focused), so test-cluster-3 routed and
test-cluster-focused-1 and -2 fell back as lane_not_enabled. A route
request may ask for several jobs on one lane (count, granted whole), so
both shards now read test-cluster-focused, requested for 2 jobs. No
approval change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run 42046597342 ran Cluster Focused Checks on a Darkbloom VM for the
first time; OwnerWriterWakeTests failed with "Renewal interval drifted:
5016.940 ms". The writer waits on a semaphore until the renewal is due
and schedules the next one from its send time, so each interval is 5 s
plus one timer wake latency; the test allowed a fixed 15 ms, which is
Blacksmith's latency, not the writer's. A probe now measures, during the
same window, how late this host wakes a thread waiting on a semaphore at
the writer's priority; a renewal may be late by that worst wake plus
5 ms, at least 15 ms, and the allowance must stay below the 50 ms idle
bound, so a writer that rested a whole idle wait is still told apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ci-test-products.py: one helper each for the commit lookup, the MiB
  size text and the upload or download clock; `uploaded` gets its own
  function like the other subcommands; `stream` precedes its callers.
  Output text, manifest and checks are unchanged.
- provider-tests.yml: keep the fixed-path explanation once, in
  build-cluster, and point to it from the other four jobs; Prompt Parity
  now runs against the downloaded provider products, not the shard's
  own build, so its comment says so.
- ci-resource-sampler.py: list the internal `run` subcommand in the
  docstring.

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

This comment has been minimized.

Run 42057277814: Cluster Runtime Tests shard 2 failed on both attempts
with every test passed; SwiftPM printed `error: error: accessing build
database "...build.db": database is locked`, without the `unable to
attach DB:` prefix the guard matched, so it did not run the selection
again. LOCKED now matches either wording. The rule is unchanged: run once
more only when attempt 1 shows the lock and every test passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ard 2's groups

- actions/cache stores each path relative to the workspace and unpacks
  it with `tar -C <workspace>`. In the jobs whose workspace links to
  /private/tmp/dinf, the metallib cache (runner.temp) unpacked to
  /private/_temp and failed ("Cannot mkdir"), and SwiftPM's repositories
  (home) unpacked under /Library, where SwiftPM never reads. The metallib,
  MiMo metadata and codec caches and SwiftPM's repositories now live in
  /private/tmp/dinf-ci, whose only common ancestor with a workspace is
  `/`; ~/Library/Caches/org.swift.swiftpm/repositories links there.
  Restores and push saves use the same paths. A self-test refuses a
  runner.temp, home or expression cache path in those jobs.
- Cluster runtime shard 2 found SwiftPM's build database locked at its
  two groups' startup in every run (runs 42041608780 to 42065297991).
  Each later group now starts CLUSTER_TEST_START_GAP seconds (default 15)
  after the one before, as the provider shards' processes do; the
  lock-retry guard stays the backstop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidtai
davidtai merged commit 25d1ad3 into dev Nov 5, 2026
20 of 22 checks passed
@davidtai
davidtai deleted the ci/build-once branch November 5, 2026 17:50

This branch had an error being deployed

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