Skip to content

cuda: opt-in KV pool sizing after warm-up for dense Qwen3.5 - #4591

Merged
ashhart merged 4 commits into
mainfrom
lead/e191-pool-after-warmup
Nov 23, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/e191-pool-after-warmup

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

TF_CUDA_POOL_AFTER_WARMUP=1 (opt-in, default off) lets dense Qwen3.5 on CUDA size its KV page pool a second time, after warm-up, from the free memory it then measures, instead of keeping only the pool planned before warm-up.

  • Today the pool is planned after the family opens, but some warm-up, pricing and graph capture happens after that plan, so the first plan has to leave room for it. With the switch, once warm-up is done, the engine drains its stream, probes free memory through the same reserve, cap and OS rule, and grows the still-empty pool up to what the planner's context windows can use. It never shrinks the pool or takes the reserve.
  • It only acts when the pool is empty and nothing holds it: all streams on pages, device KV, TP=1, no vision or training, no retained prompt cache (--prompt-cache-gib 0). Any other mode keeps today's path with the switch set.
  • The old empty pool is closed and the family's own attach builds the larger one; no live page moves. Graph tables are restaged each forward, so captured graphs stay valid. A final probe after growth refuses the start if memory changed meanwhile.
  • /memory and /v1/memory report the decision (device.pool_after_warmup: measured free, reserve, room, page counts before and after), and the start-up line appends it. Off or ineligible, both are unchanged.

No kernel, arithmetic, sampling or verification change: tokens cannot change, only how many pages exist.

Checks

  • test-cuda-pool-after-warmup-host (23 cases: grow and stay decisions, reserve, cap, refusal and overflow edges, live leases and promises blocking replacement) and test-cuda-pool-report-host (45) pass; compile-cuda-tests for Linux compiles; fmt, ast-check, the 600-line cap; no pinned file changes.

Still to run (before landing)

On a GB10, Qwen3.8-27B with DFlash2 at --parallel 4 --context 65536 --prompt-cache-gib 0: main, this PR off, and this PR on. Start-up line and /memory for each; token capacity on, level off; tokens equal across the three at levels 1, 2 and 4.

@ashhart

ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

GB10 A/B with the switch on (Qwen3.8-27B MLX 4-bit with its DFlash2 drafter; base = this PR with the switch off, new = on via a local flip-default commit; two runs each arm):

  • Decode is level, as expected for a pool change: every sweep cell at 1, 2 and 4 streams, chat and code, temperature 0 and 1, is within 0.1% (for example code at 4 streams 186.6 -> 186.6, chat at 4 streams 141.2 -> 141.2).
  • Startup: the switch-on server logs calibration=36.420s where the switch-off one logs 0.000s, with load, reserve and warm-ups the same. So turning it on costs about 36 s at every start.
  • At the default log level neither arm says how many KV pages the pool holds, so this run can't show what the second sizing gained.

Two asks before it can go further: log the pool's page count before and after the second sizing (one info line), and say why the calibration reruns. If the lane prices don't depend on the pool's size, the second sizing shouldn't trigger it. Then the number that decides it is the gain in pages (or in the longest context that fits at a given --parallel) against that startup cost.

(Our chat resume cell didn't reach the prompt cache in either arm on this setup, so it reports no resume numbers; that is our harness, not this PR.)

  • Synthena

@ashhart
ashhart force-pushed the lead/e191-pool-after-warmup branch from b18b418 to ff5812c Compare November 23, 2026 06:30
@ashhart
ashhart merged commit c488582 into main Nov 23, 2026
12 checks passed
@ashhart
ashhart deleted the lead/e191-pool-after-warmup branch November 23, 2026 06:30
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.

1 participant