mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[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
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1365
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zhq445078388 on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3364
Strata issue draft —
expert-cache autoignores--batchslot sessionsTitle
expert-cache autodoes not reserve memory for--batchslot sessions; MTP allocation then fails and the engine exits with code 1Summary
With a long context (
--max-context 1048576) and--batch 4, Strata'sexpert-cache autofills the expert cache first. The four batch slot sessionsneed ~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:
The serve layer reports:
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
0.1.45.3Windows HIP build(
strata-engine-0.1.45.3-windows-x86_64-hip-rx9070.tar.gz,release tag
v0.2.0-beta)--kv int8,--kv-resident 32768--layer-split auto--expert-cache auto --mmap-experts--mtp <strata-mtp/rt> --mtp-hnorm stream)--vision"parallel": 4→ engine gets--batch 4The model path is omitted here; full local logs can be attached.
Exact engine arguments
--batch 4comes from the serve config's"parallel": 4.Steps to reproduce
"parallel": 4.Expected behavior
expert-cache autoshould account for the memory needed by the requested--batch Nslot sessions before filling the expert cache, or it shouldreduce the cache until the slots fit. If the requested batch size still cannot
fit, it should:
It should not terminate the engine with exit code 1.
Actual behavior
Relevant engine log, in order:
The serve layer then reports:
Process result: exit code
1.Why this looks like an engine-side accounting/ordering bug
The expert cache is sized before the
--batchslots are accounted for:expert-cache autocomputes and fills the cache from the currently free VRAM.--batch 4slot sessions.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 65536with--batch 2, the same model starts successfully: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
batch_slots × per_slot_sessionbefore computing the expert cache.--batchto the number of slot sessions that fit after reserving MTP/vision,and emit a warning instead of failing MTP.
--batchcannot fit, fall back to serial or a smaller batchrather than exiting.
--batch Nmust be lowered manually for longcontexts; currently the failure mode is an engine exit, not a usable warning.
Attachments to include
Base/logs/server-20261020-120736.log(full serve traceback)Base/logs/strata-serve.logaround the lines quoted abovestrata-config.console.jsonwith"parallel": 4@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:
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
@github-actions[bot] commented on GitHub (Oct 20, 2026):
Thanks, this follows the format now.
@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 Nslot 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
a42cc3d7df--kv k8v4 --kv-resident 32768--layer-split auto--expert-cache auto --mmap-experts--spec 4--vision--max-context 1048576with YaRN from 262144--batch 2Observed
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)
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:
batch_slots × per_slot_sessionfrom the expert-cache budget before filling the cache, orNotes
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.
@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 4is not requiredEngine 0.1.52 (
strata-engine-0.1.52-windows-x86_64-hip-rx9070, built froma42cc3d, 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: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.cppbetweenv0.2.7(my 0.1.52) andv0.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
fiton failure — this is the code that prints the warnings above: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:So
session_bytes()— the same call, per stage, with that stage'slo/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
reserveabove — 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:
and subtract it wherever the remaining VRAM is decided for the cache / arena. If that leaves too little for a working cache, cap
--batchthere and say so in the same place that prints--batch is offtoday — 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": 2with a shorter context (64K starts fine here), or shrink the session with--kv-resident/ KV streaming — both reducesession_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.