[GH-ISSUE #3364] [Engine] expert-cache auto does not reserve memory for --batch slots; MTP allocation fails and the engine exits with code 1 #1365

Open
opened 2026-11-04 01:50:41 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @zhq445078388 on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3364

Strata issue draft — expert-cache auto ignores --batch slot sessions

Title

expert-cache auto does not reserve memory for --batch slot sessions; MTP allocation then fails and the engine exits with code 1

Summary

With a long context (--max-context 1048576) and --batch 4, Strata's
expert-cache auto fills the expert cache first. The four batch slot sessions
need ~1.27 GiB each per card, but by the time they are allocated each card has
0.00 GiB free. The engine then falls back to 1/0 slot sessions, and the
following MTP allocation fails:

mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown

The serve layer reports:

RuntimeError: the engine exited before it was ready

and the process exits with code 1. The engine should either reserve the
batch-slot memory before sizing the expert cache, or degrade safely instead of
exiting.

Environment

  • Strata: 0.1.45.3 Windows HIP build
    (strata-engine-0.1.45.3-windows-x86_64-hip-rx9070.tar.gz,
    release tag v0.2.0-beta)
  • OS: Windows 11
  • GPUs: 2× AMD Radeon AI PRO R9700 (gfx1201), 32 GB each
  • RAM: 64 GB class (63.4 GiB visible)
  • Model: Qwen3.8-Flash-Next GSQ-RCO-Abliterated IQ3_S, native context 262144
  • KV: --kv int8, --kv-resident 32768
  • Layer split: --layer-split auto
  • Experts: --expert-cache auto --mmap-experts
  • MTP: enabled (--mtp <strata-mtp/rt> --mtp-hnorm stream)
  • Vision: --vision
  • Serve config: "parallel": 4 → engine gets --batch 4

The model path is omitted here; full local logs can be attached.

Exact engine arguments

strata.exe --serve
  --pack <model>/strata-pack/IQ3_S
  --native <model>/...-00001-of-00002.gguf
  --ple-gguf <model>/...-00002-of-00002.gguf
  --expert-profile <model>/strata-pack/IQ3_S/expert-profile.bin
  --expert-cache auto
  --prefill auto
  --spec 4 --spec-min-p 0.5
  --kv-resident 32768
  --mtp <model>/strata-mtp/rt
  --mtp-hnorm stream
  --max-context 1048576
  --rope-scaling yarn --rope-scale 4 --yarn-orig-ctx 262144
  --kv int8
  --ple-io mmap
  --vram-reserve-mib 500
  --vram-reserve-later-mib 500
  --layer-split auto
  --mmap-experts
  --vision
  --batch 4

--batch 4 comes from the serve config's "parallel": 4.

Steps to reproduce

  1. Start the above configuration with the long-context model and "parallel": 4.
  2. Wait for model loading / layer-split selection to finish.
  3. Observe the batch-slot allocations and the final MTP failure.

Expected behavior

expert-cache auto should account for the memory needed by the requested
--batch N slot sessions before filling the expert cache, or it should
reduce the cache until the slots fit. If the requested batch size still cannot
fit, it should:

  • fall back to fewer slots (or serial) with a clear warning, and
  • keep MTP loading if only the batch-size request is impossible.

It should not terminate the engine with exit code 1.

Actual behavior

Relevant engine log, in order:

strata generate: layer split: CUDA1 holds its weights, session [26, 48) and the head; 24.58 GiB free
strata generate: --batch-groups auto: 2 groups of 2 slots
strata generate: WARNING: --batch 4: slot 1's session does not fit on CUDA0 (1.27 GiB each, 0.00 GiB free); 1 slot
strata generate: --batch: 1 slot sessions on CUDA0 (1.27 GiB each); 0.00 GiB free
strata generate: WARNING: --batch 4: slot 0's session does not fit on CUDA1 (1.26 GiB each, 0.00 GiB free); 0 slots
strata generate: --batch: 0 slot sessions on CUDA1 (1.26 GiB each); 0.00 GiB free
strata generate: WARNING: --batch is off: not two slot sessions fit (a smaller --max-context or KV streaming, --kv-resident, makes them smaller)
strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown

The serve layer then reports:

RuntimeError: the engine exited before it was ready

Process result: exit code 1.

Why this looks like an engine-side accounting/ordering bug

The expert cache is sized before the --batch slots are accounted for:

  1. expert-cache auto computes and fills the cache from the currently free VRAM.
  2. Only afterwards does the engine try to allocate the --batch 4 slot sessions.
  3. Each slot needs ~1.27 GiB per card at this context; zero memory is left.
  4. The batch silently degrades to 1/0 slots.
  5. MTP then fails its much smaller 110 MiB allocation, terminating the process.

The slot sessions are real VRAM consumers and are also visible in the engine's
own log; they should be part of the auto-cache calculation.

Contrast: same engine at a shorter context

At --max-context 65536 with --batch 2, the same model starts successfully:

strata generate: KV streaming: 32768 of 65536 cells per QSA layer in VRAM, the K/V in 0.39 GiB of pinned RAM
strata generate: --batch-groups auto: 2 groups of 1 slot
strata generate: --batch: 2 slot sessions on CUDA0 (0.32 GiB each); 25.38 GiB free
strata generate: --batch: 2 slot sessions on CUDA1 (0.32 GiB each); 24.90 GiB free

So the mechanism works when slot sessions fit; the problem is that auto cache
does not leave room for them at long context.

Possible fixes

  • Subtract batch_slots × per_slot_session before computing the expert cache.
  • Cap --batch to the number of slot sessions that fit after reserving MTP/vision,
    and emit a warning instead of failing MTP.
  • If the requested --batch cannot fit, fall back to serial or a smaller batch
    rather than exiting.
  • Alternatively, document that --batch N must be lowered manually for long
    contexts; currently the failure mode is an engine exit, not a usable warning.

Attachments to include

  • Base/logs/server-20261020-120736.log (full serve traceback)
  • relevant excerpt of Base/logs/strata-serve.log around the lines quoted above
  • the exact strata-config.console.json with "parallel": 4

Originally created by @zhq445078388 on GitHub (Oct 20, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3364 # Strata issue draft — `expert-cache auto` ignores `--batch` slot sessions ## Title `expert-cache auto` does not reserve memory for `--batch` slot sessions; MTP allocation then fails and the engine exits with code 1 ## Summary With a long context (`--max-context 1048576`) and `--batch 4`, Strata's `expert-cache auto` fills the expert cache first. The four batch slot sessions need ~1.27 GiB each per card, but by the time they are allocated each card has 0.00 GiB free. The engine then falls back to 1/0 slot sessions, and the following MTP allocation fails: ```text mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown ``` The serve layer reports: ```text RuntimeError: the engine exited before it was ready ``` and the process exits with code **1**. The engine should either reserve the batch-slot memory before sizing the expert cache, or degrade safely instead of exiting. ## Environment - Strata: `0.1.45.3` Windows HIP build (`strata-engine-0.1.45.3-windows-x86_64-hip-rx9070.tar.gz`, release tag `v0.2.0-beta`) - OS: Windows 11 - GPUs: 2× AMD Radeon AI PRO R9700 (gfx1201), 32 GB each - RAM: 64 GB class (63.4 GiB visible) - Model: Qwen3.8-Flash-Next GSQ-RCO-Abliterated IQ3_S, native context 262144 - KV: `--kv int8`, `--kv-resident 32768` - Layer split: `--layer-split auto` - Experts: `--expert-cache auto --mmap-experts` - MTP: enabled (`--mtp <strata-mtp/rt> --mtp-hnorm stream`) - Vision: `--vision` - Serve config: `"parallel": 4` → engine gets `--batch 4` The model path is omitted here; full local logs can be attached. ## Exact engine arguments ```text strata.exe --serve --pack <model>/strata-pack/IQ3_S --native <model>/...-00001-of-00002.gguf --ple-gguf <model>/...-00002-of-00002.gguf --expert-profile <model>/strata-pack/IQ3_S/expert-profile.bin --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --kv-resident 32768 --mtp <model>/strata-mtp/rt --mtp-hnorm stream --max-context 1048576 --rope-scaling yarn --rope-scale 4 --yarn-orig-ctx 262144 --kv int8 --ple-io mmap --vram-reserve-mib 500 --vram-reserve-later-mib 500 --layer-split auto --mmap-experts --vision --batch 4 ``` `--batch 4` comes from the serve config's `"parallel": 4`. ## Steps to reproduce 1. Start the above configuration with the long-context model and `"parallel": 4`. 2. Wait for model loading / layer-split selection to finish. 3. Observe the batch-slot allocations and the final MTP failure. ## Expected behavior `expert-cache auto` should account for the memory needed by the requested `--batch N` slot sessions **before** filling the expert cache, or it should reduce the cache until the slots fit. If the requested batch size still cannot fit, it should: - fall back to fewer slots (or serial) with a clear warning, and - keep MTP loading if only the batch-size request is impossible. It should not terminate the engine with exit code 1. ## Actual behavior Relevant engine log, in order: ```text strata generate: layer split: CUDA1 holds its weights, session [26, 48) and the head; 24.58 GiB free strata generate: --batch-groups auto: 2 groups of 2 slots strata generate: WARNING: --batch 4: slot 1's session does not fit on CUDA0 (1.27 GiB each, 0.00 GiB free); 1 slot strata generate: --batch: 1 slot sessions on CUDA0 (1.27 GiB each); 0.00 GiB free strata generate: WARNING: --batch 4: slot 0's session does not fit on CUDA1 (1.26 GiB each, 0.00 GiB free); 0 slots strata generate: --batch: 0 slot sessions on CUDA1 (1.26 GiB each); 0.00 GiB free strata generate: WARNING: --batch is off: not two slot sessions fit (a smaller --max-context or KV streaming, --kv-resident, makes them smaller) strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown ``` The serve layer then reports: ```text RuntimeError: the engine exited before it was ready ``` Process result: exit code `1`. ## Why this looks like an engine-side accounting/ordering bug The expert cache is sized before the `--batch` slots are accounted for: 1. `expert-cache auto` computes and fills the cache from the currently free VRAM. 2. Only afterwards does the engine try to allocate the `--batch 4` slot sessions. 3. Each slot needs ~1.27 GiB per card at this context; zero memory is left. 4. The batch silently degrades to 1/0 slots. 5. MTP then fails its much smaller 110 MiB allocation, terminating the process. The slot sessions are real VRAM consumers and are also visible in the engine's own log; they should be part of the auto-cache calculation. ## Contrast: same engine at a shorter context At `--max-context 65536` with `--batch 2`, the same model starts successfully: ```text strata generate: KV streaming: 32768 of 65536 cells per QSA layer in VRAM, the K/V in 0.39 GiB of pinned RAM strata generate: --batch-groups auto: 2 groups of 1 slot strata generate: --batch: 2 slot sessions on CUDA0 (0.32 GiB each); 25.38 GiB free strata generate: --batch: 2 slot sessions on CUDA1 (0.32 GiB each); 24.90 GiB free ``` So the mechanism works when slot sessions fit; the problem is that auto cache does not leave room for them at long context. ## Possible fixes - Subtract `batch_slots × per_slot_session` before computing the expert cache. - Cap `--batch` to the number of slot sessions that fit after reserving MTP/vision, and emit a warning instead of failing MTP. - If the requested `--batch` cannot fit, fall back to serial or a smaller batch rather than exiting. - Alternatively, document that `--batch N` must be lowered manually for long contexts; currently the failure mode is an engine exit, not a usable warning. ## Attachments to include - `Base/logs/server-20261020-120736.log` (full serve traceback) - relevant excerpt of `Base/logs/strata-serve.log` around the lines quoted above - the exact `strata-config.console.json` with `"parallel": 4` ---
Author
Owner

@github-actions[bot] commented on GitHub (Oct 20, 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:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

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:6283884913 --> @github-actions[bot] commented on GitHub (Oct 20, 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: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". 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 20, 2026):

Thanks, this follows the format now.

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

@zhq445078388 commented on GitHub (Nov 2, 2026):

Adding current-release data to this report: still reproducible on 0.1.52 / Windows HIP / 2× R9700, with K8V4 and explicit reserve.

Area

[Engine]

Summary

This is still reproducible on 0.1.52 (source f-027-rel, commit a42cc3d7df), Windows HIP, 2× R9700 32 GB (gfx1201), 1M context.

The engine sizes and fills the expert cache first, then tries to allocate the --batch N slot sessions. At 1M context each slot session is ~1.23–1.27 GiB per card, but by then the cards report 0.00 GiB free. Batch is turned off, and the following MTP allocation fails, so the engine exits with code 1.

This is engine-side: the failure occurs with a direct engine config, not through the console UI.

Environment

  • Engine: 0.1.52, source f-027-rel, commit a42cc3d7df
  • OS: Windows 11
  • GPUs: 2× AMD Radeon AI PRO R9700 32 GB (gfx1201)
  • RAM: 64 GB class
  • Model: Qwen3.8-Flash-Next GSQ-RCO-Abliterated IQ3_S
  • KV: --kv k8v4 --kv-resident 32768
  • Layer split: --layer-split auto
  • Experts: --expert-cache auto --mmap-experts
  • MTP: enabled, --spec 4
  • Vision: --vision
  • Context: --max-context 1048576 with YaRN from 262144
  • Batch: --batch 2

Observed

strata generate: layer split auto: CUDA0 ... 25.34 GiB free before its session carve
strata generate: layer split auto: CUDA1 ... 24.26 GiB free before its session carve
strata generate: KV streaming: 32768 of 1048576 cells per QSA layer in VRAM, the K/V in 4.78 GiB of pinned RAM
strata generate: --batch-groups auto: 2 groups of 1 slot
strata generate: --batch: 2 slot sessions on CUDA0 (1.23 GiB each); 22.65 GiB free
strata generate: WARNING: --batch 2: slot 0's session does not fit on CUDA1 (1.22 GiB each, 0.00 GiB free); 0 slots
strata generate: --batch: 0 slot sessions on CUDA1 (1.22 GiB each); 0.00 GiB free
strata generate: WARNING: --batch is off: not two slot sessions fit
strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown

The same happens with --kv int8; K8V4 only reduces the per-slot session from 1.27 to 1.23 GiB and does not fix it.

Things already tried (none help)

--vram-reserve-mib 1844
--vram-reserve-mib 3072 --vram-reserve-later-mib 3072
--expert-cache 19000
--kv k8v4

Even with explicit later-card reserve and a manual expert-cache cap, CUDA1 still reports 0.00 GiB free for the first batch slot session.

Expected

Either:

  1. subtract batch_slots × per_slot_session from the expert-cache budget before filling the cache, or
  2. allocate the batch slot sessions before the expert cache, or
  3. if they cannot fit, fall back to fewer slots / serial with a clear warning, but keep MTP loading and do not exit with code 1.

Notes

This is the same failure mode as #3364, now reproduced on 0.1.52 and with K8V4. The console already guards against this by auto-downgrading to 1 slot; without that guard the engine exits during startup.

<!-- gh-comment-id:6569845826 --> @zhq445078388 commented on GitHub (Nov 2, 2026): Adding current-release data to this report: still reproducible on 0.1.52 / Windows HIP / 2× R9700, with K8V4 and explicit reserve. ### Area [Engine] ### Summary This is still reproducible on 0.1.52 (source f-027-rel, commit a42cc3d7df70), Windows HIP, 2× R9700 32 GB (gfx1201), 1M context. The engine sizes and fills the expert cache first, then tries to allocate the `--batch N` slot sessions. At 1M context each slot session is ~1.23–1.27 GiB per card, but by then the cards report 0.00 GiB free. Batch is turned off, and the following MTP allocation fails, so the engine exits with code 1. This is engine-side: the failure occurs with a direct engine config, not through the console UI. ### Environment - Engine: 0.1.52, source f-027-rel, commit a42cc3d7df70 - OS: Windows 11 - GPUs: 2× AMD Radeon AI PRO R9700 32 GB (gfx1201) - RAM: 64 GB class - Model: Qwen3.8-Flash-Next GSQ-RCO-Abliterated IQ3_S - KV: `--kv k8v4 --kv-resident 32768` - Layer split: `--layer-split auto` - Experts: `--expert-cache auto --mmap-experts` - MTP: enabled, `--spec 4` - Vision: `--vision` - Context: `--max-context 1048576` with YaRN from 262144 - Batch: `--batch 2` ### Observed ```text strata generate: layer split auto: CUDA0 ... 25.34 GiB free before its session carve strata generate: layer split auto: CUDA1 ... 24.26 GiB free before its session carve strata generate: KV streaming: 32768 of 1048576 cells per QSA layer in VRAM, the K/V in 4.78 GiB of pinned RAM strata generate: --batch-groups auto: 2 groups of 1 slot strata generate: --batch: 2 slot sessions on CUDA0 (1.23 GiB each); 22.65 GiB free strata generate: WARNING: --batch 2: slot 0's session does not fit on CUDA1 (1.22 GiB each, 0.00 GiB free); 0 slots strata generate: --batch: 0 slot sessions on CUDA1 (1.22 GiB each); 0.00 GiB free strata generate: WARNING: --batch is off: not two slot sessions fit strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown ``` The same happens with `--kv int8`; K8V4 only reduces the per-slot session from 1.27 to 1.23 GiB and does not fix it. ### Things already tried (none help) ```text --vram-reserve-mib 1844 --vram-reserve-mib 3072 --vram-reserve-later-mib 3072 --expert-cache 19000 --kv k8v4 ``` Even with explicit later-card reserve and a manual expert-cache cap, CUDA1 still reports 0.00 GiB free for the first batch slot session. ### Expected Either: 1. subtract `batch_slots × per_slot_session` from the expert-cache budget before filling the cache, or 2. allocate the batch slot sessions before the expert cache, or 3. if they cannot fit, fall back to fewer slots / serial with a clear warning, but keep MTP loading and do not exit with code 1. ### Notes This is the same failure mode as #3364, now reproduced on 0.1.52 and with K8V4. The console already guards against this by auto-downgrading to 1 slot; without that guard the engine exits during startup.
Author
Owner

@zhq445078388 commented on GitHub (Nov 4, 2026):

Re-tested on a current Windows HIP build, and re-read the v0.2.10 source. Two additions: it still reproduces (even at --batch 2), and the code that carves the slot sessions is unchanged.

1. Still reproduces on 0.1.52, and --batch 4 is not required

Engine 0.1.52 (strata-engine-0.1.52-windows-x86_64-hip-rx9070, built from a42cc3d, i.e. the 0.2.7 engine), 2026-11-02. Same box as above (Windows, 2× R9700 32 GB), model GSQ-RCO-Abliterated IQ3_S, --max-context 1048576, --kv-resident 32768, serve config "parallel": 2 → --batch 2:

strata generate: layer split: CUDA1 holds its weights, session [26, 48) and the head; 24.58 GiB free
strata generate: --batch-groups auto: 2 groups of 1 slot
strata generate: WARNING: --batch 2: slot 1's session does not fit on CUDA0 (1.27 GiB each, 0.00 GiB free); 1 slot
strata generate: --batch: 1 slot sessions on CUDA0 (1.27 GiB each); 0.00 GiB free
strata generate: WARNING: --batch 2: slot 0's session does not fit on CUDA1 (1.26 GiB each, 0.00 GiB free); 0 slots
strata generate: --batch: 0 slot sessions on CUDA1 (1.26 GiB each); 0.00 GiB free
strata generate: WARNING: --batch is off: not two slot sessions fit (a smaller --max-context or KV streaming, --kv-resident, makes them smaller)
strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown

RuntimeError: the engine exited before it was ready, exit code 1. At 1M context one slot session is ~1.27 GiB per card, so two of them are already ~2.5 GiB per card on top of everything else — the requested batch size does not have to be large to trigger this.

2. What the v0.2.10 source still does

I compared src/program/generate.cpp between v0.2.7 (my 0.1.52) and v0.2.10. The slot carve and the cache sizing are both unchanged, and no step costs the slot sessions before they are taken out of what is left.

The carve (v0.2.10, ~L6604) allocates each slot session from the free VRAM at that moment and degrades fit on failure — this is the code that prints the warnings above:

const uint64_t bytes = strata::core::session_bytes(g, o.max_context, K, lo, hi);
...
if (cudaMalloc(&buf, bytes) != cudaSuccess || strata::core::session_init(g, o.max_context, K, buf, *u, lo, hi) == 0) {
    ...
    std::fprintf(stderr, "strata generate: WARNING: --batch %d: slot %d's session does not fit on CUDA%d "
                 "(%.2f GiB each, %.2f GiB free); %d slot%s\n", ...);
    fit = b;

and the expert-cache budget (v0.2.10, ~L7548) reserves the user's --vram-reserve-mib, the prompt chunk, the MTP bind and the pipeline window, but no slot bytes:

const int64_t reserve = (((int64_t) o.vram_reserve_mib + prefill_mib) << 20) + mtp_bind + pipe_first;

So session_bytes() — the same call, per stage, with that stage's lo/hi — is available at the point where the reserve is built, and it is not used there.

3. One thing I could not pin down

In the log above, CUDA1 reports 24.58 GiB free on the line just before the carve, and 0.00 GiB free at the carve itself, so some allocation between those two lines has already taken the rest. I could not identify it from the source (between the main session carve and the slot carve I only find the PLE setup and the log marks). If that is the expert-arena registration, then the ask is the same but the number has to be reserved before that step rather than only in the reserve above — could you say which step it is? That would make this report actionable rather than just a symptom.

4. The smallest change that would have avoided it

Cost the slots before whatever consumes the remaining VRAM:

int64_t slot_reserve = 0;
if (o.batch > 0)
    for (size_t k = 0; k < bslot_ss.size(); ++k) {          // stage 0 + every split stage
        const int64_t lo_k = k == 0 ? 0 : stages[k - 1]->lb;
        const int64_t hi_k = k == 0 ? (multi_gpu ? split_at[0] : -1) : stages[k - 1]->le;
        slot_reserve += (int64_t) o.batch * (int64_t)
                        strata::core::session_bytes(g, o.max_context, K, lo_k, hi_k);
    }

and subtract it wherever the remaining VRAM is decided for the cache / arena. If that leaves too little for a working cache, cap --batch there and say so in the same place that prints --batch is off today — the current failure mode lets a 110 MiB allocation be the thing that ends the process, after the full model load.

Optionally, the 0.2.10 small-card ladder could cover this case as well: when the slots degrade below two, drop the MTP layer with one plain line (as the 8 GB / 128K path does) instead of exiting 1.

5. Workaround for anyone else hitting this

"parallel": 2 with a shorter context (64K starts fine here), or shrink the session with --kv-resident / KV streaming — both reduce session_bytes().


Environment for the re-test: Strata engine 0.1.52 (Windows x64 HIP, gfx1200/gfx1201, ROCm 10.2.0a runtime), 2× Radeon AI PRO R9700 32 GB, 63.4 GiB RAM, Windows 11, model on NVMe, serve layer generated by our console ("parallel": 2 → --batch 2). Happy to run any build you point me at on this box — including a Windows HIP package with a candidate fix.

<!-- gh-comment-id:6634738550 --> @zhq445078388 commented on GitHub (Nov 4, 2026): Re-tested on a current Windows HIP build, and re-read the v0.2.10 source. Two additions: it still reproduces (even at `--batch 2`), and the code that carves the slot sessions is unchanged. ### 1. Still reproduces on 0.1.52, and `--batch 4` is not required Engine 0.1.52 (`strata-engine-0.1.52-windows-x86_64-hip-rx9070`, built from `a42cc3d`, i.e. the 0.2.7 engine), 2026-11-02. Same box as above (Windows, 2× R9700 32 GB), model GSQ-RCO-Abliterated IQ3_S, `--max-context 1048576`, `--kv-resident 32768`, serve config `"parallel": 2` → `--batch 2`: ```text strata generate: layer split: CUDA1 holds its weights, session [26, 48) and the head; 24.58 GiB free strata generate: --batch-groups auto: 2 groups of 1 slot strata generate: WARNING: --batch 2: slot 1's session does not fit on CUDA0 (1.27 GiB each, 0.00 GiB free); 1 slot strata generate: --batch: 1 slot sessions on CUDA0 (1.27 GiB each); 0.00 GiB free strata generate: WARNING: --batch 2: slot 0's session does not fit on CUDA1 (1.26 GiB each, 0.00 GiB free); 0 slots strata generate: --batch: 0 slot sessions on CUDA1 (1.26 GiB each); 0.00 GiB free strata generate: WARNING: --batch is off: not two slot sessions fit (a smaller --max-context or KV streaming, --kv-resident, makes them smaller) strata generate: mtp: dense weights allocation failed (unspecified launch failure), requested 110 MiB, CUDA0 free unknown ``` `RuntimeError: the engine exited before it was ready`, exit code 1. At 1M context one slot session is ~1.27 GiB per card, so two of them are already ~2.5 GiB per card on top of everything else — the requested batch size does not have to be large to trigger this. ### 2. What the v0.2.10 source still does I compared `src/program/generate.cpp` between `v0.2.7` (my 0.1.52) and `v0.2.10`. The slot carve and the cache sizing are both unchanged, and no step costs the slot sessions before they are taken out of what is left. The carve (v0.2.10, ~L6604) allocates each slot session from the free VRAM at that moment and degrades `fit` on failure — this is the code that prints the warnings above: ```c const uint64_t bytes = strata::core::session_bytes(g, o.max_context, K, lo, hi); ... if (cudaMalloc(&buf, bytes) != cudaSuccess || strata::core::session_init(g, o.max_context, K, buf, *u, lo, hi) == 0) { ... std::fprintf(stderr, "strata generate: WARNING: --batch %d: slot %d's session does not fit on CUDA%d " "(%.2f GiB each, %.2f GiB free); %d slot%s\n", ...); fit = b; ``` and the expert-cache budget (v0.2.10, ~L7548) reserves the user's `--vram-reserve-mib`, the prompt chunk, the MTP bind and the pipeline window, but no slot bytes: ```c const int64_t reserve = (((int64_t) o.vram_reserve_mib + prefill_mib) << 20) + mtp_bind + pipe_first; ``` So `session_bytes()` — the same call, per stage, with that stage's `lo`/`hi` — is available at the point where the reserve is built, and it is not used there. ### 3. One thing I could not pin down In the log above, CUDA1 reports **24.58 GiB free** on the line just before the carve, and **0.00 GiB free** at the carve itself, so some allocation between those two lines has already taken the rest. I could not identify it from the source (between the main session carve and the slot carve I only find the PLE setup and the log marks). If that is the expert-arena registration, then the ask is the same but the number has to be reserved before that step rather than only in the `reserve` above — could you say which step it is? That would make this report actionable rather than just a symptom. ### 4. The smallest change that would have avoided it Cost the slots before whatever consumes the remaining VRAM: ```c int64_t slot_reserve = 0; if (o.batch > 0) for (size_t k = 0; k < bslot_ss.size(); ++k) { // stage 0 + every split stage const int64_t lo_k = k == 0 ? 0 : stages[k - 1]->lb; const int64_t hi_k = k == 0 ? (multi_gpu ? split_at[0] : -1) : stages[k - 1]->le; slot_reserve += (int64_t) o.batch * (int64_t) strata::core::session_bytes(g, o.max_context, K, lo_k, hi_k); } ``` and subtract it wherever the remaining VRAM is decided for the cache / arena. If that leaves too little for a working cache, cap `--batch` there and say so in the same place that prints `--batch is off` today — the current failure mode lets a 110 MiB allocation be the thing that ends the process, after the full model load. Optionally, the 0.2.10 small-card ladder could cover this case as well: when the slots degrade below two, drop the MTP layer with one plain line (as the 8 GB / 128K path does) instead of exiting 1. ### 5. Workaround for anyone else hitting this `"parallel": 2` with a shorter context (64K starts fine here), or shrink the session with `--kv-resident` / KV streaming — both reduce `session_bytes()`. --- Environment for the re-test: Strata engine 0.1.52 (Windows x64 HIP, gfx1200/gfx1201, ROCm 10.2.0a runtime), 2× Radeon AI PRO R9700 32 GB, 63.4 GiB RAM, Windows 11, model on NVMe, serve layer generated by our console (`"parallel": 2` → `--batch 2`). Happy to run any build you point me at on this box — including a Windows HIP package with a candidate fix.
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#1365
No description provided.