Repository navigation
Stage SSD checkpoint restores without waiting on another prefill (#867) - #1519
Conversation
Bumps libs/mlx-swift-lm to stage provider checkpoint imports with host-materialized destinations, so a restore no longer waits for MLX-Swift's process-wide evalLock while the engine evaluates another request's prefill chunk (Layr-Labs#867). Adds ModelCheckpointRestoreContentionLiveTests, an opt-in real-model regression that serves the same fork restored and cold, idle, during another tenant's prefill and after another tenant's donor, and requires the restore to reach its demanded boundary and never to produce its first token later than cold prefill. Measured on M5 Max 128 GB, Qwen 3.8 27B, 16,667-token fork, 12,288 restored tokens (0.96 GB): contended staging 2.6-3.8 s -> 0.31-0.37 s; contended restore TTFT 27.0-27.5 s -> 26.1-27.1 s, within run-to-run variance (cold 40.4-42.3 s); idle unchanged (6.6 s vs 20.6 s cold). Restored outputs match cold in ModelCheckpointStorageLiveTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@javiech1 is attempting to deploy a commit to the EigenLabs Team on Vercel. A member of the Team first needs to authorize it. |
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. Scan incomplete: 3 file(s) could not be fully read as text. Binary, Git LFS and submodule changes require manual review. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Failure diagnostics: Coverage: 34/47 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 7 reused batch(es), 0 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. |
|
@codex review this |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93c67d5f78
ℹ️ 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 contention regression now fails when a contended restore stages more than 1 s slower than its pair's idle restore; the TTFT bound alone still passed on the build that waited on evalLock (2.6-3.8 s stage vs 0.3 s idle). The report is rewritten atomically after each condition and records the failure, including a teardown error that was previously discarded. Bumps libs/mlx-swift-lm to charge the largest host-zero source as import staging scratch, and documents the staged-import exception in the prefix-cache architecture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo
|
Live rerun on
Contended stage stays within ~60 ms of idle (bound: idle + 1 s; the pre-fix build staged at 2.6–3.8 s). The report was written incrementally (22 samples, no |
# Conflicts: # docs/developer/test.md # docs/reference/ssd-kv-cache.md
Layr-Labs/mlx-swift-lm#316 was squash-merged as c17693f5, whose tree is identical to the reviewed PR head 86c7899e and whose only parent is the previous pin 14661d9b.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27db87d888
ℹ️ 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".
# Conflicts: # docs/architecture/inference.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bd8584f23
ℹ️ 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".
Gajesh2007
left a comment
There was a problem hiding this comment.
Verified: CI green on 5bd8584; SDK pinned to Layr-Labs/mlx-swift-lm@c17693f (merged #316, current main).
…ratch Addresses the second round of review on the restore contention test: - require native live and checkpoint precision, since a lossy checkpoint can legitimately restore slower than recompute; - record the session's runtime identity (makeReport) in the report; - record contract violations and teardown-only failures in the saved report, not just as test issues; - describe the provider-staged host-zero buffer and its scratch charge in hardware-support.md and advance the inference.md freshness stamp.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a627644615
ℹ️ 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".
- Cite the provider-staged host-zero contract by full libs/mlx-swift-lm paths and symbols in ssd-kv-cache.md, prefix-cache.md, inference.md and hardware-support.md. - Create the contention report's parent directory before the first write, as ModelPrefixBenchmarkReport.save does.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2783936b3a
ℹ️ 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".
- Give each condition its own donor and cache scope, so a deeper checkpoint a measured fork donates can never serve a later condition; record a violation if a restore's depth differs from its pair's idle restore. - Record whether the foreign prefill was still running when a contended stage finished, and fail the run when it was not. - Require DARKBLOOM_PREFIX_EXCLUSIVE_GPU=1 like the sibling timing benchmarks, and document it in the invocation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ba5a9e684
ℹ️ 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".
MiMo loads through the native engine, whose native-bound imports keep device allocation and the eval lock, so the staging gate does not apply to it. The test guide now states that the report is rewritten after each measured run.
|
Live rerun on your head
Every restore reached 12,288 tokens; report has 26 samples, |
- libs/mlx-swift-lm: c17693f5 -> 19634dd8 (Nemotron 3.5 Super native VL/MTP/video, GLM-5.3-Flash native) - libs/mlx-swift: 6923a80f -> 67dc7528 (Metal kernel math modes, thread-scoped command-buffer limits, GLM-5.3-Flash native stack) - libs/mlx: cb77239b -> ad4745a2 (matches mlx-swift's nested Cmlx/mlx)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6df3e1d16c
ℹ️ 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".
| - Restoring a complete prefix checkpoint from SSD no longer blocks on MLX's | ||
| process-wide eval lock while the engine runs another request's prefill |
There was a problem hiding this comment.
Qualify the release note to provider-staged restores
For native-bound complete-checkpoint imports such as MiMo, this wording promises a fix that the change explicitly does not provide: the new test rejects mimo_v2 at ModelCheckpointRestoreContentionLiveTests.swift:82-85, and docs/reference/ssd-kv-cache.md:119 says native-bound imports retain device allocation. Qualify the changelog entry as provider-staged so native-bound users are not told that their restore path no longer waits on the eval lock.
Useful? React with 👍 / 👎.
| let foreign = try await timed(fixture, id: requests.next(), pair: pair, role: "foreign_donor", | ||
| tokens: prompts.donor, scope: foreignScope, target: prompts.demandedTokens, cache: true) | ||
| samples = [try await fork(id: requests.next()), foreign] |
There was a problem hiding this comment.
Verify the donor write remains in flight
With a valid small demanded checkpoint or a fast SSD, the asynchronous donation can finish between this donor's terminal and the following fork: timed waits for request completion, but this sequence never observes pending write activity, and the later drain only proves that writes are finished afterward. The sample is still accepted as after_foreign_donor, so the third condition can pass without exercising the promised concurrent-write contention; check a write-in-flight signal (for example the host-write reservation) before starting the fork and fail or record a miss when no overlap occurs.
Useful? React with 👍 / 👎.
Refresh before review. master (#1519) now pins mlx-swift 67dc7528 and MLX ad4745a2; keep those, and pin libs/mlx-swift-lm to the SDK branch's merge of main (f4be1ba1), which carries the GDN kernels on top of the SDK commit master pins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Fixes the remaining cause of #867 on current master and adds a real-model regression so it can't come back.
libs/mlx-swift-lmto Stage provider checkpoint imports without the MLX eval lock mlx-swift-lm#316: provider-staged complete-checkpoint imports create their destinations already available from host bytes, so the SSD stage no longer waits for MLX-Swift's process-wideevalLockwhile the engine evaluates another request's prefill chunk.ModelCheckpointRestoreContentionLiveTests(opt-in): serves the same fork prompt restored and cold, idle, during another tenant's long prefill, and right after another tenant's donor; fails if a restore missesdemandedTokensor produces its first token later than cold under the same condition.developer/test.md(how to run it),reference/ssd-kv-cache.md(destination contract),architecture/inference.md(stage vsevalLock); changelog fragment.The SDK PR is merged: the gitlink points at Layr-Labs/mlx-swift-lm@c17693f (the squash of
86c7899, identical tree, parent = the previous pin14661d9).What #867 looks like today
M5 Max 128 GB, macOS 27.0,
EigenLabs/Qwen3.8-27B-4bit-mtp, paged, native live/checkpoint, masterab423c1c0, isolated ephemeral cache. Fork prompt 16,667 tokens, 12,288 restored tokens (0.96 GB).plan.allocatewaiting forevalLock(≈ one prefill chunk), found with temporary per-phase timers. Moving the allocation to the CPU stream did not help; avoidingeval/synchronizedid.DARKBLOOM_PREFIX_CACHE_SSD_MAX_STAGE_MBcap is reached earlier because the checkpoint carries MTP state; since Default deeper complete-checkpoint SSD restores on large-memory Macs #1520, Macs with ≥ 48 GiB default to 7 GiB). With this change the MTP run passes: contended stage 0.32–0.35 s, restore TTFT 37.4–37.7 s vs 47.0–49.3 s cold; idle 14.0–14.5 s vs 23.8–24.7 s cold.Correctness:
ModelCheckpointStorageLiveTestsnative/native with the bump:coldMatchesRestoredandrepeatedRestoreMatchestrue for 4/4 (shared 15k and 4k cells).Before / After
flowchart LR classDef bad fill:#fde2e2,stroke:#c62828,color:#3b0d0d classDef good fill:#e3f4e8,stroke:#2e7d32,color:#0d2b14 classDef neutral fill:#e3ecfa,stroke:#1565c0,color:#0b2140 subgraph Before B0["request with SSD hit<br/>while another prefill runs"]:::neutral --> B1["stage: allocate destinations<br/>eval + synchronize"]:::bad B1 --> B2["blocked on evalLock<br/>≈2.6 s"]:::bad --> B3["read + decrypt 0.3 s"]:::neutral --> B4["engine.submit"]:::neutral B5["no contention regression test"]:::bad end subgraph After A0["request with SSD hit<br/>while another prefill runs"]:::neutral --> A1["stage: host-materialized<br/>destinations, no lock"]:::good A1 --> A3["read + decrypt 0.3 s"]:::neutral --> A4["engine.submit"]:::neutral A5["ModelCheckpointRestoreContentionLiveTests<br/>restore ≤ cold; stage ≤ idle + 1 s"]:::good endValidation
Spec: one case
donorTokens 16640, sharedTokens 15360, forkTokens 16640, demandedTokens 12288,pairs 2,outputTokens 32,kvBackend paged(MTP run:mtpEnabled true,demandedTokens 8192).Results: live contention test passed on the final code (2 pairs; plus earlier runs before/after the fix as tabled); 37 focused provider SSD/spec tests passed; SDK checkpoint suites passed (see SDK PR); docs-impact, docs-check and changelog check OK. Full
make provider-teston this branch: 4,609 Swift Testing tests across 18 runs plus the XCTest suites (only expected failures, 0 unexpected); one unrelated failure,ModelScannerMemoryFilterTests"strict MiMo scanner propagates a complete native LOAD quote…" (UnwrappingOptional), which this PR cannot affect (it adds only a test file and docs on the provider side and the scanner does not use the changed SDK path).Limitations
donorTokensmust be long enough).c17693f) — see SDK PR.balancedcheckpoints with MTP off restore through CPU row decoding in 166–225 s vs 24.7 s cold.Refactor pass
Separate refactor subagents reviewed both the test (structured
async letfor the foreign request so it is cancelled/joined before fixture close; single exit path;Condition.role(cache:)) and the SDK change (throwingcbv2HostZeros, corrected memory comment). The parent additionally required.lengthand full output per sample viaModelPrefixBenchmarkTerminal.completeSuccessfulRequest. Everything was rebuilt and re-run afterwards.Refs #867, #865.
Need help on this PR? Tag
@codesmith-botwith what you need.