Repository navigation
feat(#33): /v1/models/preview, wired limit by default, mlx-swift 0.33, watchdog for long prefills - #276
Merged
Conversation
…, a watchdog that lets long prefills finish - GET /v1/models/preview?model_id=&context= answers what loading a model would cost (weights, KV per 1k tokens, required and available bytes, fit, token budgets) from MemoryEvaluator, without loading weights. - serve and PerformanceBenchmark hold a WiredMemoryTicket of Metal's recommended working set while a model is loaded and release it on unload, with MLX renewing residency every second (MLX_METAL_RESIDENCY_REFRESH_INTERVAL_MS, ml-explore/mlx#4633). --no-wired-limit leaves the system default. On Gemma 4 26B-A4B it cut swap by 41% under competing memory pressure and changed nothing without it. - mlx-swift 0.33.0 (MLX 0.32.4) via goodmai/mlx-swift-lm@cdfc249, which drops CompiledTrace's shadowing compile overloads like upstream. - The generation watchdog budgets prefill at 50 tok/s instead of 200, so a 64k prompt on Gemma 4 12B is no longer killed at 300 s. - basalt-model-runs: every model table includes Gemma 4 of at least 12B. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cicgudpVmSKaQgaioocQ1
goodmai
force-pushed
the
feat/33-preview-wired
branch
from
November 4, 2026 00:31
823ba76 to
e74cb9c
Compare
This was referenced Nov 4, 2026
This was referenced Nov 29, 2026
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.
Part of #33 (part 1; block-sparse attention follows separately).
What
GET /v1/models/preview?model_id=&context=reports what loading a model would cost without loading weights: weights, KV per 1k tokens, required/available bytes,fits,fit_level, max context/prompt tokens, warning and recommendation (fromMemoryEvaluator).serveandPerformanceBenchmarkhold aWiredMemoryTicketof Metal's recommended working set while a model is loaded and release it on unload. MLX renews residency every second (MLX_METAL_RESIDENCY_REFRESH_INTERVAL_MS=1000).--no-wired-limitleaves the system default.compileoverloads, as upstream did.Why the limit is on by default now
Before MLX 0.32.4, a residency set lost residency after about 2 s of GPU idle (ml-explore/mlx#4609). On that MLX the limit made things worse without memory pressure. The fix is ml-explore/mlx#4633. It works only when the refresh env var is set before the first Metal allocation, so
run()sets it first. With the fix, the limit does no harm without pressure and cuts swap by 41% under pressure.A feedback controller in MemoryCoordinator was considered and skipped. The measurements show one good setting (the full working set) and no case where a smaller limit would win.
Measurements
24 GB Mac, release build, T=0,
gemma-4-26B-A4B-it-qat-4bitunless noted. "Ballast" is a competing process holding that much RAM.MLX 0.32.4 (this PR)
Older MLX, for the record
Notes:
PerformanceBenchmarkreports on the 64k runs (~0.1 s) leaves out prefill. That bug is filed separately; wall time is shown here instead.pressure033-*,nopress033-*,wired033-*in the session scratchpad.Checks
swift build -Xswiftc -warnings-as-errorspasses.scripts/check_no_new_comments.pypasses.swift test --parallelpasses: 1237/1237.HuihuiAndEx0bitModelTests"registers type aliases" failed once under parallel load and passed on rerun. It is unrelated to this change.🤖 Generated with Claude Code
https://claude.ai/code/session_012cicgudpVmSKaQgaioocQ1