Repository navigation
fix(nemotron-super): free prefill temporaries per layer; read checkpoints around the file cache - #318
Merged
Merged
Conversation
…ints around the file cache Each Mamba layer's staged recurrent states (the next convolution state and the final SSM state) feed nothing on the residual stream, so MLX evaluated them after the whole trunk and every layer's padded convolution input and SSD contributions stayed alive until the chunk ended (3.2 GB at 2,048 tokens). cbv2Forward now makes them dependencies of the layer's output, so they are computed and their inputs released within the layer. Values and order of arithmetic are unchanged. M5 Ultra, full checkpoint: a 24K-token prompt grows MLX active memory by 2.62 GiB instead of 5.63 GiB (process footprint 1.84 instead of 4.87), four parallel 12K prompts by 5.31 instead of 9.18 GiB; greedy outputs identical. ModelOptTensorFile reads each shard with F_NOCACHE and no read-ahead: the shard is hashed and then staged into memory the model owns, and through the file cache a second copy of the checkpoint stayed resident until memory pressure compressed the loaded weights.
This was referenced Oct 21, 2026
Merged
Author
|
Stack status: latest performance state (2026-10-21)
Measured on the M5 Ultra, full checkpoint, production flags, at the #1531 pin with no overrides:
The decode changes, the NAX expert kernels, the fused expert route and the dense NAX projections are bit-identical to the MLX NAX path. The chunked NAX Mamba SSD is not, and passes the accuracy-vs-truth gate (top-1 within 0.05 pts of shipped, perplexity within +0.1% of shipped). Measured and not shipped: grouped-GEMM M5 retune, multi-row decode expert gather, Phase C expert tilings, and keeping Mamba in_proj on MLX (no gain). |
jonathan308
added a commit
to Layr-Labs/d-inference
that referenced
this pull request
Oct 21, 2026
…swift-lm#318 squash-merged; same tree as a3dbc56d)
This was referenced Oct 22, 2026
javiech1
pushed a commit
to javiech1/mlx-swift-lm
that referenced
this pull request
Oct 24, 2026
Adds a basic Swift model conversion API for quantizing safetensors-backed LLMs through MLXLMCommon and LLMModelFactory. Fix Layr-Labs#266 .
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
NemotronHMamba2Mixer.cbv2Forwardnow makes them dependencies of the layer output (depends(input:dependencies:)), so they are computed, and their inputs freed, within the layer. Values and arithmetic order are unchanged.ModelOptTensorFilereads each shard withF_NOCACHEand no read-ahead. The shard is hashed and then staged into model-owned memory; through the file cache, a second copy of the checkpoint stayed resident until memory pressure compressed the loaded weights.Measured (M5 Ultra, full Nemotron 3.5 Super NVFP4 checkpoint)
prefillActivationBoundByteskeeps its measured value until it is re-measured; the doc comment now explains where the peak came from.Used by Layr-Labs/d-inference#1528 (pinned at
a3dbc56d).Testing
advertisedTokenBudgetFitsTheLedgerBesideTheOwnerReservations(307 MB over under full parallel load), passes when run alone and passes in #1528's CI. It's a provider ledger test, unrelated to this change.swift-format formatmakes no changes.