Repository navigation
ci: prebuilt MLX from GitHub releases, split test legs, commit Cargo.lock - #218
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78973e3e27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6006c6c374
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6006c6c to
74f1b2b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74f1b2bbe2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96673e58ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d033825f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ommit Cargo.lock CI wall time was ~1h40 per main push: a 23 min release build, a 60 min `cargo test` job (23 min of which was recompiling MLX C++ and deps), 12 min of clippy, and 10-26 min of macOS runner queue per job. Prebuilt MLX: crates/mlx-sys/build.rs now links upstream MLX (libmlx.a, mlx.metallib, headers) from a GitHub release asset pinned by sha256 in crates/mlx-sys/mlx-prebuilt.json instead of cmake-building the submodule in every cargo profile and job. The download is shared across profiles, refused when the submodule commit differs from the pin, and falls back to the source build (with the reason) when the digest is empty or the download fails. A digest mismatch panics. `MLX_PREBUILT_EXPORT` produces the artifact; .github/workflows/mlx-prebuilt.yml publishes it as release `mlx-prebuilt-<sha12>` (prerelease, so the desktop updater's "latest" is untouched). The bridge, preambles and paged_attn.metallib stay source-built. packages/core/metallib-select.ts resolves the release sentinel MLX bakes as METAL_PATH and reads the mlx-sys OUT_DIR from the paged_attn.metallib origin the bridge now bakes, so the strict packaging gates keep working for prebuilt addons. CI: TS lint/typecheck/rustfmt move to ubuntu; clippy, `cargo test -p mlx-core --lib` and the integration/other-crate tests become three macOS jobs that no longer wait for the native build (they fetch only the tokenizer files the tests read, not a converted checkpoint or dataset); PR builds use thin LTO; rust-cache gets a per-job shared-key and a lockfile-backed key. Cargo.lock is committed: every run was re-resolving 473 packages, which recompiled ~100 deps on cache hits and kept the rust-cache from refreshing. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Release mlx-prebuilt-e091d678454e was produced by the one-off branch push; mlx-prebuilt.json now carries its sha256 so every CI job and fresh local build links the prebuilt MLX instead of cmake-building the submodule. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… libmlx MLX loads a colocated mlx.metallib before the path baked into libmlx.a. A prebuilt-mode build copied one next to the test binaries; a later source build in the same target dir (e.g. after a submodule bump) left it there, so the fresh libmlx ran against the previous pin's kernels and failed with "Unable to load kernel ..._r_4". Copy it in both modes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
workflow_dispatch only sees workflows that exist on the default branch, so a bump PR could not request its own release. Run on the gitlink/build.rs push from any branch of this repo instead (gated on github.repository: a fork's token cannot write releases here). Releases stay keyed by the mlx commit, so a PR branch and main produce the same tag and the first one wins. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…a OUT_DIR Review follow-ups on the prebuilt-MLX flow: - The release tag is now `mlx-prebuilt-<mlx sha12>-<build key8>`, where the build key hashes the portable cmake defines and crates/mlx-sys/cmake/. A define or include change without a submodule move names a new release; a pin left on the old tag is refused (source build + reason) instead of linking an artifact built from other inputs. The workflow derives the tag from the exported manifest.json after the build, so the immutability gate moves after it. - After unpacking, manifest.json's mlx_commit / triple / release_tag must match the pin: the digest proves the bytes are the release's, not that the release is the right one. - In prebuilt mode build.rs hard-links (or copies) the artifact's mlx.metallib into <OUT_DIR>/lib next to paged_attn.metallib, and metallib-select.ts binds the sentinel to that file. The TS side no longer mirrors the cache-location env rule, which diverged for a relative MLX_PREBUILT_CACHE_DIR or CARGO_TARGET_DIR between cargo (package cwd) and yarn (packages/core). - Concurrent publishers of the same tag no longer clobber each other: the loser re-checks the asset and keeps the winner's bytes; --clobber only runs on an explicit force_reupload. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Published by the workflow for the build-key tag format; the key computed on the runner equals the local one (4610d72d), so the key is machine-independent as intended. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… release When a concurrent run wins the race for the same tag, this run keeps the winner's asset but used to print its own tarball's digest (the archives differ: manifest.json built_at, tar metadata). Pinning that digest makes every consumer download panic on a sha256 mismatch. Emit the snippet after publication from the `.sha256` sidecar read back off the release. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Branch protection can require just `done`; it depends on every CI job and fails only when one of them failed or was cancelled, so skipped legs (model-test on unlabeled PRs) pass through. Same shape as vite-plus's. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
3d03382 to
8f3959a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f3959a1ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- prebuilt_build_key now folds in PREBUILT_BUILD_KEY_REVISION, a hand-bumped constant covering the artifact-shaping logic the key could not hash directly (macOS toolchain selection, -isysroot, export layout). Without it a change there re-ran the workflow but computed the old immutable tag and kept the old asset. - main() emits rerun-if-changed=cmake: the directory feeds the key in every mode, but only the source build tracked (one file of) it, so an edit under cmake/ could leave a restored target on a stale prebuilt. - mlx-prebuilt.yml treats a release as complete only when both the tarball and its .sha256 are present; the snippet step digests the published tarball itself and uploads a missing sidecar instead of failing forever on a half-finished upload. The key moves 4610d72d -> 6d601cad; the push publishes the new release and the pin follows in the next commit. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
An unrelated `labeled` event skips every job, and `done` with a bare `always()` still ran and passed, posting a green required check on the PR head that nothing validated. Gate `done` like the other jobs so that event produces no `done` check run, and fail it when no needed job succeeded. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5a09349fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Same MLX commit, new build key after PREBUILT_BUILD_KEY_REVISION entered the key. Verified: downloaded asset digest equals the release's .sha256 sidecar, and a fresh cache links against it. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af86c255bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…build key The workflow triggers on cmake/**, but the key only read the top level, so a new include under a subdirectory would publish nothing new. Relative paths keep the canonical form for the existing file, so the key does not move. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a2fdfed5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The immutability check ran after the 8-13 min MLX source build, because the
tag's build key came out of that build's manifest. Every push that touches
build.rs on any branch (each PR of a stack, each rebase) therefore paid the
full macOS build to conclude "release already exists".
build.rs derives the tag before it touches cmake; MLX_PREBUILT_PROBE=<file>
makes it write {mlx_commit, build_key, release_tag} there and stop (6 s
locally). The workflow probes, gates, and only then builds; the real build's
manifest must name the probed tag.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6472707ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…219) Stacked on #218 (base branch `ci/faster-build-test`, GitHub stack #220); retarget to `main` once that merges. ## Summary Rebases the fork patch stack onto ml-explore/mlx main `bebd6422f` (56 upstream commits). Also the first real exercise of the prebuilt-MLX bump flow from #218: pushing the gitlink published the release with no manual step, and `crates/mlx-sys/mlx-prebuilt.json` pins `mlx-prebuilt-bcad393045a2-4610d72d`. ``` ml-explore/mlx main bebd6422f (2026-10-14) │ + 4 patches (patch 5 dropped: upstream merged the same fix as 9503cb7e4 / #4623) ▼ mlx-node/mlx bcad39304 fork branch mlx-node/rebase-2026-10-14 (fork main NOT yet moved — step 8) ``` - `mlx_paged_profile.cpp`: `array(Buffer, shape, dtype, Deleter)` → `array(allocator::Data(buffer, deleter), shape, dtype)` (upstream #4634). Every other bridge call site audited; the D=256 SDPA predicate mirror still matches upstream. - `paged_kv_cache_adapter.rs`: upstream #4366 makes the `[1,T,H,D]` transpose + reshape a strided **view**; the raw `write_kv` path assumed a copy and swapped tokens/heads on multi-head sliding restore. Now `deep_copy`s into a row-contiguous buffer (the only caller of the raw path). - `mlx_qwen4_ops.cpp`: upstream #4516 changed `load_vector` to sum activations in float before folding the affine bias (5-bit arm); the affine expert GEMV mirrors MLX's gather_qmv bit for bit and now carries that form (`load_vector_fsum`). The vendored `kquant.h` keeps the older sum on purpose (K-quant goldens must not move). - `affine_mixed_golden_gate` fixtures: 237 `promoted` lines re-captured per `docs/mlx-fork.md` (attribution 494c8a6c9 / #4641, route-back proof old==new off split-K on all 7 routes, f64 reference table in the commit message, `native` lines untouched). - `metallib-select.ts`: `steel_gemm_thin_nax` added to the NAX markers (new in this range). - `docs/mlx-fork.md`: 4 patches, new base, bump step 6 = push the gitlink. ## Gate status on this pin (M5 Max, all captured arches) | gate / test | status | note | | --- | --- | --- | | `segmented_sdpa_golden_gate` | green | — | | `affine_mixed_golden_gate` | green | re-captured (promoted only), see commit 6edf0f6 | | `affine_direct_experts_preserve_promoted_arithmetic_and_tail_rows` | green | fixed, commit 767de22 | | `kquant_golden_gate` 15 cases, gen-17 only | **red, pre-existing** | identical failures on a pristine `origin/main` checkout with the old pin — not this bump; needs its own issue | Not yet done from the bump checklist: step 7 benches (ABBA), step 8 force-push of fork `main` (the rebased stack is on fork branch `mlx-node/rebase-2026-10-14`; the gitlink is reachable from it, so CI clones fine). #### Test plan - [x] patch stack rebases; standalone CMake configure clean at 26.2 (NAX kernels build) - [x] `cargo build --release -p mlx-core` against the new pin; `yarn build:native` gates with the new metallib markers - [x] `restore_sliding_prefix_materializes_multi_head_layout` and `affine_direct_experts_preserve_promoted_arithmetic_and_tail_rows` green locally - [x] golden gates on M5 Max across the arch matrix (table above) - [x] release `mlx-prebuilt-bcad393045a2-4610d72d` published by the workflow; digest pinned and cross-checked against its `.sha256` - [ ] CI green once retargeted to `main` Generated with [Devin](https://devin.ai) --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…rallel pure-TS lane (#221) ## Summary Stacked on #219. Makes the test suite cheaper without dropping the regressions it guards. Research first (per-test timings from CI logs, then code reading), then four scoped commits. ### Where the time went ``` rust-lib 4198 tests 921 s rust-int 96 binaries 1160 s ├─ 1 test int8_verify_routes 336 s ├─ kquant_m8_nax 372 s 3 tests ├─ 4 tests qwen4_exp prefill 147 s ├─ kquant_mode_guards 296 s 12 tests ├─ 2 tests int8 (others) 74 s ├─ kquant_tiled 201 s 11 tests ├─ 5 tests retention_sim 56 s ├─ kquant_affine_tiled 97 s 4 tests └─ 4186 tests ~300 s ├─ kquant_metallib_names 93 s 2 tests ├─ bridge_metallib_names 51 s 4 tests TS (vitest) 3775 tests 220 s └─ 90 binaries ~50 s ``` Root cause: `cargo test` ran at opt-level 0, and the slow tests are f64 CPU reference loops / host-side data generation (the test files themselves say `cargo test --release` in their headers). The MLX C++ side is always Release. ### Commits 1. **`[profile.test] opt-level = 2`** — measured: `int8_verify_routes` 255 s → 34 s, `kquant_m8_nax` 253 s → 30 s; mlx-core compile 3m03s → 4m46s (18 cores). Full `--lib` suite 921 s (CI) → 317 s locally with no test touched. Debug assertions / overflow checks stay on. 2. **K-quant integration trims** — build-every-pipeline tests (`#[ignore]`, now run in the qwen3 model-test leg on main), determinism sweeps 20–24 repeats × full grid → 3 × representative, bulk FFI readback in `kquant_mode_guards`. 3. **Unit-test sweeps** — int8 prefixes chosen from the segmented-SDPA plan boundaries (150 → 50 cases, every route still hit per layout), qwen4_exp prefill parity on a table of distinct mechanisms (70 → 16 combos), `retention_sim` reports behind `#[ignore]`, asserted cells kept. 4. **vitest two lanes** — `pure-ts` parallel, `addon` serial; membership traced from the import graph at config load (`scripts/test-lanes.ts`). TS tests pinned exactly by Rust unit tests removed; `expect(true)` train() tests now assert the batch contract; the flaky `stdReward > 0` test made deterministic (greedy); two never-run paged TS gates wired into the qwen3 model leg. ### Measured locally (M5 Max), after all four ``` before (CI, debug) after (local, opt 2) mlx-core --lib 921 s 90 s (4053 passed, 153 ignored) 6 hot kquant binaries 1109 s 202 s (142 s of it is one CPU-reference test, see below) vp test 220 s 127 s ``` ### Left alone on purpose (product calls) - `kquant_tiled::kquant_modes_take_no_row_tier_past_m8` — 115 s, 45 single-thread CPU reference matmuls at M=40 on Qwen3.8 shapes. Now the single biggest Rust test; shrinking it is a coverage decision. - `kquant_m8_nax::m8_nax_matches_cpu_on_every_mode_and_shape` (31 s) — not a subset of the tiled test (outlier channels, signed sub-scales, production dispatch), kept. - `RUST_TEST_THREADS=1` — load-bearing (global RNG, default device, route counters). - 15 pre-existing K-quant golden failures on `main` — untouched. #### Test plan - [x] `cargo test -p mlx-core --lib` 4053 passed / 0 failed - [x] the 6 touched integration binaries + their `--ignored` pipeline tests pass - [x] `vp test`: only environmental failures locally (gsm8k file, local addon older than `index.cjs`) - [x] fmt / clippy / typecheck / lint / actionlint clean - [ ] CI on this PR (runs once #218 merges and the stack is retargeted) Generated with [Devin](https://devin.ai) --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
CI took ~1h40 per main push (23 min release build, 60 min
cargo testof which 23 min was recompiling MLX C++ + deps, 12 min clippy, 10-26 min macOS queue per job).crates/mlx-sys/build.rslinks upstream MLX (libmlx.a,mlx.metallib, headers) from GitHub releasemlx-prebuilt-<submodule sha12>, sha256-pinned incrates/mlx-sys/mlx-prebuilt.json, downloaded once per machine and shared across cargo profiles. Refused when the submodule commit differs from the pin or is dirty; falls back to the source build (printing why) when the digest is empty or the download fails; a digest mismatch panics.MLX_PREBUILT=0/MLX_PREBUILT_DIR/MLX_PREBUILT_EXPORT/MLX_PREBUILT_CACHE_DIRknobs documented indocs/mlx-fork.md. New workflow.github/workflows/mlx-prebuilt.ymlbuilds + publishes the asset (prerelease, so the desktop updater's "latest" is untouched). The bridge, preambles andpaged_attn.metallibstay source-built.packages/core/metallib-select.tsresolves the release sentinel MLX bakes asMETAL_PATH; strict packaging gates still run for prebuilt addons.--lockedon every direct cargo call; rust-cachev2prefix + per-jobshared-key.cargo test -p mlx-core --lib, and integration/other-crate tests are separate macOS jobs that fetch onlytokenizer{,_config}.json(no non-ignored Rust test reads the converted checkpoint or dataset) and no longer wait for the native build. Test-target coverage verified equal to plaincargo test(97 binaries + doc-tests).lto=thin,codegen-units=16; main/publish keep the fat-LTO profile.Test plan
MLX_PREBUILT_EXPORTsource build → tarball → download (local HTTP + the real release) → sha256 → unpack →cargo build -p mlx-corelinks;cargo test -p mlx-core --lib <filter>finds colocated metallibsMLX_METALLIB_STRICT=1 yarn build:nativepasses all gates with a prebuilt (sentinel-baked) addon; oxnode matmul smoke OKMLX_PREBUILT=0forces sourcecargo metadata --locked,cargo fmt --check,cargo clippy -p mlx-sys --all-targets -D warnings,vp lint --type-aware --type-check(0 errors),yarn typecheck,vp test __test__/core/metallib-select.test.ts(70/70), actionlintmlx-prebuilt-e091d678454epublished by the workflow (MLX build: 8m18s on macos-26)using prebuilt MLXin the cargo logsGenerated with Devin