Repository navigation
cluster: drop the model's file cache before a part starts and before a load reads it (MiMo on 128 GB Macs) - #1768
Merged
Conversation
…the file cache Checks that go red on dev (0f99ddb): - ClusterServicePartStartCacheTests: the actual service loop starts the follower's part with its model folder (a 64 MiB weight file and a 32 MiB file in audio_tokenizer/) read into the file cache. At beforePartStart both must be under 10 % resident, and their bytes unchanged. On dev both are 100 % resident: the part-start prefetch keeps them cached. - ClusterModelProvisioningChecks: dropCachedPages drops regular files one folder down too, never through a link, nothing deeper. The prefetch checks go with the prefetch. - CheckpointPayloadCacheCheck, run by CheckpointChecks/run.sh and by CheckpointPayloadCacheTests in the runtime tests: after bypassTensorPayloadCache a weight file read into the cache is under 10 % resident, config.json keeps its page, checkUnchanged passes and the uncached aligned read returns the original bytes. On dev the weight file stays 100 % resident. - StageLoadFileCacheGuardTests: the darkbloom-load-memory-v1 line names the rule that settled a load gate and the figures of the decision it rests on (the 2026-11-03 M5 Max refusal: 515 MiB compressed). ObservabilityChecks: that line in a worker's tail is never read as a failure (green before and after). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fore a load reads it
MiMo V2.6 Flash never served on two 128 GB M4 Max Macs: 680 of 680
starts were refused by the load gate ("needs 25.79 GiB, has 0.09"). A
16 GB Qwen 27B rank was refused once on a 128 GB M5 Max ("0.17 GiB free
plus no file cache: 515 MiB was compressed ... limits 512 and 64 MiB").
The gate counts free pages plus every file-backed page, and counts no
cache once a load has compressed more than 512 MiB. Every part start
(and every retry) read the whole model folder into the file cache
(prefetchPagesInBackground, db88e55). Loading a share against a
cache that is mostly its own model makes macOS free it page by page by
compressing other memory, so the guard fired, the start was refused,
the part restarted, the prefetch refilled the cache, and so on.
- A. ClusterService.supervise drops the model folder's cached pages,
synchronously, before this Mac's part starts, instead of reading them
in. ClusterModelStore.dropCachedPages also drops regular files one
folder down (MiMo's audio_tokenizer/), opened through the folder's
descriptor, never through a link. prefetchPages,
prefetchPagesInBackground and ClusterModelPrefetchFolders go: nothing
else used them. The comments that said the gate can count that cache
are corrected.
- B. VerifiedCheckpoint.bypassTensorPayloadCache drops each weight
file's cached pages through its pinned descriptor when it turns the
payload reads uncached. The MiMo, Qwen, Gemma and GPT-OSS pipeline and
tensor-parallel loads take this path; GLM's prepared load still reads
through the cache on purpose.
- C. Observability only: QwenDenseStageLoadAdmissionSummary.logLine,
and the worker writes one darkbloom-load-memory-v1 line per load gate
after the load or before the failure that ended it (rule, required,
admissible, free, file-backed, counted, kernel minimum, compression
and swap-out since the first sample). Its words match no incident
rule. The dead room-making pass stays, for the reasons in the report.
Both drops use msync(MS_INVALIDATE) over a read-only shared mapping: no
privileges, no purge, the files' bytes and identity unchanged, and only
the model's own files. The gate's rules, its 512 MiB limit and the
placement are unchanged. A load now reads its weights from the SSD, a
few seconds more on a warm restart.
Docs: inference.md (the gate), two-mac-cluster.md, test.md. Changelog:
cluster-drop-model-cache-before-load.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Behavior-preserving cleanup of the cache-drop fix (the required refactor
pass). The same system calls run on the same files, in the same order.
- VerifiedCheckpoint: File.dropCachedPages() and
bypassTensorPayloadCache() no longer return a byte count. Every caller
and test discarded it, so bypassTensorPayloadCache() is back to dev's
signature. The drop is still mmap(PROT_READ, MAP_SHARED),
msync(MS_INVALIDATE) and munmap on the pinned descriptor, best effort.
- ClusterModelStore: the private one-file helper is now
dropCachedPages(ofFile:in:), so the call sites say which file and
which directory, and it no longer reads like the folder overload.
- Comments and docs:
- ClusterService: the part-start comment said every load reads
uncached. GLM's tensor-parallel load reads through the cache on
purpose (keepFileCache on the product's prepared path), as
docs/architecture/inference.md already says.
- logLine's doc comment names the classifier type,
ClusterFailureClassifier; ClusterIncidentGuidance is its file.
- docs/developer/test.md: the run line for
ClusterServicePartStartCacheTests pointed to a sandbox profile that
is not in the repository. It now reads like its neighbours.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
8 of 17 tasks
Run in one test process in parallel (local `swift test`'s default), ClusterServiceRecoveryTests failed every time beside the new ClusterServicePartStartCacheTests (validator, 3 of 3). Both run the real service loop. While serving, each service holds IOKit assertions named "Darkbloom cluster: serving deployment". The recovery test counts this process's assertions by that name. macOS keeps assertions per process, so it saw the other suite's too: `serviceAssertionTypes() == held` and `.isEmpty` failed (:150, :155). Each suite already had its own home, paths, pairing, part process and temporary folders. The assertions were the only state they shared, and they are process-wide. - ClusterService takes the assertions' name as an internal init parameter (`powerAssertionReason`). The default is ClusterServicePowerAssertions.servingReason, the unchanged production name. - The recovery lifetimes test gives its service a name of its own and counts only that name. The part-start test names its service apart too, as ClusterServicePowerAssertionTests already do. No .serialized is needed across suites. Both suites together in parallel: 5 of 5 pass (red before: 2 issues). Each alone: 7/7 and 1/1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 4, 2026
Brings #1763, #1765, #1764, #1770, #1772, #1767, #1768, #1769 and #1766 from dev. One conflict, in docs/provider/two-mac-cluster.md (2 hunks): before "## Undo", #1774's "Stopping and starting again", then #1770's "Pairing again"; Undo keeps #1770's opening, #1774's --service sentences, the Uninstall link, and #1772's "## Uninstall" section as written. Resolution verified in a dry run (tree 4737f00). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/provider/two-mac-cluster.md
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the memory-gate loop that kept MiMo V2.6 Flash from ever serving on two 128 GB Macs. On 2026-11-01 a pair of
M4 Max 128 GB MacBook Pros running provider 0.10.6 was refused 680 times out of 680 starts over six hours, all
memory_gate_refused("needs 25.79 GiB, has 0.09"). It served only once a background job on both Macs cleared MiMo's filesfrom the file cache every second. The same cause refused a 16 GB Qwen3.8 27B rank once on our 128 GB M5 Max (2026-11-03
23:48:44Z):
Cause.
512 MiB.
prefetchPagesInBackground,since
db88e554c8): 161 GiB for MiMo.compressing other memory. The guard fires and the start is refused. Then the part restarts, the prefetch refills the cache,
and the cycle repeats.
Fix.
pages, including one folder down (MiMo's
audio_tokenizer/) and never through a link. The prefetch is removed.VerifiedCheckpoint.bypassTensorPayloadCache()drops each weight file'scached pages through its pinned descriptor. That covers MiMo, Qwen, Gemma and GPT-OSS, pipeline and tensor parallel.
GLM's prepared load is unchanged on purpose.
darkbloom-load-memory-v1line per load gate: the rule, the figures and thecompression since the first sample. The next refusal explains itself.
purgeor sudo, the files are neverchanged, and only the model's own files are dropped.
Linked issue
None filed. Field report: Dylan's MiMo pair, 2026-11-01. Our M5 Max refusal: pair 2 validation, 2026-11-03.
Test plan
Red on
devwith only the tests added (4b1c5be34b), green with the fix (a7dbb1f870):ClusterServicePartStartCacheTestsruns the real service loop, with the follower's part as/usr/bin/true. Its modelfolder (a 64 MiB weight file and a 32 MiB file in
audio_tokenizer/) is read into the cache first. Ondev, bothfiles are 100 % in the file cache when the part starts; with the fix, under 10 %, with their bytes unchanged. 5 of 5
repeats.
CheckpointChecks/run.shandCheckpointPayloadCacheTestscheck what happens afterbypassTensorPayloadCache. Ondevthe weight file stays 100 % resident. With the fix it is under 10 %,
config.jsonkeeps its page,checkUnchanged()passes, and the aligned read returns the original bytes.
ClusterModelProvisioningChecks/run.sh: the drop covers one folder down, no link and nothing deeper (dev: thesubfolder's file was not dropped).
StageLoadFileCacheGuardTestscovers the log line's rule and figures, including the M5 Max refusal shape.Green before and after:
ClusterServiceRecoveryTests: 7 of 7;StageLoadFileCacheAdmissionTests,StageLoadFileCacheGuardTestsandStageLoadMeasurementModeTests:35 of 35;
The provider build of every product and test passes, and the worker module typechecks against it.
make docs-check,make docs-impact-check BASE=origin/devandmake changelog-checkpass, andgit diff --checkis clean.Hardware, in progress (0.10.8 candidate on the owner's pairs; this fix ships together with cluster: judge a Mac's memory by the load gate's rule and the GPU limit (MiMo on 128 GB Macs, mixed pairs) #1767):
pipeline;
The numbers to watch are in the candidate's plan: residency to about 0 at the part start, the "Compressions" delta under
32,768 pages, and
refused=0.Validator fix
d036b3f970: parallel test isolation. Run in one test process beside the newClusterServicePartStartCacheTests,ClusterServiceRecoveryTestscounted the other suite's power assertions(macOS keeps them per process). CI runs the suites serially, so it was green. Each suite's service now uses its
own assertion name (
ClusterService(powerAssertionReason:), default unchanged). Both suites pass together inparallel 5 of 5 (failed at
2e768bffd5); each alone 7/7 and 1/1;ClusterServicePowerAssertionTests5/5.Components touched
ClusterService,ClusterModelProvisioningVerifiedCheckpoint,QwenDenseStageLoadAdmissionSummary, the worker'sWorkerMainProtocol / interface changes
darkbloom-load-memory-v1.Documentation impact
docs/architecture/inference.md,docs/provider/two-mac-cluster.md,docs/developer/test.md.Changelog
changelog.d/cluster-drop-model-cache-before-load.mdand ranmake changelog-check.Notes for reviewers
on 256 GB Ultras loses the warm folder (about 12–14 s becomes 19–22 s, by
db88e554c8's estimate). Not starting at allcost more.
the refusal is now self-explaining. Counting only the cache above the kernel minimum is a later policy change, and it must
not land before this one.
QwenDenseStageLoadReclaim) has not been able to run since58d7371a. It is documented assuch and left for removal with the model-fit branch, whose files cite it.
fix/cluster-model-memory-fit. Its at-rest change offers MiMo on 2× 128 GB, and without thisfix that offer loops.
Before And After
Behavior, before:
flowchart TD A["Part starts (first start or a retry)"] --> B["Prefetch reads the whole model folder into the file cache (161 GiB for MiMo)"] B --> C["Worker hashes uncached, then loads its 76-82 GiB share"] C --> D["macOS frees the cache page by page and compresses other memory"] D --> E["Compressed more than 512 MiB since the first check"] E --> F["Gate counts no file cache: needs 25.79 GiB, has 0.09 GiB"] F --> G["memory_gate_refused: the part ends"] G --> ABehavior, after:
flowchart TD A["Part starts"] --> B["Service drops the model folder's cached pages (folder and one folder down)"] B --> C["Worker hashes uncached; the load drops each weight file's pages before its uncached reads"] C --> D["Share loads from the SSD into free pages; nothing to compress"] D --> E["Gate admits every decision"] E --> F["worker.log: darkbloom-load-memory-v1 ... refused=0 ... compressed_since_first small"] F --> G["Rank ready; the pair serves"]Code flow, before:
flowchart LR S["ClusterService.supervise"] --> P["ClusterModelStore.prefetchPagesInBackground"] P --> T["Thread: prefetchPages, 4 readers of 8 MiB preads"] S --> R["Process.run"] W["Worker stage or TP load"] --> V["VerifiedCheckpoint.bypassTensorPayloadCache"] V --> N["F_NOCACHE and F_RDAHEAD only: cached pages still serve the reads"] W --> X["Refusal: only the error sentence reaches worker.log"]Code flow, after:
flowchart LR S["ClusterService.supervise"] --> D["ClusterModelStore.dropCachedPages: openat with O_NOFOLLOW, mmap and msync(MS_INVALIDATE)"] D --> H["beforePartStart"] H --> R["Process.run"] W["Worker stage or TP load"] --> V["VerifiedCheckpoint.bypassTensorPayloadCache"] V --> N["F_NOCACHE and F_RDAHEAD, then File.dropCachedPages on the pinned descriptor"] M["WorkerMain after the load or at its failure"] --> L["WorkerLoadMemory.write: one logLine per load gate"]Refactor Pass
A dedicated refactor subagent reviewed the finished fix (
2e768bffd5, one signed commit, 5 files, +14/−20). Thechanges are behavior-preserving: no rule, limit, log format, test or assertion changed, and the same system calls run on
the same files in the same order.
VerifiedCheckpoint.File.dropCachedPages()andbypassTensorPayloadCache()nolonger return a byte count. Every caller and test discarded it, so
bypassTensorPayloadCache()keeps dev'ssignature.
ClusterModelStore.dropCachedPages(ofFile:in:), so itscall sites no longer read like the folder overload.
ClusterServicesaid every load reads uncached. GLM'stensor-parallel load reads through the cache on purpose (its
preparedpath), as the architecture doc already says.logLine's doc names the classifier typeClusterFailureClassifier. The test guide's run linefor
ClusterServicePartStartCacheTestsno longer points to a sandbox profile that is not in the repository.Reviewed and left unchanged:
O_NOFOLLOWat every open, nothingdeeper.
File.dropCachedPages()'s handling of edge cases: zero-length files, mapping failure and truncation.darkbloom-load-memory-v1field set. Its rules followQwenDenseStageLoadPolicy.decide's order; it is pinnedbyte for byte by two tests and matches no incident rule.
QwenDenseStageLoadReclaimpass. It is accurate; the pass stays for removal afterfix/cluster-model-memory-fitlands.Rerun after the pass:
ClusterServicePartStartCacheTests(5 of 5 repeats) andClusterServiceRecoveryTests(7 of 7), bothsandboxed.
CheckpointChecks(4 groups),ClusterModelProvisioningChecks(148 plus thedownload cache check's 4).
ObservabilityChecks(212), the gate suites (35 of 35) andCheckpointPayloadCacheTests(1 of 1), the last two through scratch harnesses.
make docs-check,make docs-impact-check,make changelog-checkandgit diff --check.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.