mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#2226
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 @eddietheengineer on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4846
Area
[Engine] — the PLE residency policy and the expert-arena load at startup.
Desktop app, Terminal or source?
Docker — the official CUDA 13 image (
ghcr.io/niko1221/strata@sha256:83e37db8625c67b61c579fd7c0f9068f2d831037a937f139c569502b54290998, image 0.2.9, engine 0.1.55), stocksetup.pyflow inside it, driven by our launcher.What happened
On a 92 GiB-RAM rig with the model on an NVMe SSD, booting Qwen3.8-Flash-Next IQ3_S at a raised
--max-context 524288(trained 262144, yarn ×2), auto policy (STRATA_PLE_AUTO_RAMempty/unset):ple_resident_admit: table + arena ≤ available − an 8 GiB headroom; in the capture 73.6 ≤ 86.7 − 8 = 78.7, ~5.1 GiB to spare): (The policy, not our config, choseram: the run config/data/install/strata-iq3_s.jsonandrun-iq3_s.shcontain no--ple-ioat all, and the logged engine argv has none.)ple_residency.hpp's own #4518 comment says exactly this window is invisible to the check ("what the rest of the engine takes after that (the KV pools, the pinned staging, the GPUs' host buffers) is not known then"). The boot's own lines itemize only part of the ~26 GiB (KV streaming pins 2.58 GiB; the batch slot sessions are in VRAM; the conversation cache is sized at serve time, after the arena) — the residual is unexplained from the log alone.- 15 s so far; the next line is the next engine start at 15:09:17. The host journal's last entries are memory-pressure cache flushes at 14:56:20/14:56:22/14:56:48 UTC, with no shutdown sequence; the next boot starts at 15:00:02. The host had to be power-cycled. (Engine log timestamps are UTC; the journal prints local EDT = UTC-4.)- 15 s so farline the very next line isstrata: expert arena: MAP_HUGETLB unavailable (needed 23983 2 MiB pages, vm.nr_hugepages=0); transparent huge pages NOT requested: only 1 GiB of free 2 MiB blocks for a 46 GiB arena, compaction would stall the load (#2126)(attached:registration-after-timeout-144344.log; other starved boots read 0 GiB). The #4518 give-back mechanism exists and works, but it fires at serve time against the conversation cache only; a starved boot never reaches serve.STRATA_PLE_AUTO_RAM=0(table on direct disk reads — on this SSD the probe says it's cheap:PLE direct read probe: 47431 rows/s (fine), 46.9–48.4k across the=0boots) comes up clean and is our current serving config:loaded 46.84 GiB at 2.92 GiB/s, verify-stress ceiling ladder to 481K tokens, MemAvailable floor 6.7 GiB, zero swap.Reproduction status
The sequence above was reproduced on demand under a watchdog that
docker stops the container at the first arena-wait line, inside the 20 s window and before the arena registration — so the capture stops exactly where the dangerous step begins.clean-repro-boot.logis that boot in full (engine 0.1.55, 2026-10-31 18:07:45 UTC): memory guard 87.4 GiB → residency admit at 86.7 GiB →PLE table locked in RAM ... in 11.3 s→ KV streaming pins 2.58 GiB → ... →the expert arena needs 46.84 GiB of RAM and 33.66 GiB is available; waiting up to 20 s→- 5 s so far(container stopped there).Before we understood the failure, the same failure mode — auto policy at a raised context — killed the host outright four times in one afternoon: three 1M-context boots (14:28:50, 14:35:02, 14:43:44 UTC, each logging the arena wait at 8.1–9.3 GiB available) and the 524288 boot (14:55:20, wait at 34.6 GiB), each followed within 1.4–3.8 min by a journal ending in
Under memory pressure, flushing caches(one inrtkit-daemon: The canary thread is apparently starving) with no shutdown record; last journal entries 14:30:11, 14:38:50, 14:45:48, 14:56:48 UTC. (Journal timestamps after NTP sync are local EDT; add 4 h for UTC. Boot 0's early journal lines predate the NTP correction and read 07:00 — the real boot time, 15:00:02 UTC, is fromuptime/who -b.) No starved boot ever loggedloaded 46.84 GiB— only the=0boots did. Those deaths are why we built the watchdog; the clean capture is the primary evidence, the journal history (journal-deaths.txt) shows it is not a one-off. The stall mechanism (direct reclaim/compaction during registration with the table locked) is inference by analogy with #3698 — we did not capture PSI/vmstat at the deaths.Contrast with #3698: there MemAvailable over-reported because of KHO/CMA (
CmaFree~17 GiB counted as free). HereCmaTotal: 0 kB(kernel cmdline hascrashkernel=…, nokho=) and swap is 8.0 GiB — MemAvailable was accurate at both readings; the RAM genuinely disappeared between the check and the fill.Smallest steps or command that reproduce it
(2× sm_86,
STRATA_PLE_AUTO_RAMempty/unset = auto policy.) Preconditions that matter: a fresh boot with ~87 GiB MemAvailable, model files on an SSD so setup leaves the table on direct reads (on a rotational disk setup writes--ple-io ramitself and the policy is not the decider), and the context raised past 262144 so the arena is the big late allocation.⚠️ Unwatchdogged, auto-policy raised-context boots hung this 92 GiB host four times (three at 1M context, one at 524288 — see Reproduction status). The attached capture was taken with a watchdog stopping the container inside the 20 s wait, before registration.
Strata version
Image 0.2.9 / engine 0.1.55. #4518's give-back was fixed in 0.2.8 and is present here — it works for the conversation cache (we see it fire on this rig on earlier boots:
PLE table lock given back: the lock left 4.5 GiB of RAM for the conversation cache, 30.7 GiB without it (the table stays cached; --conversation-cache-mib N and --ple-io ram are kept as asked)), but the incident boot never reached serve, where that check happens.Graphics card, memory and system
RTX 3090 + RTX 3090 Ti (sm_86, PCIe, no NVLink), 91.9 GiB host RAM (capture boot's guard line:
memory guard: limit 91.9 GiB (source: meminfo), current 4.5 GiB, reclaimable cache credited 0.0 GiB; available 87.4 GiB (MemAvailable 87.4 GiB), floor 2560 MiB), Ubuntu 26.04.1 kernel 7.0.0-38-generic, driver 615.71.09, model files on NVMe SSD (ext4,rotational=0), Docker 29.9.0, container with--ulimit memlock=-1, swap 8.0 GiB,CmaTotal: 0 kB.Model, size and settings
Qwen3.8-Flash-Next IQ3_S (GSQ-RCO pack); PLE table 26.8 GiB (second GGUF shard), expert arena 46.84 GiB,
--kv int8 --kv-resident 32768 --spec 4 --batch 3 --layer-split auto,--max-context 524288 --rope-scaling yarn --rope-scale 2.The ask
When the arena wait expires and the arena still does not fit: give the PLE table lock back (the #4518 mechanism, applied at the arena-wait point against the arena instead of at serve time against the conversation cache) and retry the registration — or fail the start with a clear error — rather than registering into a host stall. The engine has both numbers at that moment; the current code waits 20 s and proceeds regardless. (Secondary: the admission prices table + arena against an 8 GiB headroom, but on our rig the rest of startup took ~26 GiB between the check and the fill; a MemAvailable re-check at the arena point, before registering, would have caught every starved boot above.)
Potential fix (from reading v0.2.9 — please correct us if we misread the design)
The pieces already exist; only the seam between them is missing:
PleTable::unlock()(src/kernels/ngram.cpp:522) is a clean, self-contained give-back:unlock_residentover the table range,locked = false; the mapping stays and reads keep going through it — only the page lock is dropped, so the OS may reclaim the pages and they fault back from the file (the #4518 log's "the table stays cached").generate.cpptracksple_lock_by_policy(:4710, set at:4769) precisely so the policy's lock — and only the policy's lock, never a hand-asked--ple-io ram— may be given back. The #4518 site (:10413) callsple_table.unlock()when the lock starves the conversation cache.ArenaExpertSource::open()(src/core/expert_source.cpp:5777, the check at ~5864-5921) computes the shortfall before it registers: it waits (wait_for_ram), and ifhm.available < needstill holds, it setsram_warning_— whose own text says "with this little room the whole machine can stall in memory reclaim until it is restarted (#4051)" — and then proceeds to thecudaHostRegisterslices anyway (:3944/:3987).All three live in
main()'s scope, so the warning and the unlock are visible to each other. The stall happens insideopen()(the registration follows the warning in the same function), so the check can't just move to the call site. Minimal shape we'd suggest: hand the arena source a give-back hook — e.g. astd::function<void()> ple_give_backparameter (or thePleTable*+ theple_lock_by_policyflag, as the #4518 site already pairs them) — and call it whereram_warning_is set when the shortfall survives the wait (hm.available < need), then re-readavailable_host_bytes()before the registration slices begin. Log line in the #4518 style:strata generate: PLE table lock given back: the expert arena needs %.2f GiB and only %.2f GiB is available (the table stays cached; --ple-io ram asked for by hand is kept). Roughly 30-50 lines plus aple_residency_test.cppcase; no new state, no reordering of the load.Note the warning text reserves "the whole machine can stall in memory reclaim" for
hm.available < need / 2— our 512K hang happened at 33.66 available against 46.84 needed, above that threshold (the 1M boots were below it). If the stall clause is the intended trigger, the threshold under-prices the risk on a 92 GiB host; giving back on any surviving shortfall is the safer rule, and costs the 2-3% lock benefit only on boots that would otherwise stall.We recognize the recommend-not-force rule the wait's comment cites ("the load then goes on either way - it only warns") — this narrows the exception to the case where the engine's own warning text already predicts a machine stall, and gives back a lock the policy (not the user) took, which is the same trade #4518 made for the conversation cache: the lock is worth 2-3% of prompt speed, the host is worth more.
Context
Filed from the club-3090 project (we vendor Strata in our catalog; open PR #1888 forwards
STRATA_PLE_AUTO_RAMas a launch workaround on all five Strata composes and documents the two RAM paths). Happy to run any instrumented build on this rig.Logs
clean-repro-boot.log — the primary watchdogged capture (2026-10-31 18:07:45 UTC, container stopped at the arena wait):
registration-after-timeout-144344.log — an unwatchdogged 1M boot: the wait expires and the registration line follows immediately:
incident-boot-145520.log — the 524288 boot quoted in step 3, ending mid-wait at '- 15 s so far'; the host died minutes later:
journal-deaths.txt — host journal: last lines of the four dead boots, boot 0's first line, meminfo (Cma/Swap):
How the clean capture was taken safely: a watchdog tails the engine log, and at the first
expert arena needs ... is availableline runsswitch.sh --down— inside the 20 s wait, before the arena registration. The script is in our repo scratch; happy to share it.@github-actions[bot] commented on GitHub (Oct 31, 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 31, 2026):
Thanks, this follows the format now.
@eddietheengineer commented on GitHub (Oct 31, 2026):
Update: the same stall happens with the table NOT locked — the engine should fail gracefully when the arena does not fit
A second capture from this rig, 2026-10-31 18:32:14 UTC:
--max-context 1048576 --rope-scaling yarn --rope-scale 4withSTRATA_PLE_AUTO_RAM=0— the workaround from the body. The residency policy never ran, the table was never locked:Then the registration went ahead — and the host stalled the same way: the journal's last entries are
Under memory pressure, flushing cachesat 18:33:59 UTC (14:33:59 local), no shutdown sequence; the box needed a power reset (next boot 18:36).This is on purpose, not a watchdog miss: the
=0config is our serving config, and the 1M boot was an attempt to raise the context further. The=0boots at 524288 come up with ~6.7 GiB MemAvailable to spare; at 1048576 the KV stream's pinned RAM grows (2.58 → 5.16 GiB) and the arena no longer fits even with the table on disk.Why this matters for the fix above: the give-back at the arena-wait point would not have saved this boot — there was no lock to give back. The general defect is that
ArenaExpertSource::open()measuresavailable < need(46.84 vs 34.98), waits, and callscudaHostRegisterregardless. The wait's own comment says the load "goes on either way - it only warns", and the warning text itself predicts "the whole machine can stall in memory reclaim until it is restarted (#4051)" — but a warning that requires a power reset to act on is not a warning.Suggested addition to the ask: when the shortfall survives the wait, do not register. Options in rough order of preference: (a) refuse the start with the same error text the warning already computes ("the arena needs X, Y is available — close other programs, or run with
--mmap-experts --resident-budget-gib N") — the engine has every number at that point; (b) auto-fall back to--mmap-expertswith a resident budget sized from what is actually available, and say so; (c) at minimum, cap the wait's follow-through so the registration is skipped whenavailable < needstill holds after it. All three turn a host power-reset into a startup error, which is the difference between a bug report and a support ticket.The PLE give-back (the body's ask) is still the right fix for the 524288 case — on a 92 GiB rig the two together are what make raised contexts safe: give the lock back when the arena needs the room, and refuse the start when even then the arena does not fit.
@eddietheengineer commented on GitHub (Nov 7, 2026):
Reporter update — re-tested on 0.2.11 (engine 0.1.57): both boots from this issue now serve, and the give-back fix was observed firing under forced pressure.
Rig: 2× RTX 3090 / 3090 Ti, 91.9 GiB RAM, SSD model disk — so the residency policy is the live mechanism here (on a rotational disk, setup writes
--ple-io ramdirectly and the policy never runs).Boot 1 — the hang repro from the issue body:
--max-context 524288 --rope-scaling yarn --rope-scale 2, default PLE policy. On 0.2.11 it comes up and serves. The policy still locks the table, but on a clean boot the arena fits after the lock, so the wait never arms:Ready in 72 s, MemAvailable at ready ≈ 30 GiB, host never stalled.
Boot 2 —
--max-context 1048576 --rope-scaling yarn --rope-scale 4withSTRATA_PLE_AUTO_RAM=0. Serves: PLE stays on direct disk reads (PLE direct read probe: 107896 rows/s (fine), no lock line), arena registers, MemAvailable at ready ≈ 20.8 GiB. A full context stress against this boot passes 8/8 (needle recall clean to 813K tokens, prefill 2,184 → 1,648 t/s from 95K → 903K, VRAM flat, swap ~zero).Forcing the pressure so the fix actually runs. A static RAM pin can't arm the arena wait: the policy's lock test (
table 26.8 + arena 46.8 ≤ available) and the arena's fit test (available − 26.8 ≥ 46.8) are the same 73.6 GiB boundary — whenever the policy locks, the arena fits. The original hang crossed it because a dying previous engine still held ~21 GiB of mlocked RAM between the two checks (the wait message's own "another engine still exiting?" hint). So I pinned 11 GiB withMAP_LOCKEDand re-ran boot 1: the arena still fit, but the boot starved under the lock at the next allocation — and the give-back fired:The boot completed and served (
session is up, verify windows captured, KV streaming 96.3 % VRAM hit); MemAvailable bottomed at 5.5 GiB mid-boot and settled at 30.5 GiB. On 0.1.55 this exact shape — lock held, downstream allocation starved — was the host stall.Not exercised in isolation: the arena-wait branch specifically (the
the expert arena needs … waiting up to 20 slines from the original captures). Per the boundary arithmetic above it needs overlapping boots rather than a static pin — a second Strata boot started while the first is still draining its mlocked table/arena. If you want that capture too, I can attempt it; the host-stall guard (stop below 2 GiB MemAvailable) is scripted.As we read it, 0.2.10's give-back covers both failure shapes in this issue, and the fix is working as described. Happy to provide further logs — and this is also cross-posted on our side (noonghunna/club-3090#1888), so the issue can be closed against 0.2.11 if you're satisfied.