[PR #8139] [MERGED] build: qualify updated MLX runtime on Apple Silicon #8124

Closed
opened 2026-10-24 04:10:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8139
Author: @SpicyMarinara
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/mlx-apple-runtime-qualification


📝 Commits (5)

  • bed60fc build: qualify updated Apple MLX runtime candidate
  • 7092d7d fix(sidecar): disable thinking in MLX runtime test
  • 09704d3 fix(sidecar): safely refresh managed MLX environments
  • 89a534e Merge remote-tracking branch 'origin/staging' into codex/mlx-apple-runtime-qualification
  • 2550a30 fix: make MLX lock provenance reproducible

📊 Changes

8 files changed (+399 additions, -115 deletions)

View changed files

📝 packages/server/src/assets/mlx-runtime-requirements.in (+3 -2)
📝 packages/server/src/assets/mlx-runtime-requirements.lock (+132 -89)
📝 packages/server/src/services/sidecar/mlx-runtime.service.ts (+10 -7)
📝 packages/server/src/services/sidecar/runtime-integrity-manifest.ts (+11 -7)
📝 packages/server/src/services/sidecar/sidecar-inference.service.ts (+1 -1)
➕ scripts/regressions/mlx-runtime-upgrade.regression.ts (+142 -0)
📝 scripts/regressions/runtime-integrity.regression.ts (+20 -9)
📝 scripts/regressions/utility-sidecar.regression.ts (+80 -0)

📄 Description

Linked issue

Related to #8079. This is the Apple MLX portion; the issue remains open for the other native runtime qualifications. Owner: @SpicyMarinara.

Why this change

Existing MLX environments could not refresh after a bundle change: uv refused to create a virtual environment at the existing path. The local test could also report an empty response because Gemma spent its fixed 48 tokens on hidden reasoning. Both failures were reproduced before the fixes. Native M4 qualification now also supports updating the Apple runtime bundle.

What changed

  • Reuse an existing MLX environment for exact hash-required upgrades/retries. Preserve the previous approval until source verification succeeds, invalidate it before environment mutation, and approve only after package verification and cancellation checks. Model data and the bundled uv remain intact.
  • Disable thinking in the local smoke request for both backends while preserving its 48-token allowance and visible nonce verification. Keep the llama.cpp-only reasoning parameter on that backend.
  • Update only Apple MLX to MLX/Metal 0.32.4, mlx-lm 0.32.2, Transformers 5.20.2 and the exact compatible dependency lock. Keep all other native bundles and platform admission rules unchanged.
  • Pin the official immutable release sdist, which carries the generated build version. All 208 shipped runtime files and its pyproject match source commit 93e6d4a6447b3080861985947f0820e76fcb957d; only generated version/packaging metadata is additional.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Final head 2550a3027f4fde2f5cf1beb55d5c8a4d02b59264 is integrated with staging 5d64e0f993250189acacfbaf1e270efd57bb40e5. The full native comparison was completed on 89a534e75b93336ccf3f614ee58b488e0d59aa9c; the final lock-comment repair was separately reinstalled and compiled-product tested:

  • Pinned pnpm 12.15.0 frozen/offline install and full pnpm check passed. The existing HomeProfessorMari hook warning remains; no errors.
  • Runtime integrity, actual-installer upgrade and all four sidecar regression files passed (6/6). The installer regression failed the original existing-venv path; current cases cover retry, mid-sync failure, missing metadata, final cancellation and preservation before source-integrity failure. The actual-function smoke regression failed the original MLX nonce contract and passed both backends after the fix.
  • Fresh deep local CodeRabbit review completed on all 8 changed files with 0 findings at 89a534e7. The subsequent three-file lock-comment/hash/regression repair received a separate completed review with 0 findings. Independent source review of the installer also found no actionable issue; that peer review did not run physical tests.
  • Actual Apple M4/24 GiB/macOS 27.0.1 Metal and Engine probes passed with the approved fixed Gemma 4 E2B 4-bit snapshot 238767527555cb75a05732a84dff5d6ba0dd6809. Weight size 3,550,670,554 bytes, SHA-256 038e39a37a7667373d2c3991375446b10c96ae1d717a68674870343db376b76e.
  • On one disposable DATA_DIR, real hash-required installers transitioned approved old → new → approved old → new. Each transition verified exact package versions, stamps and the unchanged model hash, followed by unmodified product-default 48-token nonce completion, streaming, cancellation/recovery, restart and cache reuse. Final compiled-server JavaScript passed the same product probes. Process RSS peaks were approximately 3.7–3.8 GB; no performance improvement is claimed.
  • Actual in-place install cancellation withheld approval and retried successfully. Tampered lock/source and truncated source were rejected before mutation/execution. Engine downloadModel passed against the existing approved cache under Hub 2.2 offline; a separate anonymous real TLS request fetched only the fixed-revision 6,395-byte config with its expected hash through the new httpx2/truststore transport.

The final candidate lock is SHA-256 6bbbfd48fc62edae1132d2e9b5089fe724ff9ab415f575f1de1f9caa12a4071d; actual final install stamps and compiled probes use it. This removes absolute qualification paths using --no-annotate. Two fresh directories seeded from the previous approved lock and the qualified candidate lock generated byte-identical output: all 37 dependency pins and 560 artifact hashes remain unchanged from the 8e4e7f…50049 lock used by the old/new/rollback comparison. The new path regression failed on the original artifact; it and pnpm check passed after the repair. The sdist is 449,827 bytes, SHA-256 1af8a92f6a141c3e2bf5b0369ac4464203a8e2189c47b9e40d3e921e5b3a1fe9.

Proof limits: old-runtime rollback above uses this fixed Engine installer and smoke request; it is not an application downgrade to an unmodified older Engine release, which may still hit uv's existing-venv refusal. Historical 1024-token and separate-environment replays are excluded from final qualification. Only the listed model on M4/macOS 27 was physically exercised; older macOS, other Apple hardware/models, Linux/NVIDIA, native Windows and physical Android remain outside this proof. Advertised wheel/platform floors were not removed.

Manual verification notes

Manually verify Send Test Message in the Local Model settings on Apple Silicon after updating. Browser interaction and other physical devices were not manually exercised here. Hosted CI and Dottore remain merge gates.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

Reviewed README, Android README, CONTRIBUTING, Configuration, Troubleshooting, FAQ and Local Model Setup together. Existing setup, integrity and test-button instructions remain accurate; no new user-facing text or app version/changelog change is included.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8139 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/mlx-apple-runtime-qualification` --- ### 📝 Commits (5) - [`bed60fc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bed60fca3ed346d7898915dd150fe3def4944e8b) build: qualify updated Apple MLX runtime candidate - [`7092d7d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7092d7da11939031e66a41ea1109aac3ce030be5) fix(sidecar): disable thinking in MLX runtime test - [`09704d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/09704d31565f585b6bae46cf88fb90bdb4e24454) fix(sidecar): safely refresh managed MLX environments - [`89a534e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/89a534e75b93336ccf3f614ee58b488e0d59aa9c) Merge remote-tracking branch 'origin/staging' into codex/mlx-apple-runtime-qualification - [`2550a30`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2550a3027f4fde2f5cf1beb55d5c8a4d02b59264) fix: make MLX lock provenance reproducible ### 📊 Changes **8 files changed** (+399 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/assets/mlx-runtime-requirements.in` (+3 -2) 📝 `packages/server/src/assets/mlx-runtime-requirements.lock` (+132 -89) 📝 `packages/server/src/services/sidecar/mlx-runtime.service.ts` (+10 -7) 📝 `packages/server/src/services/sidecar/runtime-integrity-manifest.ts` (+11 -7) 📝 `packages/server/src/services/sidecar/sidecar-inference.service.ts` (+1 -1) ➕ `scripts/regressions/mlx-runtime-upgrade.regression.ts` (+142 -0) 📝 `scripts/regressions/runtime-integrity.regression.ts` (+20 -9) 📝 `scripts/regressions/utility-sidecar.regression.ts` (+80 -0) </details> ### 📄 Description ## Linked issue Related to #8079. This is the Apple MLX portion; the issue remains open for the other native runtime qualifications. Owner: @SpicyMarinara. ## Why this change Existing MLX environments could not refresh after a bundle change: uv refused to create a virtual environment at the existing path. The local test could also report an empty response because Gemma spent its fixed 48 tokens on hidden reasoning. Both failures were reproduced before the fixes. Native M4 qualification now also supports updating the Apple runtime bundle. ## What changed - Reuse an existing MLX environment for exact hash-required upgrades/retries. Preserve the previous approval until source verification succeeds, invalidate it before environment mutation, and approve only after package verification and cancellation checks. Model data and the bundled uv remain intact. - Disable thinking in the local smoke request for both backends while preserving its 48-token allowance and visible nonce verification. Keep the llama.cpp-only reasoning parameter on that backend. - Update only Apple MLX to MLX/Metal **0.32.4**, mlx-lm **0.32.2**, Transformers **5.20.2** and the exact compatible dependency lock. Keep all other native bundles and platform admission rules unchanged. - Pin the official immutable release sdist, which carries the generated build version. All 208 shipped runtime files and its pyproject match source commit `93e6d4a6447b3080861985947f0820e76fcb957d`; only generated version/packaging metadata is additional. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Final head `2550a3027f4fde2f5cf1beb55d5c8a4d02b59264` is integrated with staging `5d64e0f993250189acacfbaf1e270efd57bb40e5`. The full native comparison was completed on `89a534e75b93336ccf3f614ee58b488e0d59aa9c`; the final lock-comment repair was separately reinstalled and compiled-product tested: - Pinned pnpm 12.15.0 frozen/offline install and full `pnpm check` passed. The existing HomeProfessorMari hook warning remains; no errors. - Runtime integrity, actual-installer upgrade and all four sidecar regression files passed (**6/6**). The installer regression failed the original existing-venv path; current cases cover retry, mid-sync failure, missing metadata, final cancellation and preservation before source-integrity failure. The actual-function smoke regression failed the original MLX nonce contract and passed both backends after the fix. - Fresh deep local CodeRabbit review completed on all **8 changed files with 0 findings** at `89a534e7`. The subsequent three-file lock-comment/hash/regression repair received a separate completed review with **0 findings**. Independent source review of the installer also found no actionable issue; that peer review did not run physical tests. - Actual Apple M4/24 GiB/macOS 27.0.1 Metal and Engine probes passed with the approved fixed Gemma 4 E2B 4-bit snapshot `238767527555cb75a05732a84dff5d6ba0dd6809`. Weight size **3,550,670,554 bytes**, SHA-256 `038e39a37a7667373d2c3991375446b10c96ae1d717a68674870343db376b76e`. - On **one disposable DATA_DIR**, real hash-required installers transitioned approved old → new → approved old → new. Each transition verified exact package versions, stamps and the unchanged model hash, followed by unmodified product-default 48-token nonce completion, streaming, cancellation/recovery, restart and cache reuse. Final compiled-server JavaScript passed the same product probes. Process RSS peaks were approximately 3.7–3.8 GB; no performance improvement is claimed. - Actual in-place install cancellation withheld approval and retried successfully. Tampered lock/source and truncated source were rejected before mutation/execution. Engine `downloadModel` passed against the existing approved cache under Hub 2.2 offline; a separate anonymous real TLS request fetched only the fixed-revision 6,395-byte config with its expected hash through the new httpx2/truststore transport. The final candidate lock is SHA-256 `6bbbfd48fc62edae1132d2e9b5089fe724ff9ab415f575f1de1f9caa12a4071d`; actual final install stamps and compiled probes use it. This removes absolute qualification paths using `--no-annotate`. Two fresh directories seeded from the previous approved lock and the qualified candidate lock generated byte-identical output: all **37 dependency pins and 560 artifact hashes** remain unchanged from the `8e4e7f…50049` lock used by the old/new/rollback comparison. The new path regression failed on the original artifact; it and `pnpm check` passed after the repair. The sdist is **449,827 bytes**, SHA-256 `1af8a92f6a141c3e2bf5b0369ac4464203a8e2189c47b9e40d3e921e5b3a1fe9`. **Proof limits:** old-runtime rollback above uses this fixed Engine installer and smoke request; it is not an application downgrade to an unmodified older Engine release, which may still hit uv's existing-venv refusal. Historical 1024-token and separate-environment replays are excluded from final qualification. Only the listed model on M4/macOS 27 was physically exercised; older macOS, other Apple hardware/models, Linux/NVIDIA, native Windows and physical Android remain outside this proof. Advertised wheel/platform floors were not removed. ### Manual verification notes Manually verify **Send Test Message** in the Local Model settings on Apple Silicon after updating. Browser interaction and other physical devices were not manually exercised here. Hosted CI and Dottore remain merge gates. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) Reviewed README, Android README, CONTRIBUTING, Configuration, Troubleshooting, FAQ and Local Model Setup together. Existing setup, integrity and test-button instructions remain accurate; no new user-facing text or app version/changelog change is included. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:35 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8124
No description provided.