Repository navigation
Provider: a memory_only cache policy per request, and SSD cache records without token IDs - #2575
Merged
Merged
Conversation
- Parse an optional cache_policy in the sealed _darkbloom_cache member. "default" or absent keeps today's behaviour; memory_only, and any other value, runs the request with its prefix cache off, so it never reads, writes, stages, donates or restores anything on the SSD tier. The policy needs no nonce or scope; a plaintext cache_policy on the frame can only narrow it. - The SSD stores refuse every call made with a memory-only receipt, counted on the local /metrics beside requests by policy. - Complete checkpoints store a keyed digest of their prefix instead of its token IDs, and an MTP assistant's token tensor as zeros; a restore rebuilds both from the request's prompt. The epoch binding is versioned, so either format's files are removed when the other opens the model directory. - Cluster prefix records (versions 3 and 4) store history tokens as zeros. - DARKBLOOM_SSD_KV_TTL_MODE=fixed stops a reuse from extending an entry's life. - Advertise the cache_policy_v1 runtime capability.
Document the sealed cache_policy and its frame rule, cache_policy_v1, every file a request can leave on disk, the token-free checkpoint and cluster record formats, DARKBLOOM_SSD_KV_TTL_MODE and DARKBLOOM_LOCAL_CACHE_POLICY, with a changelog fragment.
Behaviour is unchanged; formats, wire keys, metric names and the capability string are untouched. - SSDHybridCheckpointEnvelope: decodeManifest and the DEBUG inspectStoredManifestForTesting parse chunk 0 through one StoredManifest instead of two copies of the same member lookups. The PackedTokens comment says why it copies MLXLMCommon's internal encoder. - SSDHybridCheckpointStore: takeStaged and takeNativeStaged share the memory-only refusal in takeStage. The write path releases a refused and a withheld preparation in one branch. - SSDPrefixCache: the three fixed-TTL refresh sites wrap the original refresh code in one `if config.ttlMode.refreshesOnHit` each. - RequestCachePolicy(decoding:forKey:) holds the absent/present rule the sealed member and the plaintext frame both read. The localServing comment sits on the function it describes. - The local endpoint reads DARKBLOOM_LOCAL_CACHE_POLICY once and gives the same value to the scheduler engines and the Nemotron Super engine. - MultiModelBatchSchedulerEngine: the cachePolicy comment now covers local requests and the prompt-token piece cache. - Tests: the checkpoint fixture donates a given source, replacing two copied continuations; an inline donation replaces a copied attention helper; the handler test no longer expects an exact process-wide count of default requests, which other suites also add to; the pair rank's fixed-TTL test advances the tier's clock instead of sleeping. - Docs: restamp the five changed pages that kept an older date.
…x cache off The image and video route of the Super owner did not pass a request's cache policy to the bridge, so a memory_only media request on an owner with a checkpoint bank could restore from and publish to it. The policy now reaches submitTokenized on that route, as on the text route. Tests: a marked text and a marked image request on a bank owner make no lookup, restore nothing and publish nothing; the unmarked requests around them miss, then hit.
Name the provider's usage-history.json and the desktop app's settled usage archive beside the cache files one request can leave on disk.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jonathan308
added a commit
that referenced
this pull request
Nov 23, 2026
# Conflicts: # provider-swift/Sources/ProviderCore/KVCacheSSD/SSDHybridCheckpointStore.swift
A version-4 record keeps one history for all its frontiers. Its restore sized the token buffer to the record's deepest prompt and filled it from the request's prompt, so a shorter prompt that covers a kept frontier failed and the record was deleted. The restore now fills only the frontier's tokens, the part the view uses.
…eep clear of seeded IDs A pair member registers and attests cache_policy_v1 beside its hardware capabilities, since its ranks run a memory_only request with the prefix cache off and the coordinator needs every member to report it. Memory-only receipts move to bit 62 with the seeded engine-ID tag clear, so no engine ID falls in the range. The rank no longer lists TTL_MODE as a numeric pass-through; the mode reaches it from this Mac's setting. The handler test checks request counts as lower bounds, since other suites send requests alongside it.
List the daemon state, provider log, unified log, pair telemetry and worker log beside the usage records; say that a memory_only request makes no SSD call and when the receipt range applies; name builds before this change instead of a release number; and say when the other format's files of a model that is not loaded go.
jonathan308
added a commit
that referenced
this pull request
Nov 23, 2026
jonathan308
added a commit
that referenced
this pull request
Nov 23, 2026
# Conflicts: # docs/provider/direct-mode.md # provider-swift/Sources/ProviderCore/Inference/PrefixCache/RequestCachePolicy.swift
jonathan308
added a commit
that referenced
this pull request
Nov 23, 2026
Release before sleep and the partial release on a covered refused charge; the up-to-2x admission cost when free memory bounds headroom; budget 0 and oversize exports; duplicates and the fixed TTL; transient heap copies; Nemotron Super and native MiMo in the configuration row; the changelog no longer repeats #2575's piece-cache change.
Expired records were deleted only inside the next write or at load, so an idle pair kept them on disk past the TTL. A running rank now sweeps its own expired records, and the other plans' it kept at load, every expirySweepSeconds (60), as the single-Mac tier's whole-root maintenance. Past its TTL a record is also never restored or kept recent. Comments name the shared history header version 4.
Every 60 s, on a single Mac and on a pair's Macs, the provider deletes the expired .dbpx records of plan folders no running rank holds, so a pair that is not loaded keeps none (ClusterPrefixRecordExpiry). Comments say that a pair member reports cache_policy_v1 beside its hardware capabilities.
The characterization test recorded that an expired attention block was still staged until the sweep removed it. The stage plan now counts only blocks within their TTL, so the test expects the cutoff in both orders, and that a refused stage leaves the files for the sweep.
List what can postpone or prevent removal on one Mac, and state that after a switch to the fixed TTL an entry's age counts from its last recorded hit.
A throwing read inside the right side of && does not compile in #expect.
A re-donation checks its own checkpoint's TTL, not the whole chain. State that a new unpair also replaces a marker it cannot read because of an I/O error, so an earlier selection's pending cleanup can be dropped.
fix/zdr-ssd-residual at 8f2a14e: the existing characterization now expects the stage cutoff before the expiry sweep.
The retirement-recovery case now holds the root as a starting rank does, then checks that an abandoned plan without its lock file goes once the root is idle.
trust_status gains an optional coordinator_features list. While the connected coordinator's latest trust_status lists decode_rate_age_decay, the heartbeat stops omitting an idle slot's observed_decode_tps after DARKBLOOM_DECODE_RATE_IDLE_MAX_AGE_SECONDS: it sends the rate and its observed_decode_tps_age_ms, and the coordinator decays a stale rate toward the fleet median itself. This removes the alternation between no rate (idle) and an old one (busy) for such a coordinator. Absent, malformed or unknown entries, a later trust_status without the entry, and a disconnect keep today's behaviour; the heartbeat is then unchanged byte for byte. Older coordinators never send the field and are decoded as before. Tests: CoordinatorDecodeRateDecayTests (shared wire cases in Fixtures/Protocol/coordinator_features_wire.json, wire shape, advertisement lifecycle, heartbeat bytes with and without the feature).
…intenance Each build keeps its complete-checkpoint files in a directory bound to the build, so after an update or a rollback the other build's files are never read. State when maintenance removes them and when they remain, and that memory_only requests are unaffected. Comment and documentation lines only.
Records of versions 1/2 are refused and removed when the plan that wrote them loads. After an update the old build's pair records sit in another plan directory and follow the usual TTL cleanup. Documentation only.
Conflict in docs/developer/serving-performance-qualification.md only: both sentences kept (the decode rate before a slot's first completed request, then the decode_rate_age_decay advertisement).
This was referenced Nov 24, 2026
This branch was successfully 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
A coordinator request can now ask that nothing it sends reaches this Mac's SSD cache, and cached prompts no longer
store token IDs.
memory_onlyper request. The coordinator sealscache_policyinside the request's_darkbloom_cachemember, either beside the cache identity or alone (
{"cache_policy":"memory_only"}).capture, donation or write.
prefix_cache_*_v2evidence and skips the prompt-token piece cache."default"keeps today's behaviour; any other value counts asmemory_only.nonce, as before.
cache_policyon the frame can only narrow the sealed one.memory_onlyrequest makes no SSD read, write or index call. Shouldone run with a cache on (a RAM-only tier is a separate change), its receipt IDs come from their own range
(
MemoryOnlyReceipt: bit 62 set, the seeded engine-ID tag clear), and every entry point of both SSD tiers refusesthat range.
prefix's token IDs.
.dbpx, versions 3/4) store their MTP history tokens as zeros and refill them from theprompt.
an update or a rollback, the other build's files are not reused. They become eligible for removal once unused
(unmodified) for
DARKBLOOM_PREFIX_CACHE_SSD_TTL_SECONDS(1,800 s by default and at most). While the provider runson its own (not as a pair member) and its cache volume has been available since it started, maintenance (every
60 s, and once each time a model's cache opens) removes them after that, or earlier if the disk budget needs the
space. Otherwise they remain on disk: while the provider isn't running, serves as a pair member or started without
its cache volume, until it next runs on its own with that volume available; after the cache location changed,
because another location isn't walked, until that location is selected again; and when a file or directory can't
be read (a malformed header, an unreadable or foreign cache record, a symbolic link or a misnamed entry), until the
cache is cleared or the provider is uninstalled. Empty directories stay. Files written by builds before this
change can contain prompt token IDs until removed. Requests with
cache_policymemory_onlyare unaffected:they never write cache files.
3/4 the same way. After an update, the old build's pair records sit in another plan directory: they are not
reused, and they expire by TTL like other pair records, under the same conditions.
past the 30-minute TTL.
DARKBLOOM_SSD_KV_TTL_MODE=fixedstops a hit from extending an entry: it is not reused morethan 30 minutes (or the configured TTL) after it was written. A later maintenance pass removes the file; removal
has no fixed time. It applies to
kv3and to a pair's ranks (each Mac reads its own setting).Unset, empty or
slidingkeeps today's sliding TTL.cache_policy_v1is reported in Registerruntime_capabilitiesand in the signed attestation'sruntimeCapabilities(one detector feeds both). Each Mac of a pair reports it too, beside its hardwarecapabilities (
memberRegistrationCapabilities).DARKBLOOM_LOCAL_CACHE_POLICY=memory_onlyserves this Mac's local API the same way, so thebehaviour can be measured without a coordinator. Both new switches are forwarded by the LaunchAgent.
/metricsonly:darkbloom_cache_policy_requests_total{policy};darkbloom_memory_only_ssd_refusals_total;darkbloom_memory_only_ssd_tier_touches_total(stays 0).Before
flowchart LR R["Coordinator request<br/>sealed _darkbloom_cache: nonce + scope"] --> H["ProviderLoop.handleInferenceRequest"] H --> B["EngineV2Bridge.submit<br/>prefix cache on"] B --> L["Engine prefix lookup"] --> S[("SSD tier kv3<br/>stage and restore")] B --> P["Prompt-token piece cache"] B --> D["Donation at request end"] --> W[("Complete checkpoint .dbk3<br/>manifest: prefix token IDs<br/>MTP tensor: token IDs")] B --> E["prefix_cache_*_v2 evidence<br/>rewrites cache-epoch.json"] B --> C[("Pair records .dbpx v1/v2<br/>MTP history token IDs")] S -.->|"each hit extends the TTL"| S C -.->|"expired: deleted only at the next write or load"| CAfter
flowchart LR R["Coordinator request<br/>sealed _darkbloom_cache: cache_policy, nonce, scope"] --> H["ProviderLoop.handleInferenceRequest<br/>RequestCachePolicy"] H --> Q{"PrefixCacheSubmissionPolicy"} Q -->|"memory_only"| M["Prefix cache off: no lookup, stage, capture or donation<br/>no v2 evidence, no piece cache<br/>pair ranks: cache disabled"] M -.->|"any SSD entry point"| X["Refused: MemoryOnlyReceipt<br/>counted on local /metrics"] Q -->|"default"| B["Unchanged path"] B --> S[("SSD tier kv3")] B --> W[("Complete checkpoint .dbk3<br/>manifest: keyed prefix digest<br/>MTP tensor: zeros")] B --> C[("Pair records .dbpx v3/v4<br/>history tokens: zeros")] S -.->|"TTL mode fixed: a hit no longer extends the TTL"| S C -.->|"reuse expires; eligible cleanup pass removes due records"| C O[("Files of the other format")] -.->|"removed when the cache opens"| SFiles a request can still leave on disk
A
memory_onlyrequest leaves none of these. A default request may cause:kv3/<model>/<fanout>/<tag>.dbk3, attention blockcreatedAtkv3/<complete model>/<fanout>/<tag>.dbk3, complete checkpoint<tag>.dbk3.darkbloom-tmp.<UUID>crashTempTTLSecondskv3/<model>/cache-epoch.jsonprefix_cache_lookup_v2/prefix_cache_ready_v2kv3/.write-budgetcluster-prefix-v1/v1-<plan>/rank<r>/<tag>.dbpx, on a paircluster-prefix-v1/…/rank<r>/key-check,write-window,staging/<epoch>/…cluster-prefix-v1/…/rank<r>/expiry-ttlNone holds a token ID or text. The same table is in
docs/reference/ssd-kv-cache.md.Outside the cache, any request,
memory_onlyincluded, still causes the following. None holds prompt or outputtext, media, token IDs or a prompt digest:
~/.darkbloom/usage-history.json(owner-only, the last 4,096 records)ProviderUsageHistory)~/.darkbloom/daemon-state.jsonDaemonStateFile)~/.darkbloom/provider.logProviderLogger)~/.darkbloom/cluster/pair-telemetry.json,served-speed.json, on a pair's leaderClusterPairTelemetry)worker.login a pair's setup folder, on each Mac (owner-only, 4 MiB, rotated)~/.darkbloom/desktop/usage-history.jsonDesktopUsageArchive)Both tables are in
docs/reference/ssd-kv-cache.md.Validation
RequestCachePolicyTests: parsing (absent,"default", other values, non-object member); no nonce/scope; noncemismatch; frame narrowing; the submission policy; the receipt range, which no seeded engine ID enters; the local
switch; the capability in registration and attestation; LaunchAgent forwarding; the rank's TTL switch; metric
names.
DistributedServingEligibilityTests.memberRegistersTheCachePolicyCapability: a pair member registerscache_policy_v1.NemotronSuperManagedSlotTests(memoryOnlyTextLeavesTheBankAlone,memoryOnlyImagesLeaveTheBankAlone): onan owner with a checkpoint bank, a marked text or image request makes no lookup, restores nothing and publishes
nothing; the unmarked requests around it miss, then hit.
MemoryOnlySSDTierTests(serialized):memory_onlyrequest throughhandleInferenceRequestleaves the SSD directory unchanged (names, sizes,mtimes), while an unmarked control writes.
CheckpointTokenFreeStorageTests:SSDPrefixCacheTests: fixed and sliding TTL on both tiers; the mode parser.PrefixDiskTierTests(cluster): v3/v4 records hold zeros and restore exactly, a shared-history record also fora shorter prompt that covers its frontier; v1/v2 records are refused and removed; the fixed TTL on a rank; an
idle rank can clean eligible records without a new write; an expired record is never revived, and a fresh capture can be admitted for replacement.
ClusterPrefixRecordExpiryTests: the provider's pass deletes only the tier's expired records of plan folders norank holds; a later running pass removes a due record; it uses the rank's applied TTL stamp (the shorter of it and this Mac's TTL; this Mac's TTL for an empty or malformed
stamp) on a pinned selection's saved volume and pauses for a changed volume; it repairs a plan without its lock only
while no rank holds the root; and a new unpair replaces an unusable reclaim marker.
12270ef039: 514 provider tests in 70 suites. Two dev-namespace path tests had four assertion failures on the local host; the CI run passed. At that same head 82 cluster tests in seven suites passed.12270ef039passed (45153756890); CI also passed on1e3daa02d1(45258903123). Final-head CI passed atcd71d2b86f(45261556892), with no failed jobs.bb13a64d8e, the affected cluster filter passed 86 tests in seven suites and the provider expiry suite passed all three tests. The changed cases cover pinned and refused replacements, lease lifetime after a bounded close, missing lease retry, noncanonical names, saved TTL and descriptor-bound volume selection. Docs, impact and changelog checks passed.f9e5f1743b: 87 affected cluster tests in seven suites, all four provider expiry/reclaim tests, and all 41 standalone console groups passed locally. Earlier proofs for unchanged checkpoint, wire and engine paths are retained under their measured heads.1e3daa02d1: all 33 rank disk tests, 5 provider expiry/reclaim tests, and 41 console groups passed locally. New cases cover changing the selected root, a missing or wrong volume, an old marker without identity, and interruption after plan retirement. Docs/impact/changelog pass.cd71d2b86f, six provider expiry/reclaim cases, the interrupted-retirement regression, 41 console groups, and docs/impact/changelog checks passed locally. The new case reopens the marker at the publication boundary, holds the returned plan across the first retry, substitutes another root on the same volume and confirms it is untouched.a6d123e971: the pair-cache cleanup changes (18dffd737b) add cases for a plan that lost its lock file (repaired only while no rank holds the root), an empty or malformed TTL stamp, earlier-format, malformed and multi-link reclaim markers on a new unpair, and a failed unlink on a rank. In CI the expiry/reclaim suite passes atd7510a0614; withcd71d2b86f's pair sources (Red control for #2575: cleanup tests without the fixes (do not merge) #2587) it fails exactly these cases; CI 45286436202 passed ond7510a0614(attempt 2, after an artifact upload and a fixture download failed in attempt 1; no test failed in either). The new cases ran and passed: the provider pass, lock repair, TTL stamp and reclaim marker cases; both new single-Mac suites and the updated attention TTL case; and the rank tier's failed-retirement and retirement-recovery cases. Only the optional, non-blocking cluster GPU shards were skipped.3fa5bde712(signed mergefb16abaf0e): an epoch wipe that stopped early still leaves that model's due and over-budget files to maintenance and repeats at the next load; an entry past its TTL is not counted by a stage, written over as durable, or used as a delta parent, and a complete checkpoint chain past its TTL is not advertised. TestsSSDInterruptedEpochWipeTestsandSSDExpiredEntryReuseTests; red control Red control for #2590: tests without the change (do not merge) #2591.bb4e5d36f3switches off the policy and format seams on12270ef039. The expected assertions failed in run 45155436488. That remains evidence for the unchanged paths; the replacement and cleanup changes are covered by the additional regressions above. Red control for #2575: cleanup tests without the fixes (do not merge) #2587 adds only the newest cleanup tests tocd71d2b86f, without their fixes; its CI is running.dc25f81861(BASE),12270ef039(NEW), anda003d6e9ef(RAM; branches from3b585299cd)run a repeat-prefix replay shaped like OpenRouter traffic (synthetic prompts; 92 requests per arm). It covers:
memory_only: cached tokens, TTFT, decode speed, peak memory;memory_onlyand the SSD root;make docs-check,make docs-impact-check BASE=origin/devandmake changelog-checkpass.Refactor pass
A separate pass went through the whole diff for behaviour-preserving cleanup (
616da8d0c3):cache_policyvalues;and one exact counter delta that parallel suites can move became a lower bound;
It kept every name, environment variable, metric, wire key and format. It found that Nemotron Super's image and
video route did not pass the policy on, which is fixed here (
1013650a3f) with the tests above.Independent check
A separate, read-only check went through the whole diff and every place a request can write to disk, on one Mac and
on a pair. It found four things, all fixed here:
was then deleted. That would have changed unmarked requests. Fixed in
e1c6ebb4be, with that case in the test.cache_policy_v1, so no pair could take marked requests. Fixed in780e6df261.engages. Fixed in
780e6df261andd3ee65b997.d3ee65b997andabove.
A second check of those fixes confirmed them and found only wording, applied in
3dd2a1d50fand3b585299cd.Expired pair records outliving the TTL on an idle pair came up separately, and are fixed in
52badeefbband3dd2a1d50f. A third check of that fix found that on a pair's Macs the provider's pass looked at the default root andits own TTL, not those the ranks get, and suggested tightening the races around a record's expiry. Those changes landed on this branch in
f1429b13f4,8887b4e231and12270ef039. A further pass found issues with duplicate replacement, shutdown, locks, background settings reads and pathname-based deletion.bb13a64d8eaddressed the writer, plan lease and periodic pass. The next check found incomplete unpair reclaim, combined-budget fallback and a log call under the index lock.f9e5f1743bkeeps staging and the retry marker on any incomplete inspection, takes the same verified lease for switch-off and unpair, and handles eviction and admission accounting under the mutex without writing logs there. The next pass confirmed the budget, mutex, fixture and reuse wording changes. It found two remaining unpair cases: retrying on a new selection and losing the lease before final directory removal.1e3daa02d1records the original selection before reclaiming and renames the verified idle plan before removing its lease. The retirement check passed. The remaining marker issues were addressed incd71d2b86f: first-return inode binding before cleanup, single-link publication by atomic rename, restart verification, and a distinct incomplete status. An independent read-only check ofcd71d2b86fconfirmed both changes and passed all three selected regression tests. The restart fixture uses real filesystem operations; it does not simulate physical unplug or sudden power loss. A fresh check of every cleanup, lock and volume path atcd71d2b86fthen found four pair-cache cases, fixed in18dffd737b: a plan that lost its lock file was never cleaned and blocked unpair; an unreadable reclaim marker blocked every later unpair; a malformed TTL stamp skipped a rank; and a failed unlink left a file untracked. On one Mac it found that an epoch wipe that stopped early left a model's files without maintenance, and that an entry past its TTL could still count toward reuse;1342b58caeand3fa5bde712fix those. An independent read-only check ofcd71d2b86f..d7510a0614found no remaining issue beyond wording, applied in62989397eband here. It covered the two later test updates: the attention TTL characterization now expects the cutoff before the sweep, and the retirement-recovery case still binds recovery to the exact inode while a rank shares the root.Limitations
different volume, or an earlier unpair still waiting for its original selection postpones it. A TTL bounds reuse,
not the time a file is removed.
memory_onlyruns with the prefix cache off. A pair partition that keeps such a prefix in RAM only isa follow-up.
memory_onlyrequest prefills its whole prompt every time. A RAM-only prefix tier for theserequests is a separate, stacked change.
request.
prompt, and a complete checkpoint's media identity. They are digests, not token IDs; file names are keyed.
darkbloom_cache_policy_requests_totalcounts coordinator requests only; local API requests followDARKBLOOM_LOCAL_CACHE_POLICYand are not counted.