Scenario
A pool at 5 percent, and the server still died
RolesLLM Product EngineeringInference EngineeringDeveloper Experience and Education
- Engine
- SGLang 0.5.22 with the MLX backend
- Model
- mlx-community/Qwen3-0.6B-4bit
- Hardware
- a laptop with unified memory, shared with the other programs of a desktop session
Situation
A developer advocate prepares a workshop demo on a laptop. The server runs a small quantized model on the MLX backend, started with the model path and nothing about memory. Single requests work, and a few people at once work. To show what the laptop can do, the advocate runs the benchmark client with 32 requests in flight at once.
The whole server dies. The log ends with a Metal error, Insufficient Memory, and the process tree is gone. The decode lines right before the crash show 32 running requests, with token usage at 0.05. The advocate concludes that the laptop cannot serve 32 users and plans to show the demo at four.
Questions
- The pool was almost empty when the server died. Where was the memory, if not in the pool?
- Two starts of the same command gave two pool sizes. What changed between them?
- What rule produced the fraction, and what does that rule assume about the machine?
- Which flag fixes this, what value did the capture kit use, and what did the pool look like after?
- What proves the fix: a startup line or a benchmark result?
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the pool line of the first start
Read sys_available, kv_budget and pool_size.
# run 1 startup
[2026-10-16 13:30:31] Auto-sized attention KV pool: sys_available=27.81 GB, mlx_limit=51.8 GB, mlx_used=0.31 GB, kv_budget=24.25 GB, bytes_per_slot=114688, pool_size=227022Source: manuals/sglang-101/capture/out/oom-exploratory.log, lines 3-4
the pool lines of the second start, minutes later
Compare sys_available and kv_budget with the first start, and read the resolved fraction.
# run 2 startup
'mem_fraction_static': 0.872
[2026-10-16 13:38:58] Auto-sized attention KV pool: sys_available=38.29 GB, mlx_limit=51.8 GB, mlx_used=0.31 GB, kv_budget=33.39 GB, bytes_per_slot=114688, pool_size=312581
[2026-10-16 13:38:58] MLX stub: initialized minimal pools (max_total_num_tokens=312581, max_running_requests=4096, zero GPU KV cache allocation)
[2026-10-16 13:39:00] max_total_num_tokens=312581, chunked_prefill_size=4096, max_prefill_tokens=16384, max_running_requests=4096, context_len=40960, available_gpu_mem=37.92 GB
[2026-10-16 13:39:02] MlxAttentionKVPool: 312582 slots x 28 layers x 8 heads x 128 dim, dtype=mlx.core.bfloat16, ~34188.7 MBSource: manuals/sglang-101/capture/out/oom-exploratory.log, lines 5-10
the benchmark at a concurrency of 32, and the crash
Read token usage in the decode lines before you read the RuntimeError.
# run 2, benchmark at --max-concurrency 32
[2026-10-16 13:42:51] Decode batch, #running-req: 32, #token: 16095, token usage: 0.05, cuda graph: False, gen throughput (token/s): 579.49, #queue-req: 0
[2026-10-16 13:42:53] Decode batch, #running-req: 32, #token: 16095, token usage: 0.05, cuda graph: False, gen throughput (token/s): 564.55, #queue-req: 0
[2026-10-16 13:42:55] Prefill batch, #new-seq: 1, #new-token: 511, #cached-token: 0, token usage: 0.00, #running-req: 0, #queue-req: 9, #pending-token: 0, cuda graph: False, input throughput (token/s): 66.85
RuntimeError: [METAL] Command buffer execution failed: Insufficient Memory (00000008:kIOGPUCommandBufferCallbackErrorOutOfMemory).
[2026-10-16 13:42:57] SIGQUIT received. signum=None, frame=None. It usually means one child failed.
[2026-10-16 13:42:57] Sleeping 5 seconds before crash diagnostics to let GPU activity settle.
[2026-10-16 13:43:02] No live scheduler processes found; skipping py-spy and CUDA coredump.
[2026-10-16 13:43:02] kill_process_tree called: parent_pid=81559, include_parent=True, pid=81559Source: manuals/sglang-101/capture/out/oom-exploratory.log, lines 11-20
why the two starts sized the pool differently
One paragraph from the manual.
Nothing changed in SGLang between the runs. Other programs on the Mac used less memory at the second start, so `sys_available` grew from 27.81 GB to 38.29 GB. The pool grew with it, from 24.25 GB to 33.39 GB. Both budgets are 87.2 percent of the free memory, because the automatic `mem_fraction_static` resolved to 0.872.Source: manuals/sglang-101/sections/3-2-mem-fraction-static-and-startup-sizing.md, lines 26-26
how the manual reads the crash
Start with token usage.
Read `token usage: 0.05` first. Thirty-two requests held 16,095 tokens, which is 5 percent of a 312,581-token pool. The pool reserved 33 GB and used under 2 GB of it. The activations of the next forward pass needed memory outside the pool, and the operating system had none left. One failed command buffer took down the scheduler, and the server killed its whole process tree.Source: manuals/sglang-101/sections/3-2-mem-fraction-static-and-startup-sizing.md, lines 43-43
the pool line of the kit's server, with an explicit fraction
Divide kv_budget by sys_available.
[2026-10-16 13:58:03] Auto-sized attention KV pool: sys_available=48.49 GB, mlx_limit=51.8 GB, mlx_used=0.31 GB, kv_budget=19.39 GB, bytes_per_slot=114688, pool_size=181574Source: manuals/sglang-101/capture/out/server-default.log, lines 61-61
the same benchmark against the kit's server
Read the concurrency and the count of successful requests.
Max request concurrency: 32
Successful requests: 128
Benchmark duration (s): 64.83 Source: manuals/sglang-101/capture/out/bench-random-c32.txt, lines 14-16
The answer
Show the walkthrough
- Read the decode lines before the error. Thirty-two requests held 16,095 tokens, which is 5 percent of a pool of 312,581 tokens. The pool had reserved 33 GB and used under 2 GB of it. The next prefill needed activation memory outside the pool, but the operating system had none left to give. One failed command buffer took down the scheduler, the parent received a SIGQUIT, and it killed the process tree. The server did not run out of KV cache. It ran out of everything else.
- Compare the two startup lines. The first start saw 27.81 GB of available system memory and gave the pool a budget of 24.25 GB, for 227,022 tokens. The second start, minutes later, saw 38.29 GB and gave 33.39 GB, for 312,581 tokens. Nothing changed in SGLang. Other programs on the laptop used less memory at the second start, so the snapshot of free memory was larger and the pool grew with it.
- Read the rule. Both budgets are 87.2 percent of the free memory, because the automatic fraction resolved to 0.872. On this backend the rule takes the smaller of two numbers, a fraction of the Metal working set and a fraction of the system memory available right now, and the second one is the snapshot that moved. The rule assumes that the machine belongs to SGLang for the life of the server. A laptop with a browser and an editor open is not that machine.
- Read the fix in the kit's start. The capture kit passes
--mem-fraction-static 0.4. Its startup line shows a snapshot of 48.49 GB and a budget of 19.39 GB, which is 0.4 of the snapshot, for a pool of 181,574 tokens. That pool still holds far more than 32 requests of 640 tokens need, so the smaller pool cost nothing in this workload. - Prove it with the same load. Against the kit's server, the benchmark at a concurrency of 32 finished all 128 requests in 64.83 seconds. The startup line shows the split. The benchmark result shows that the server survived the load that killed it before.
Show the resolution
The laptop was never the limit. The automatic fraction took 87 percent of the free memory for a pool that the workload used at 5 percent, and left the activations of the next prefill with nothing. With --mem-fraction-static 0.4 the pool shrank to 181,574 tokens and the same benchmark completed 128 of 128 requests at a concurrency of 32.
The demo now starts with the fraction set, and the advocate reads two lines after every change: the kv_budget on the pool line and max_total_num_tokens on the settings line. On this backend the cache memory metric reads 0.0, because the MLX pool is allocated outside the accounting that the metric reads, so the pool log line is the number to trust.
Show the wrong turns
“The laptop cannot serve 32 users.”
The pool held 312,581 tokens and 32 requests used 5 percent of it. The memory ran out outside the pool, where the fraction left too little.
“Raise the fraction so the pool is bigger.”
The pool was the cause. It took 87 percent of the free memory and starved the activations. Lower it.
“Restart the server, the second start had more memory.”
The snapshot changes with the other programs on the machine, and the next start can find less. Set the fraction so the pool does not depend on the snapshot.
“Set the fraction to 0.95 to be safe.”
A fraction of 0.95 leaves 5 percent for activations, and issue #39675 in the manual reports exactly that failure on the first prefill.
Show the general rule
A pool that is almost empty when the process dies tells you the memory went somewhere the pool does not count. On a machine that runs anything else, a fraction computed from a snapshot of free memory is a bet on how the rest of the machine behaves for the life of the server. Set the share yourself, read the two startup lines that show the result, and prove a memory fix with the load that broke it, not with a start that succeeded.
Taught in
The memory page of SGLang 101 records the crash and the fix in the crash we recorded and our position: set the fraction yourself on any shared machine.