Repository navigation
fix(engine): keep a prefill chunk's working memory out of the moe-cache-auto plan - #930
Draft
RaunakGengiti2725 wants to merge 1 commit into
Draft
RaunakGengiti2725 wants to merge 1 commit into
RaunakGengiti2725 wants to merge 1 commit into
Conversation
…he-auto plan The auto plan gave every byte of memory_ratio x free to expert slots and KV and had no term for a prefill's temporaries, so on a small card a long prompt ended the server with CUDA out of memory in a GatedDeltaNet layer. The plan now leaves one chunk's working memory, counted from tensor shapes, out of both caches: KV above its floor pays first, expert slots pay the rest, and at the default floor KV keeps room for a prompt of one chunk with 1024 tokens of reply. A typed cache size gets a warning instead.
RaunakGengiti2725
force-pushed
the
pr/prefill-working-memory
branch
from
November 27, 2026 22:01
4745dc9 to
764253a
Compare
This branch has not been 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.
Fixes #401.
--moe-cache-autoleft no room for prefill temporaries, so on a tight card a long prompt crashed the server (CUDA out of memory, GatedDeltaNet layer). On GatedDeltaNet models the plan now keeps one--max-prefill-lengthchunk's working memory free, from KV above its floor, then expert slots; with the default--kv-reserve-tokensit also aims to hold KV for one chunk plus 1024 reply tokens. Startup warns when less is free.A/B against main 2fb371e (measured at 26be467; later: comments, a test bound). RTX 5090 (400 W), AMD Ryzen 9 7950X, driver 595.91.07, 12 GiB left free (holder process). Both arms:
ft serve --model nvidia/Qwen3.6-35B-A3B-NVFP4 --enable-timings-report(--moe-strategy autotakes offload with--moe-cache-auto). Per fresh server: a short request (16 reply tokens), one 8,192-token prompt, greedy, thinking off, 128 reply tokens, a short follow-up; 2 rounds reversed.The branch logged "keeps 1.03 GiB free for a prefill chunk of 8192 tokens". Main failed so in 2 of 2 rounds; the branch answered and stayed up in 2 of 2.
Tests (
tests/engine/test_cache_budget.py, CPU only) cover payment order, floors, the 3,785-token count staying over 0.43 GiB, KDA and non-GatedDeltaNet models, and typed sizes; dropping the reserve in cache_budget.py turns 10 of 42 red.Rebased on 8a5b38a. Main's failure may now show as a 500 error instead of a hang (#958); not re-measured.
Tested on real hardware by me.