Repository navigation
provider: drop fused-MoE-cache accounting; pin mlx-swift-lm to merged fused-cache removal - #516
Conversation
…sed-cache removal mlx-swift-lm (Layr-Labs/mlx-swift-lm#66) deletes SwitchGLU's runtime fused gate+up cache — the full second copy of the MoE gate/up expert weights (7.98 GiB qat-4bit / 15.07 GiB 8bit always-resident) whose only active shape was B=1 solo decode at ~0% measured win, and the root cause of the v0.7.3 black-hole incident. With the cache gone the provider's fused-byte accounting has nothing to measure, so the special-casing is deleted rather than left reading a structural zero: - EngineV2VLMTextExtraction: no more cross-tree cache sharing (shareMoEFusedCaches) or fusedMoECacheBytes measurement; Extraction carries only the model + parity diff. - EngineV2KVSizing.netOfEngineResidentOverhead deleted — the v2 KV ceiling is the weights-derived grant, nothing netted out (PR#508 finding 2 no longer has a subject). The 8–15 GiB return to KV / admission headroom automatically. - ModelSlot.engineResidentOverheadBytes deleted; the co-resident residency sums (later engine ceilings, heartbeat fleet clamp) are plain weight sums again. The post-engine-build serveable-KV headroom re-check (unload + 503, never black-hole) stays — it guards any load-time growth, not just the removed cache. - Tests: EngineV2FusedCacheCapacityTests deleted (its subject is gone); the two Gemma VLM live tests now pin the STRONGER invariant that the extraction + parity probe retain (almost) nothing beyond the shared weights, and that the weights-derived v2 ceiling equals the shared gate's headroom with nothing netted. Parity re-run on this pin (M4 Max, qat-4bit, BenchCBv2 v2-compiled, 256 steps): B=1 104.6-107.1 TPS/req, B=2 69.9-70.3 TPS/req, gpuActive 13.48 GiB (fused-ON baseline 21.45 GiB). Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR removes a VLM-specific MoE fused-cache memory accounting layer ( Trust Boundaries Touched
Threat AssessmentT-007 / T-012 / T-027 — Weight hash integrity, model serving correctness T-008 — Plaintext SSE fallback on encryption failure T-009 — Swift provider excluded from private-text routing (Python flags) T-010 — Inference cancellation propagation T-034 — APNs code-identity challenge T-028 — Residual inference data in GPU memory New Attack SurfacePotential over-routing after removal — not a new exploit surface, but a correctness risk worth flagging: The deleted Reviewers should confirm that SEC-* Findings ResolvedNone. This PR does not resolve any open SEC-* findings. 🔐 Threat model: |
…66 + CBv2 vision prefill #63) provider-swift full suite against the new pin: 1,340 tests / 115 suites, all pass (clean rebuild; the transient SIGSEGV during iteration was a stale incremental-build artifact from cross-pin object files, gone after a clean build with mlx.metallib restored). Co-authored-by: Cursor <cursoragent@cursor.com>
|
mlx-swift-lm#66 is merged; the pin now points at merged main bc6eb9b (includes #66 fused-cache removal + #63 CBv2 vision prefill, which is API-additive for the current provider). Full provider suite against the new pin: 1,340 tests / 115 suites, all pass (clean rebuild). Note for reviewers: an initial run showed a SIGSEGV in test teardown — it was a stale incremental-build artifact from switching submodule pins, not a code issue; gone after |
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: COMMENT
Security — ✅ No issues found
Performance — ✅ No issues found
Type_diligence — ✅ No issues found
Additive_complexity — ✅ No issues found
✅ All four passes clean. No issues found.
🤖 Automated review by Centaur · DAR-186
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b350616429
ℹ️ 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".
| let ceiling = EngineV2KVSizing.engineKVBytesCapacity( | ||
| newModelWeightBytes: Int(min(mlxUsedNow, UInt64(Int.max))), |
There was a problem hiding this comment.
Use scheduler weights in the capacity regression
In this live regression, passing mlxUsedNow as newModelWeightBytes makes the static ceiling use the same live MLX active+cache total that liveKVHeadroomBytes uses below, so the equality becomes tautological. Production makeEngineV2BridgeForSlot sizes the v2 grant from scheduler.modelWeightBytes before extraction/engine-build retained state, not from live MLX usage, so this no longer catches the over-advertising case it claims to guard when extraction leaves any non-weight resident overhead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f5999e0: the ceiling is now sized from scheduler.modelWeightBytes — the exact input production makeEngineV2BridgeForSlot passes — so retained non-weight state shows up as ceiling-over-headroom divergence instead of cancelling out. Bounded by the same 2 GiB retained-state bar as step 1, with a 64 MiB rounding guard on the impossible direction. Verified live on the 8bit checkpoint: ceiling 28.57 GiB vs headroom 28.56 GiB, retainedOverhead 0.00 GiB.
|
Found 1 test failure on Blacksmith runners: Failure
|
The step-4 consistency check passed live MLX usage as newModelWeightBytes, making ceiling == headroom tautological. It now uses scheduler.modelWeightBytes — the exact input production makeEngineV2BridgeForSlot passes — so any non-weight state retained by extraction/probe shows up as ceiling-over-headroom divergence, bounded by the same 2 GiB retained-state bar as step 1 (plus a 64 MiB rounding guard in the impossible direction). Verified live on the 8bit checkpoint: ceiling 28.57 GiB vs headroom 28.56 GiB, retained overhead 0.00 GiB. Co-authored-by: Cursor <cursoragent@cursor.com>
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: COMMENT
Security — ✅ No issues found
Performance — ✅ No issues found
Type_diligence — ✅ No issues found
Additive_complexity — ✅ No issues found
✅ All four passes clean. No issues found.
🤖 Automated review by Centaur · DAR-186
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: COMMENT
Security — ✅ No issues found
Performance — ✅ No issues found
Type_diligence — ✅ No issues found
Additive_complexity — ✅ No issues found
✅ All four passes clean. No issues found.
🤖 Automated review by Centaur · DAR-186
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: COMMENT
Security — ✅ No issues found
Performance — ✅ No issues found
Type_diligence — ✅ No issues found
Additive_complexity — ✅ No issues found
✅ All four passes clean. No issues found.
🤖 Automated review by Centaur · DAR-186
…GiB reclaimed per MoE box) The SwitchGLU runtime fused gate+up cache held a full second copy of the MoE expert weights (~15 GiB on gemma-4-26b-8bit, ~8 GiB on qat-4bit) for a decode benefit measured at ~0%, confined to B=1 solo decode — batched decode and prefill never used it. Deleting it (mlx-swift-lm #66/#67, d-inference #516) returns those bytes to KV/admission headroom automatically via the weights-derived v2 ceiling. Also rides in this pin: dormant CBv2 vision-prefill engine support (mlx-swift-lm #63) — activates with the upcoming multimodal provider release; text serving is byte-identical. LatestProviderVersion fallback bumped in lockstep. Co-authored-by: Cursor <cursoragent@cursor.com>
- A prompt_anchor_mismatch receipt quarantines the provider's cache capability for the whole model (coordinator CacheQuarantineCommit.Apply; ProofFenceBase 60 s, doubling to ProofFenceMax 10 min), not only the mismatched requests' affinity. Say so in the changelog note and runbook step 1, and cite the platform code in the evidence table. - #1599 shipped in v0.10.2 (99e1059 is an ancestor of f9d1af3), not first in the v0.10.3 hotfix. - Drop the runbook's "platform change that pushes trust_status when legacy authorization starts is in progress": that change is darkbloom-platform#541, merged as 6beb8514, which step 1 already requires. - Step 1: deploy shortly before the tag, matching the changelog's "close to this rollout" for #516, and limit #491's 5 s refresh to App Attest serving (startUnauthorizedStatusRefresh returns unless ServingEnabled). - Step 3: name LatestProviderVersion instead of the dangling "That fallback constant", and scope "only ProviderCore.swift should change" to the snapshotted inputs. - Evidence: production 2acffb5c also lacks #491 and #541; add rows for the #491/#541 status behavior and the quarantine.
* chore(release): prepare provider 0.10.4 Set ProviderCore.version to 0.10.4 and mark v0.10.3 as published on 2026-10-26 (tag target 3ddd11c). Open the v0.10.4 candidate entry with its upgrade and rollout notes: deploy darkbloom-platform#516 close to the rollout (Qwen JSON prompts render without thinking; mixed versions fail cache receipts with prompt_anchor_mismatch but still serve), the client-visible Qwen JSON changes (no default reasoning, a grammar-constrained answer cut short is a 422 after streaming, no MTP beside a constrained row), forced tool_choice on four more models without a version floor, delta checkpoints across upgrade and rollback, the unauthorized re-registration cadence, the status served-line format, the add-on hold (darkbloom-platform#514 already in production), unchanged MLX pins, and the entries that build no provider artifact. Update the release runbook: the 0.10.4 scope, the pin and metallib checks before tagging, the rollout order and post-tag platform snapshot, the 0.10.2 enablement steps that still apply, platform evidence inspected on 2026-10-27, and the published history. The pending changelog fragments are rendered in the next commit. * chore(release): render the pending changelog fragments into provider 0.10.4 Insert the output of python3 scripts/changelog.py render --version 0.10.4 --date 2026-10-27 \ base-reward-zero-reason.md ci-darkbloom-runner-routing.md \ coordinator-reconnect-stall.md coordinator-traffic-verdict.md \ delta-complete-checkpoints.md desktop-release-sign-dmg.md \ desktop-update-feed.md forced-tool-choice-admission.md \ json-response-format-enforcement.md landing-agent-documents.md \ provider-addon-hold-hardening.md provider-addon-hold.md \ status-served-session-counts.md switch-model-cache-directory.md verbatim, without its heading line, below the v0.10.4 upgrade and rollout notes, and remove exactly those 14 fragments. The render ran against an export of origin/master aa2887f, whose changelog.d matches this branch, because the renderer refuses a version that CHANGELOG.md already names. This commit is mechanical so the final roll-up can revert it, merge master and render again once the in-flight 0.10.4 changes have landed. * Revert "chore(release): render the pending changelog fragments into provider 0.10.4" This reverts commit f673fff. * chore(release): update 0.10.4 rollout notes for #1630, #1631, #1633 and platform #491/#541 The re-registration note now states which evidence counts (#1633); the delta-checkpoint off switch is forwarded to the launchd job (#1630); the coordinator to deploy before the tag must include #516, #491 and #541; #1631 joins the non-provider entries. * chore(release): correct the 0.10.4 rollout notes from the review pass - A prompt_anchor_mismatch receipt quarantines the provider's cache capability for the whole model (coordinator CacheQuarantineCommit.Apply; ProofFenceBase 60 s, doubling to ProofFenceMax 10 min), not only the mismatched requests' affinity. Say so in the changelog note and runbook step 1, and cite the platform code in the evidence table. - #1599 shipped in v0.10.2 (99e1059 is an ancestor of f9d1af3), not first in the v0.10.3 hotfix. - Drop the runbook's "platform change that pushes trust_status when legacy authorization starts is in progress": that change is darkbloom-platform#541, merged as 6beb8514, which step 1 already requires. - Step 1: deploy shortly before the tag, matching the changelog's "close to this rollout" for #516, and limit #491's 5 s refresh to App Attest serving (startUnauthorizedStatusRefresh returns unless ServingEnabled). - Step 3: name LatestProviderVersion instead of the dangling "That fallback constant", and scope "only ProviderCore.swift should change" to the snapshotted inputs. - Evidence: production 2acffb5c also lacks #491 and #541; add rows for the #491/#541 status behavior and the quarantine. * changelog: delta complete checkpoints apply to Qwen native recurrent layouts, not only Qwen 3.8 Eligibility follows the checkpoint layout (native-paged/contiguous-full-recurrent-v1), which Qwen 3.5/3.6 MTP builds also produce; the fragment is rendered verbatim into 0.10.4. * chore(release): render the pending changelog fragments into provider 0.10.4 Verbatim scripts/changelog.py render output for the 15 fragments pending on master (rendered from a master export, since CHANGELOG.md already names 0.10.4), inserted below the rollout notes; exactly those fragments deleted. #1427 is not in 0.10.4 and its fragments stay with it.

Summary
mlx-swift-lm#66 deletes
SwitchGLU's runtime fused gate+up cache — a full second copy of the MoE gate/up expert weights (7.98 GiB qat-4bit / 15.07 GiB 8bit, always-resident once a model serves one request) whose only active shape was B=1 solo decode at ~0% measured decode win, and the root cause of the v0.7.3 black-hole incident. This PR removes the provider-side accounting that existed only to measure and net out that cache, and bumps the submodule pin.With the cache gone, the fused-byte measurement is structurally zero — so the special-casing is deleted, not left as dead plumbing:
EngineV2VLMTextExtraction— no more cross-tree cache sharing (shareMoEFusedCaches, the v0.7.3 fix) orfusedMoECacheBytesmeasurement;Extractioncarries only the model + parity diff.EngineV2KVSizing.netOfEngineResidentOverhead— deleted. The v2 KV admission ceiling is the weights-derived grant with nothing netted out (PR#508 finding 2 no longer has a subject). The reclaimed 8–15 GiB flows straight back into KV/admission headroom, exactly as the fleet ceiling math already derives it.ModelSlot.engineResidentOverheadBytes— deleted; co-resident residency sums (later v2 engine ceilings inProviderLoop+EngineV2, the heartbeat fleet-budget clamp inProviderLoop+Capacity) are plain weight sums again.ProviderLoop+ModelLoading(unload + 503 instead of advertising a dead model) — it guards any load-time growth, not just the removed cache. No other budget logic touched.EngineV2FusedCacheCapacityTestsdeleted (subject gone). The two Gemma VLM live tests now pin the stronger invariant: extraction + parity probe retain < 2 GiB beyond the shared weights (pre-v0.7.3 this measured ~30 GiB — two fused copies), and the weights-derived v2 ceiling equals the shared KV gate's headroom with nothing netted.Benchmark evidence
From
benchmarks/reports/fused-moe-ab-2026-07-04/SUMMARY.md(bench worktree; M4 Max, 128 GB, BenchCBv2 = real EngineV2/CBv2, compiled decode, temperature 0):Decode TPS delta at the cache's ONLY active cell (B=1 solo decode, ABBA-interleaved): mean paired delta ≈ 0.0% on qat-4bit (sign alternates across 4 pairs); ≤ +2–4%-within-noise on 8bit. B≥2 and all prefill are structurally unchanged (same code path both configs).
Post-removal parity re-run (this pin, same machine, qat-4bit, v2-compiled, 256 steps, two trials):
gpuActive lands exactly on the fused-OFF figure; B=1 TPS at/above the recorded ~94–100 baseline band.
Fleet impact
36–64 GB boxes currently cannot hold gemma-8bit + fused cache + KV; reclaiming ~15 GiB is the difference between serving and not serving, and CBv2's whole value is batched decode where the cache does nothing.
Before / after
Memory model + admission:
Code path:
Test results
StartupPreloadTestsgate-timing andcodexR6Medium_engineTierLoadBlockDropRefreshesAccountantfailed on the clean baseline pin too;admissionDoesNotBlockTheActorOnTheReclaimFlushflaked once under full-suite load; all three pass deterministically in isolation).swift build -c release --product darkbloomgreen;kv-se-harness(test-only executable) is pre-broken on the baseline pin, untouched here.Made with Cursor
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.