[GH-ISSUE #4098] [Engine] --prefill-head-alias: every request fails with "native head upload: out of memory" #1789

Closed
opened 2026-11-04 01:54:05 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @PierpaoloPernici on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4098

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

With --prefill-head-alias --short-read 0 on a 32 GB card, the model starts and reaches "ready", then every request fails with HTTP 400:

{"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}}

and the server prints:

[strata] the engine reported an error: restoring the native output head failed: native head upload: out of memory
[strata] done: 0 tokens in 1 s (no speed) (error, cancel=False)

The prompt is read (no prefill error), then the head cannot be put back. It is not a slow path and not the #2065 memory-pressure warning: the request simply does not complete, at any context size I tried, on a card whose expert cache is filled to the reserve on purpose (276 MiB free at request start).

The numbers say the flag's own free-VRAM figure is about 426 MiB optimistic while the head is 497 MiB (521 472 000 bytes), so any --vram-reserve-mib below about 925 MiB fails. --vram-reserve-mib 960 — the value the engine itself suggests in the #2065 warning — is enough. --vram-reserve-mib 700 (what setup wrote into this install) and 832 are not.

--vram-reserve-mib "free" at the head-alias line real free, "with everything loaded" head needs 497 MiB result
700 702 MiB 276 MiB no room HTTP 400, head upload OOM
700, --max-context 16384 702 MiB 276 MiB no room HTTP 400, same message
700, --vision removed 701 MiB – no room HTTP 400, same message
832 (with --kv-grow) 832 MiB 406 MiB no room HTTP 400, same message
960 962 MiB 536 MiB fits HTTP 200
2000 2004 MiB 1578 MiB fits HTTP 200

Two things are worth separating:

  1. The request failure (the bug above). The restore is not guaranteed any VRAM: the free-VRAM accounting the alias uses at start does not match what is free after the model is loaded (the gap is consistently ~426 MiB in the four runs above, with and without --kv-grow), so a reserve that passes the start-up check cannot hold the 497 MiB head at the end of a prompt read.
  2. A client that retries turns it into an engine restart loop. tools/ab_engine.py posts one warm-up answer before it treats the server as ready; against this config it made the server restart the engine 34 times in 8 min 44 s (34 "engine started" lines in that arm's log, 13:00:53 to 13:09:37) and never got ready. Worth knowing because a bug that is one failed request in the log looks like a hung install from the outside.

Smallest steps or command that reproduce it

From a source checkout with a Qwen3.8-Flash-Next IQ3_S pack (the flags below are the install's own strata-<model>.json, plus the two the alias needs):

# --prefill-head-alias is a --serve flag and needs --short-read 0
<engine> --serve --pack <pack> --native <shard1.gguf> --ple-gguf <shard2.gguf> \
  --expert-profile expert-profile.bin --expert-cache auto --prefill auto \
  --spec 4 --mtp <mtp dir> --max-context 262144 --kv int8 --vision \
  --vram-reserve-mib 700 --pcie-frac 0.35 --spec-min-p 0.55 \
  --adapt-every 1 --adapt-swaps 80 --adapt-decay 0.97 \
  --short-read 0 --prefill-head-alias

# then one request (any prompt):
curl -s http://127.0.0.1:PORT/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"messages":[{"role":"user","content":"Say hi."}],"max_tokens":16,"temperature":0}'
# -> {"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}}

Same with --vram-reserve-mib 960 instead of 700: the same request answers 200. Reproduced 3/3 at 700, 1/1 at 832; works 1/1 at 960 and 1/1 at 2000.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.5 (source checkout 41cf05a0), engine 0.1.50 (engine/strata --version -> strata 0.1.50), built 2026-10-25.

Graphics card, memory and system

NVIDIA GeForce RTX 5090, 32 GiB VRAM (compute capability 12.0), driver 615.78.08 · AMD Ryzen 7 9800X3D, 8 cores / 16 threads, 62.2 GiB RAM · Linux 7.3.0-5-cachyos.

Model, size and settings

Qwen3.8-Flash-Next GSQ-RCO IQ3_S (2 shards: main + PLE table), 262144-token context, --kv int8, --expert-cache auto (expert cache 10 162 slots / 19.28 GiB; 11 790 slots / 22.37 GiB with --kv-grow), MTP draft layer (--spec 4 --spec-min-p 0.55), pictures on, --vram-reserve-mib 700 in the install's config. STRATA_DEQUANT_WIDE=1, STRATA_GDN_CHUNKED=1.

Logs

Start-up, reserve 700 (fails):

strata generate: --prefill-head-alias: the 521472000-byte output head is prompt workspace
strata generate: expert cache auto: 20.45 GiB free, 700 MiB reserved (+0 MiB for the draft head) -> 7969 slots
strata serve: prompt chunk head alias: 2048 tokens with 20230 MiB borrowed and 702 MiB free
strata serve: 276 MiB of VRAM free with everything loaded
strata serve: WARNING: only 276 MiB of VRAM free at the start of this request (below 512 MiB): ... (#2065) Add --vram-reserve-mib 960 to the config's args ...

Same build, reserve 960 (works):

strata serve: prompt chunk head alias: 2048 tokens with 19971 MiB borrowed and 962 MiB free
strata serve: 536 MiB of VRAM free with everything loaded

Request failure (reserve 832, with --kv-grow):

{"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}}
[strata] the engine reported an error: restoring the native output head failed: native head upload: out of memory
[strata] done: 0 tokens in 1 s (no speed) (error, cancel=False)

What I ruled out (each one measured, one flag changed per run)

  • --kv-grow is not the trigger. It fails without it (reserve 700) and with it (reserve 832), so the elastic K/V is not what breaks the restore.
  • Not the vision model. Removing --vision from the args fails the same way.
  • Not the 262144-token context. --max-context 16384 fails the same way (same 276 MiB free).
  • It is the reserve. The only difference between a failing and a working run is --vram-reserve-mib: 700/832 fail, 960/2000 work.

Duplicates I checked first

  • #620 (closed): the same message text, but at startup, engine 0.1.38 on Windows with the desktop on an iGPU. Here the engine starts and reaches ready; the message comes from the head restore after a prompt read.
  • #2724 (closed in the 0.2.0-beta tracker reset): the same flag, but the 2048-token chunk cost and the "reloaded at another address" abort. Different failure point; the chunk cap is reproduced here.
  • Nothing open mentions native head upload together with --prefill-head-alias.

Why I am filing it rather than commenting on #2724

#2724 reported two other things about this flag (a 3x slower cold prefill at 2048-token chunks, and the abort "the output head was reloaded at another address, so the captured verify graphs would read freed memory") and was closed in the 0.2.0-beta tracker reset. This is a different message and a different point in the code (a plain out of memory from the head upload, not an address change), and it makes the flag unusable at the reserve values this install has. The 8192 -> 2048 prompt chunk cap that #2724 measured is still there and is reproduced here: prompt chunk head alias: 2048 tokens with 20230 MiB borrowed.

Reading the code (unconfirmed static analysis, not a proven cause)

src/program/generate.cpp ~14172-14180, after the prompt read:

if (!refill(err)) { ... }                 // the borrowed slots go back to the expert cache
if (o.prefill_head_alias) {
    sp.reset();                           // the prompt scratch is freed
    if (!native_head.load(o.native_head_shards, g.n_embd, n_vocab, err)) {
        std::printf("ERR restoring the native output head failed: %s\n", err.c_str());

The restore happens after refill() has given the lent slots back to the cache and after the scratch is released, so at that point the only room left is the reserve. The start-up line that decides how much the alias may borrow (prompt chunk head alias: N tokens with X MiB borrowed and Y MiB free) says 702 MiB free while the engine itself reports 276 MiB free once everything is loaded, which is less than the 521 472 000-byte head. I have not stepped this in a debugger; it is a reading of the order of the calls.

What would fix it, in my view

Either reserve the head's own bytes when the alias is on (so the start-up "free" figure cannot be spent by the prompt borrow), or fall back to keeping the head resident instead of failing the request. A line at start-up saying "the alias needs --vram-reserve-mib at least N on this card" would have saved me the four runs above.

Originally created by @PierpaoloPernici on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4098 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened With `--prefill-head-alias --short-read 0` on a 32 GB card, the model starts and reaches "ready", then **every request fails with HTTP 400**: ```json {"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}} ``` and the server prints: ``` [strata] the engine reported an error: restoring the native output head failed: native head upload: out of memory [strata] done: 0 tokens in 1 s (no speed) (error, cancel=False) ``` The prompt is read (no prefill error), then the head cannot be put back. It is not a slow path and not the #2065 memory-pressure warning: the request simply does not complete, at any context size I tried, on a card whose expert cache is filled to the reserve on purpose (276 MiB free at request start). The numbers say the flag's own free-VRAM figure is about **426 MiB optimistic** while the head is **497 MiB** (521 472 000 bytes), so any `--vram-reserve-mib` below about 925 MiB fails. `--vram-reserve-mib 960` — the value the engine itself suggests in the #2065 warning — is enough. `--vram-reserve-mib 700` (what setup wrote into this install) and `832` are not. | `--vram-reserve-mib` | "free" at the head-alias line | real free, "with everything loaded" | head needs 497 MiB | result | | ---: | ---: | ---: | --- | --- | | 700 | 702 MiB | **276 MiB** | no room | HTTP 400, head upload OOM | | 700, `--max-context 16384` | 702 MiB | 276 MiB | no room | HTTP 400, same message | | 700, `--vision` removed | 701 MiB | – | no room | HTTP 400, same message | | 832 (with `--kv-grow`) | 832 MiB | 406 MiB | no room | HTTP 400, same message | | **960** | 962 MiB | **536 MiB** | fits | **HTTP 200** | | 2000 | 2004 MiB | 1578 MiB | fits | HTTP 200 | Two things are worth separating: 1. **The request failure (the bug above).** The restore is not guaranteed any VRAM: the free-VRAM accounting the alias uses at start does not match what is free after the model is loaded (the gap is consistently ~426 MiB in the four runs above, with and without `--kv-grow`), so a reserve that passes the start-up check cannot hold the 497 MiB head at the end of a prompt read. 2. **A client that retries turns it into an engine restart loop.** `tools/ab_engine.py` posts one warm-up answer before it treats the server as ready; against this config it made the server restart the engine **34 times in 8 min 44 s** (34 "engine started" lines in that arm's log, 13:00:53 to 13:09:37) and never got ready. Worth knowing because a bug that is one failed request in the log looks like a hung install from the outside. ### Smallest steps or command that reproduce it From a source checkout with a Qwen3.8-Flash-Next IQ3_S pack (the flags below are the install's own `strata-<model>.json`, plus the two the alias needs): ```sh # --prefill-head-alias is a --serve flag and needs --short-read 0 <engine> --serve --pack <pack> --native <shard1.gguf> --ple-gguf <shard2.gguf> \ --expert-profile expert-profile.bin --expert-cache auto --prefill auto \ --spec 4 --mtp <mtp dir> --max-context 262144 --kv int8 --vision \ --vram-reserve-mib 700 --pcie-frac 0.35 --spec-min-p 0.55 \ --adapt-every 1 --adapt-swaps 80 --adapt-decay 0.97 \ --short-read 0 --prefill-head-alias # then one request (any prompt): curl -s http://127.0.0.1:PORT/v1/chat/completions -H 'Content-Type: application/json' \ -d '{"messages":[{"role":"user","content":"Say hi."}],"max_tokens":16,"temperature":0}' # -> {"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}} ``` Same with `--vram-reserve-mib 960` instead of `700`: the same request answers 200. Reproduced 3/3 at 700, 1/1 at 832; works 1/1 at 960 and 1/1 at 2000. ### Reproduction status Reproduced locally ### Strata version Strata 0.2.5 (source checkout `41cf05a0`), **engine 0.1.50** (`engine/strata --version` -> `strata 0.1.50`), built 2026-10-25. ### Graphics card, memory and system NVIDIA GeForce RTX 5090, 32 GiB VRAM (compute capability 12.0), driver 615.78.08 · AMD Ryzen 7 9800X3D, 8 cores / 16 threads, 62.2 GiB RAM · Linux 7.3.0-5-cachyos. ### Model, size and settings Qwen3.8-Flash-Next GSQ-RCO **IQ3_S** (2 shards: main + PLE table), 262144-token context, `--kv int8`, `--expert-cache auto` (expert cache 10 162 slots / 19.28 GiB; 11 790 slots / 22.37 GiB with `--kv-grow`), MTP draft layer (`--spec 4 --spec-min-p 0.55`), pictures on, `--vram-reserve-mib 700` in the install's config. `STRATA_DEQUANT_WIDE=1`, `STRATA_GDN_CHUNKED=1`. ### Logs Start-up, reserve 700 (fails): ``` strata generate: --prefill-head-alias: the 521472000-byte output head is prompt workspace strata generate: expert cache auto: 20.45 GiB free, 700 MiB reserved (+0 MiB for the draft head) -> 7969 slots strata serve: prompt chunk head alias: 2048 tokens with 20230 MiB borrowed and 702 MiB free strata serve: 276 MiB of VRAM free with everything loaded strata serve: WARNING: only 276 MiB of VRAM free at the start of this request (below 512 MiB): ... (#2065) Add --vram-reserve-mib 960 to the config's args ... ``` Same build, reserve 960 (works): ``` strata serve: prompt chunk head alias: 2048 tokens with 19971 MiB borrowed and 962 MiB free strata serve: 536 MiB of VRAM free with everything loaded ``` Request failure (reserve 832, with `--kv-grow`): ``` {"error": {"type": "invalid_request_error", "message": "restoring the native output head failed: native head upload: out of memory"}} [strata] the engine reported an error: restoring the native output head failed: native head upload: out of memory [strata] done: 0 tokens in 1 s (no speed) (error, cancel=False) ``` ## What I ruled out (each one measured, one flag changed per run) - **`--kv-grow` is not the trigger.** It fails without it (reserve 700) and with it (reserve 832), so the elastic K/V is not what breaks the restore. - **Not the vision model.** Removing `--vision` from the args fails the same way. - **Not the 262144-token context.** `--max-context 16384` fails the same way (same 276 MiB free). - **It is the reserve.** The only difference between a failing and a working run is `--vram-reserve-mib`: 700/832 fail, 960/2000 work. ## Duplicates I checked first - **#620** (closed): the same message text, but at **startup**, engine 0.1.38 on Windows with the desktop on an iGPU. Here the engine starts and reaches ready; the message comes from the head restore after a prompt read. - **#2724** (closed in the 0.2.0-beta tracker reset): the same flag, but the 2048-token chunk cost and the "reloaded at another address" abort. Different failure point; the chunk cap is reproduced here. - Nothing open mentions `native head upload` together with `--prefill-head-alias`. ## Why I am filing it rather than commenting on #2724 #2724 reported two other things about this flag (a 3x slower cold prefill at 2048-token chunks, and the abort "the output head was reloaded at another address, so the captured verify graphs would read freed memory") and was closed in the 0.2.0-beta tracker reset. This is a different message and a different point in the code (a plain `out of memory` from the head upload, not an address change), and it makes the flag unusable at the reserve values this install has. The 8192 -> 2048 prompt chunk cap that #2724 measured is still there and is reproduced here: `prompt chunk head alias: 2048 tokens with 20230 MiB borrowed`. ## Reading the code (unconfirmed static analysis, not a proven cause) `src/program/generate.cpp` ~14172-14180, after the prompt read: ```cpp if (!refill(err)) { ... } // the borrowed slots go back to the expert cache if (o.prefill_head_alias) { sp.reset(); // the prompt scratch is freed if (!native_head.load(o.native_head_shards, g.n_embd, n_vocab, err)) { std::printf("ERR restoring the native output head failed: %s\n", err.c_str()); ``` The restore happens after `refill()` has given the lent slots back to the cache and after the scratch is released, so at that point the only room left is the reserve. The start-up line that decides how much the alias may borrow (`prompt chunk head alias: N tokens with X MiB borrowed and Y MiB free`) says 702 MiB free while the engine itself reports 276 MiB free once everything is loaded, which is less than the 521 472 000-byte head. I have not stepped this in a debugger; it is a reading of the order of the calls. ## What would fix it, in my view Either reserve the head's own bytes when the alias is on (so the start-up "free" figure cannot be spent by the prompt borrow), or fall back to keeping the head resident instead of failing the request. A line at start-up saying "the alias needs --vram-reserve-mib at least N on this card" would have saved me the four runs above.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".
  • Fill in "Desktop app, Terminal or source?".
  • Fill in "Reproduction status".
  • Fill in "Strata version".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6398019814 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". - [ ] Fill in "Desktop app, Terminal or source?". - [ ] Fill in "Reproduction status". - [ ] Fill in "Strata version". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6398035147 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks, this follows the format now.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6659988568 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1789
No description provided.