Skip to content

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
FlashML-org:mainfrom
RaunakGengiti2725:pr/prefill-working-memory
Draft

RaunakGengiti2725 wants to merge 1 commit into
FlashML-org:mainfrom
RaunakGengiti2725:pr/prefill-working-memory

Conversation

@RaunakGengiti2725

@RaunakGengiti2725 RaunakGengiti2725 commented Nov 20, 2026 •

Copy link
Copy Markdown

Fixes #401.

--moe-cache-auto left 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-length chunk's working memory free, from KV above its floor, then expert slots; with the default --kv-reserve-tokens it 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 auto takes 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.

main this PR
8,192-token request no answer (900 s client timeout); CUDA out of memory, "Backend worker is gone" HTTP 200, 128 tokens, 1.3 s
follow-up request connection refused HTTP 200
plan 3454 expert slots, 8216 KV tokens 2821 expert slots, 9220 KV tokens

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.

…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
RaunakGengiti2725 force-pushed the pr/prefill-working-memory branch from 4745dc9 to 764253a Compare November 27, 2026 22:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--moe-cache-auto leaves no room for prefill: boots and serves decode, then the first 8k prefill OOMs and kills the worker (NVFP4 dense)

1 participant