[GH-ISSUE #507] [BUG] [DS4] Load-time OOM kill on one NUMA node with DS4_ENGRAM_RAM=1 + --mmap-experts off #210

Closed
opened 2026-10-29 21:22:37 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @zhangxiaoxing on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/507

Load-time OOM kill on one NUMA node with DS4_ENGRAM_RAM=1 + --mmap-experts off

Summary

On a 2-socket / 512 GB host, Maya v1.1.28 is reliably SIGKILLed by the kernel during load on node 0, while the machine still has ~195 GiB of MemAvailable and global memory PSI is 0.00. The kill is a node-local CONSTRAINT_MEMORY_POLICY OOM, not a machine-wide OOM:

  • DS4_ENGRAM_RAM=1 maps and mlock()s the two complete Engram tables — 202.758 GB decimal (189 GiB). On the failing starts essentially all of it was resident on node 0 (Node 0 ... mlocked:201740944kB).
  • --mmap-experts off then puts all 6,771 CPU-lane experts (106.3 GB) into anonymous host memory. place_experts() allocates each layer's host block separately per NUMA node with node_map() → anon_alloc() → mbind(MPOL_BIND, {node X}). There is no check of node-local free memory on this path.
  • Node 0 had ~58–59 GiB left after the Engram lock. Its half of the expert blocks is ~49.5 GiB, leaving only ~8–10 GiB for page cache / kernel / other tenants. The load's page cache crosses that margin; the first touch of a node-0-bound block then hits the node's min watermark. MPOL_BIND forbids falling back to node 1, so the kernel kills the process instead of spilling.
  • For non-GGUF packs, place_experts() has no RAM budget at all on this path. For GGUF/MXFP4 packs the analogous copy_experts() path has a machine-global budget (ram_room() / kRamMargin) with per-node MPOL_BIND placement — the same class of bug.

This is not a v1.1.28 regression. The same unguarded node_map(bytes, X, NH) host allocation exists in v1.1.24–v1.1.27; it is at ds4_model.cu:4977 in v1.1.27 and ds4_model.cu:5185 in v1.1.28.

Environment

Item Value
Maya v1.1.28 (tag 6afa525, local HTTPS patch on top; VERSION 1.1.28, build stamp cf28053a13c8876d)
Previous version checked v1.1.27 — same allocation path (ds4_model.cu:4977)
Host 2× Intel Xeon Gold 5320, 2 NUMA nodes, 104 logical CPUs, 512 GB DDR4
GPUs 2× NVIDIA A100 80 GB, --tp 2, --layer-split auto
OS / kernel Ubuntu 24.04.5 LTS, kernel 6.8.0-136-generic
Pack DeepSeek-V4.1-Flash-1017, EXL3 3.5 bpw (Maya EXL3 pack, trellis / suh / svh tensors; not GGUF/MXFP4)
Pack location network share (/DPC_HOME/...), 460.9 GB
Engine args --pack … --max-context 262144 --tp 2 --mmap-experts off --dspark none
Engine env DS4_ENGRAM_RAM=1
Memlock ulimit -l unlimited

The engine is started directly by capture-engine.sh (no server), with the same args/env as the service. The service path (run-captured.sh) shows the same failure, but the server reports only exit code 1.

Steps to reproduce

  1. On a 2-socket host with two NUMA nodes, start with the config above (DS4_ENGRAM_RAM=1, --mmap-experts off, --tp 2).

  2. Ensure the Engram tables are already in page cache on one socket (this happens naturally after a previous start/kill; a cold cache with numactl --interleave=all may avoid it).

  3. Run the engine directly and record memory/PSI:

    ulimit -l unlimited
    ./capture-engine.sh --timeout 1800
    
  4. Observe: exit status 137, the engine's stderr ends at Engram RAM ONLY, global MemAvailable is still very high, and the kernel log has a node-local OOM record.

Local captures used for this report (to attach): .stage/engine-capture-20261026-101643/ and .stage/engine-capture-20261026-104645/.

Capture Engine PID (from strace) Engine exit Last memory sample before kill
20261026-101643 1707741 137 10:18:14 used=315708MB avail=199731MB full avg10=0.00
20261026-104645 1745546 137 10:48:21 used=322382MB avail=193057MB full avg10=1.26

The two engine stderr files are byte-identical (31 lines each): 30 Engram RAM file … locked progress lines followed by the final Engram RAM ONLY line, then nothing.

Expected behavior

  • If the CPU-lane experts do not fit the RAM this process can actually obtain on each node, the engine should copy only what fits and leave the rest in place (the GGUF path already has a "do not all fit" warning), or fail startup with a clear error before touching the pages.
  • It must not hard-bind an allocation that cannot fit its node and then let the kernel SIGKILL the process.
  • A global MemAvailable of ~195 GiB with 0.00 global PSI should not coexist with a fatal OOM.

Actual behavior

Kernel OOM record (trimmed from /var/log/kern.log)

Node 0 Normal free:190560kB min:223808kB ... mlocked:201740944kB all_unreclaimable? yes
...
global free:46034760 pages  (~184 GB free machine-wide)
...
oom-kill:constraint=CONSTRAINT_MEMORY_POLICY,nodemask=0,...,task=maya-ds4,pid=1707741
...
Out of memory: Killed process 1707741 (maya-ds4) ... anon-rss:79860736kB file-rss:198224000kB ...
  • Node 0: 186 MB free against a 218 MB min watermark.
  • Node 0: 192.4 GiB mlocked (the Engram tables), all_unreclaimable? yes.
  • Machine-wide: 46,034,760 free pages (~175.6 GiB / ~188.6 GB decimal), so this is not a global OOM.
  • nodemask=0 + CONSTRAINT_MEMORY_POLICY means the faulting allocation was bound to node 0 and could not use node 1's free memory.

memory.log: global memory was not exhausted

From .stage/engine-capture-20261026-101643/memory.log:

10:16:48 used=45054MB  avail=470385MB full avg10=0.00   <- start
10:17:49 used=269263MB avail=246176MB full avg10=0.00   <- Engram tables locked
10:18:14 used=315708MB avail=199731MB full avg10=0.00   <- last sample before SIGKILL
10:18:19 used=193767MB avail=321672MB full avg10=1.22   <- process dead, memory released

At the kill, MemAvailable was 199,731 MB = 195.0 GiB, and global PSI full avg10 was 0.00. From the post-lock sample to the last sample, machine-wide used rose by ~46 GB — the copy is 106.3 GB in total — while 195 GiB still appeared available.

engine.err: the last line is the Engram lock

ds4: Engram RAM file 46 locked 94.76 / 98.31 GB
ds4: Engram RAM file 46 locked 98.31 / 98.31 GB
ds4: Engram RAM file 46 locked 0.27 / 3.07 GB
ds4: Engram RAM file 46 locked 3.07 / 3.07 GB
ds4: Engram RAM ONLY: 2 complete tables (Q6_K/IQ4_NL/FP8), 202.758 GB locked; reads use memcpy

No CUDA placement lines, no "experts VRAM leaves over" line, no error message. The next thing the process sees is SIGKILL.

signals.log: SIGKILL on the main PID and its threads

1709003 +++ killed by SIGKILL +++
...
1707741 +++ killed by SIGKILL +++

The main PID matches the pid=1707741 in the kernel OOM record. The second capture's main PID is 1745546, matching the other record.

Service/TUI

RuntimeError: the engine exited before it was ready (see .../maya-ds4.log)
[X] Maya stopped: its server ended with exit code 1

serve/server.py:561 raises this when the engine dies before READY. The engine's real termination (SIGKILL; 137 in shell notation, -9 from Popen.wait()) is lost; the user sees the server's exit code 1.

Root cause

1. The Engram tables are locked on one socket

DS4_ENGRAM_RAM=1 calls EgReader::pin_range() (src/ds4/ds4_engram_io.hpp:140), which mmap()s each table and mlock()s it in 256 MB chunks (:164). The two tables total 202.758 GB decimal / 188.8 GiB. On the failing starts they were essentially all on node 0:

  • file-rss:198224000kB = 189.0 GiB (the locked tables);
  • Node 0 ... mlocked:201740944kB = 192.4 GiB;
  • node 0 total managed = 251.4 GiB, leaving ~59 GiB.

mlock() does not migrate pages; it locks them where the page cache already has them. docs/SETTINGS.md:508-510 warns about exactly this:

Locked file mappings can reuse pages already on one socket even with an interleave policy. … Leave headroom on every node.

2. --mmap-experts off allocates host experts per node, with no RAM budget

For a non-GGUF pack, file_experts is false when --mmap-experts off (ds4_model.cu:2566-2582), and NH = min(2, cores.size()) = 2 (:3216). Every layer then does:

// ds4_model.cu:5181-5198 (v1.1.28)
} else if (n_host > 0) {
    const int n_parts = n_host + (l.spare_vram >= 0 ? 1 : 0);
    const size_t bytes = (size_t) n_parts * l.hl.bytes;
    for (int X = 0; X < NH; ++X) {
        void* m = node_map(bytes, X, NH);          // <- per-node host block
        ...
    }
}

node_map() (:212) is os::anon_alloc() (src/ds4/ds4_os.hpp:363):

void* m = ::mmap(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (m == MAP_FAILED) return nullptr;
madvise(m, bytes, MADV_HUGEPAGE);
if (node >= 0 && nodes > 1) {
    unsigned long mask[4] = {0, 0, 0, 0};
    mask[node / 64] = 1ul << (node % 64);
    syscall(SYS_mbind, m, bytes, 2 /* MPOL_BIND */, mask, 256, 0);
}

There is no ram_avail() / ram_room() / per-node free-memory check in place_experts() on Linux before this allocation. The only failure test is mmap() == nullptr, which does not fire under Linux overcommit. The mbind() return value is also ignored.

The total host copy is 106.3 GB (6,771 experts), split into two parts: ~53.15 GB per node / ~49.5 GiB per node. Node 0 has ~59 GiB after the Engram lock, so only ~8–10 GiB remains for page cache, kernel, and other tenants. The load's page cache alone can exceed that.

3. First touch happens during the expert copy

load_experts() (:5734) reads each expert and, for a non-VRAM expert, calls repack_part() (:5831) into the pre-allocated node-X block. repack_part() (:2416) does memcpy() into that block. That is the first touch of the anonymous pages — and the kernel trace's rep movsb fault path.

When node 0 reaches its min watermark, the allocation is still MPOL_BIND-ed to node 0. The kernel cannot fall back to node 1, so it invokes the OOM killer for the allocating task: CONSTRAINT_MEMORY_POLICY, nodemask=0.

4. Why global RAM checks did not catch it

ram_room() (:1212) is MemAvailable minus helper_pending; kRamMargin is 8 GiB (:1119). This is machine-global. The budget in copy_experts() (:5432) is:

const double can = std::min(avail == ~uint64_t{0} ? 1e300 : std::max(0.0, (double) avail - (double) kRamMargin),
                            commit_room());

But for a non-GGUF pack, copy_experts() is never called. The only call site is inside load_experts_mx() (:5334), which is entered only when L[0].lay.fmt == kFmtMXFP4 (:5735). The reported pack is EXL3, so the fatal path is place_experts() → load_experts(), which has no budget at all.

For NH=2, the correct budget is per node: a copy can fit globally but not on node 0. A global can therefore both over-selects experts and suppresses the "do not all fit" warning in exactly the case that fails. On the deployment side, the local preflight's only RAM gate is global free -g >= 300 GB (it passed at ~470 GB available at start), so it cannot catch a single-node shortfall either.

For a GGUF/MXFP4 pack, copy_experts() has the analogous bug: its budget is machine-global, while node_map() binds each half to a node. On a 2-socket host with one node already full, the same CONSTRAINT_MEMORY_POLICY kill follows. DS4_COPY_NUMA=1 works around that path by setting NH=1, which makes anon_alloc() skip the mbind() (:5457-5460). It does not affect place_experts(), so it is a no-op for the non-GGUF path in this report.

5. The missing "experts VRAM leaves over" line is expected

That line is printed only inside if (file_experts) (:3180-3206). With --mmap-experts off on a non-GGUF pack, file_experts is false, so the line is not expected. Its absence is not evidence of an unknown allocation site; the site is place_experts() + load_experts().

Why restarting does not help

After a SIGKILL, the kernel unlocks the mlocked file pages, but they stay in the page cache on the socket where they were. The next start's mlock() re-locks them in place rather than migrating them. The engine itself does not drop the page cache before mlock(), so node 0 stays full and every retry dies at the same point. This is the "ratchet" described in docs/SETTINGS.md:508-510.

A separate DS4_COPY_NUMA=1 attempt confirms this: numa-watch recorded node 0 falling from 232 GiB to 2 GiB while node 1 stayed at ~186 GiB, then ENGINE GONE:

12:25:36  node0 232G  node1 230G  mlocked   6G  avail 464G
...
12:28:40  node0   2G  node1 186G  mlocked 195G  avail 189G
12:28:45  ENGINE GONE (was 1868674)

That run had DS4_COPY_NUMA=1 in the config, which is consistent with the variable being ignored on this pack.

Workarounds

For this host (verified)

Rebalance node 0 before starting, then start under an interleave policy:

# stop other node-0 tenants first (vLLM workers, MATLAB, etc.)
sudo sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
numactl --interleave=all ./run-maya-ds4.sh

Keep DS4_COPY_NUMA=2 (or leave it unset). This made the load succeed here. The successful start reports:

ds4: CUDA0 layers [0, 39] ... experts 76.49 GB (8589 of 15360 in VRAM) ...
ds4: CUDA1 layers [0, 39] ... experts 76.49 GB (8589 of 15360 in VRAM) ...
ds4: 6771 routed experts on the CPU lane (106.3 GB of RAM, 2 NUMA parts), 52 threads
ready: https://127.0.0.1:8080/v1 ...

The per-node Mlocked is now balanced (~72 GiB on each node), instead of ~192 GiB on node 0.

Note: numactl --interleave=all alone does not move pages already cached on node 0; the drop_caches step is required. The interleave policy fixes the Engram/page-cache placement, but the expert blocks themselves are still MPOL_BIND-ed by mbind(), so it does not override the per-node bind.

Originally created by @zhangxiaoxing on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/507 # Load-time OOM kill on one NUMA node with `DS4_ENGRAM_RAM=1` + `--mmap-experts off` ## Summary On a 2-socket / 512 GB host, Maya v1.1.28 is reliably SIGKILLed by the kernel during load on **node 0**, while the machine still has ~195 GiB of `MemAvailable` and global memory PSI is 0.00. The kill is a node-local `CONSTRAINT_MEMORY_POLICY` OOM, not a machine-wide OOM: - `DS4_ENGRAM_RAM=1` maps and `mlock()`s the two complete Engram tables — 202.758 GB decimal (189 GiB). On the failing starts essentially all of it was resident on node 0 (`Node 0 ... mlocked:201740944kB`). - `--mmap-experts off` then puts all 6,771 CPU-lane experts (106.3 GB) into anonymous host memory. `place_experts()` allocates each layer's host block **separately per NUMA node** with `node_map()` → `anon_alloc()` → `mbind(MPOL_BIND, {node X})`. There is no check of node-local free memory on this path. - Node 0 had ~58–59 GiB left after the Engram lock. Its half of the expert blocks is ~49.5 GiB, leaving only ~8–10 GiB for page cache / kernel / other tenants. The load's page cache crosses that margin; the first touch of a node-0-bound block then hits the node's min watermark. `MPOL_BIND` forbids falling back to node 1, so the kernel kills the process instead of spilling. - For non-GGUF packs, `place_experts()` has **no RAM budget at all** on this path. For GGUF/MXFP4 packs the analogous `copy_experts()` path has a machine-global budget (`ram_room()` / `kRamMargin`) with per-node `MPOL_BIND` placement — the same class of bug. This is **not a v1.1.28 regression**. The same unguarded `node_map(bytes, X, NH)` host allocation exists in v1.1.24–v1.1.27; it is at `ds4_model.cu:4977` in v1.1.27 and `ds4_model.cu:5185` in v1.1.28. ## Environment | Item | Value | | --- | --- | | Maya | v1.1.28 (tag `6afa525`, local HTTPS patch on top; `VERSION 1.1.28`, build stamp `cf28053a13c8876d`) | | Previous version checked | v1.1.27 — same allocation path (`ds4_model.cu:4977`) | | Host | 2× Intel Xeon Gold 5320, 2 NUMA nodes, 104 logical CPUs, 512 GB DDR4 | | GPUs | 2× NVIDIA A100 80 GB, `--tp 2`, `--layer-split auto` | | OS / kernel | Ubuntu 24.04.5 LTS, kernel `6.8.0-136-generic` | | Pack | DeepSeek-V4.1-Flash-1017, EXL3 3.5 bpw (Maya EXL3 pack, `trellis` / `suh` / `svh` tensors; **not GGUF/MXFP4**) | | Pack location | network share (`/DPC_HOME/...`), 460.9 GB | | Engine args | `--pack … --max-context 262144 --tp 2 --mmap-experts off --dspark none` | | Engine env | `DS4_ENGRAM_RAM=1` | | Memlock | `ulimit -l unlimited` | The engine is started directly by `capture-engine.sh` (no server), with the same args/env as the service. The service path (`run-captured.sh`) shows the same failure, but the server reports only `exit code 1`. ## Steps to reproduce 1. On a 2-socket host with two NUMA nodes, start with the config above (`DS4_ENGRAM_RAM=1`, `--mmap-experts off`, `--tp 2`). 2. Ensure the Engram tables are already in page cache on one socket (this happens naturally after a previous start/kill; a cold cache with `numactl --interleave=all` may avoid it). 3. Run the engine directly and record memory/PSI: ```sh ulimit -l unlimited ./capture-engine.sh --timeout 1800 ``` 4. Observe: exit status `137`, the engine's stderr ends at `Engram RAM ONLY`, global `MemAvailable` is still very high, and the kernel log has a node-local OOM record. Local captures used for this report (to attach): `.stage/engine-capture-20261026-101643/` and `.stage/engine-capture-20261026-104645/`. | Capture | Engine PID (from strace) | Engine exit | Last memory sample before kill | | --- | --- | --- | --- | | `20261026-101643` | 1707741 | 137 | `10:18:14 used=315708MB avail=199731MB full avg10=0.00` | | `20261026-104645` | 1745546 | 137 | `10:48:21 used=322382MB avail=193057MB full avg10=1.26` | The two engine stderr files are byte-identical (31 lines each): 30 `Engram RAM file … locked` progress lines followed by the final `Engram RAM ONLY` line, then nothing. ## Expected behavior - If the CPU-lane experts do not fit the RAM this process can actually obtain **on each node**, the engine should copy only what fits and leave the rest in place (the GGUF path already has a "do not all fit" warning), or fail startup with a clear error before touching the pages. - It must not hard-bind an allocation that cannot fit its node and then let the kernel SIGKILL the process. - A global `MemAvailable` of ~195 GiB with 0.00 global PSI should not coexist with a fatal OOM. ## Actual behavior ### Kernel OOM record (trimmed from `/var/log/kern.log`) ```text Node 0 Normal free:190560kB min:223808kB ... mlocked:201740944kB all_unreclaimable? yes ... global free:46034760 pages (~184 GB free machine-wide) ... oom-kill:constraint=CONSTRAINT_MEMORY_POLICY,nodemask=0,...,task=maya-ds4,pid=1707741 ... Out of memory: Killed process 1707741 (maya-ds4) ... anon-rss:79860736kB file-rss:198224000kB ... ``` - Node 0: 186 MB free against a 218 MB min watermark. - Node 0: 192.4 GiB mlocked (the Engram tables), `all_unreclaimable? yes`. - Machine-wide: 46,034,760 free pages (~175.6 GiB / ~188.6 GB decimal), so this is not a global OOM. - `nodemask=0` + `CONSTRAINT_MEMORY_POLICY` means the faulting allocation was bound to node 0 and could not use node 1's free memory. ### `memory.log`: global memory was not exhausted From `.stage/engine-capture-20261026-101643/memory.log`: ```text 10:16:48 used=45054MB avail=470385MB full avg10=0.00 <- start 10:17:49 used=269263MB avail=246176MB full avg10=0.00 <- Engram tables locked 10:18:14 used=315708MB avail=199731MB full avg10=0.00 <- last sample before SIGKILL 10:18:19 used=193767MB avail=321672MB full avg10=1.22 <- process dead, memory released ``` At the kill, `MemAvailable` was 199,731 MB = **195.0 GiB**, and global PSI `full avg10` was **0.00**. From the post-lock sample to the last sample, machine-wide `used` rose by ~46 GB — the copy is 106.3 GB in total — while 195 GiB still appeared available. ### `engine.err`: the last line is the Engram lock ```text ds4: Engram RAM file 46 locked 94.76 / 98.31 GB ds4: Engram RAM file 46 locked 98.31 / 98.31 GB ds4: Engram RAM file 46 locked 0.27 / 3.07 GB ds4: Engram RAM file 46 locked 3.07 / 3.07 GB ds4: Engram RAM ONLY: 2 complete tables (Q6_K/IQ4_NL/FP8), 202.758 GB locked; reads use memcpy ``` No CUDA placement lines, no "experts VRAM leaves over" line, no error message. The next thing the process sees is SIGKILL. ### `signals.log`: SIGKILL on the main PID and its threads ```text 1709003 +++ killed by SIGKILL +++ ... 1707741 +++ killed by SIGKILL +++ ``` The main PID matches the `pid=1707741` in the kernel OOM record. The second capture's main PID is 1745546, matching the other record. ### Service/TUI ```text RuntimeError: the engine exited before it was ready (see .../maya-ds4.log) [X] Maya stopped: its server ended with exit code 1 ``` `serve/server.py:561` raises this when the engine dies before `READY`. The engine's real termination (SIGKILL; 137 in shell notation, -9 from `Popen.wait()`) is lost; the user sees the server's exit code 1. ## Root cause ### 1. The Engram tables are locked on one socket `DS4_ENGRAM_RAM=1` calls `EgReader::pin_range()` (`src/ds4/ds4_engram_io.hpp:140`), which `mmap()`s each table and `mlock()`s it in 256 MB chunks (`:164`). The two tables total 202.758 GB decimal / 188.8 GiB. On the failing starts they were essentially all on node 0: - `file-rss:198224000kB` = 189.0 GiB (the locked tables); - `Node 0 ... mlocked:201740944kB` = 192.4 GiB; - node 0 total managed = 251.4 GiB, leaving ~59 GiB. `mlock()` does not migrate pages; it locks them where the page cache already has them. `docs/SETTINGS.md:508-510` warns about exactly this: > Locked file mappings can reuse pages already on one socket even with an interleave policy. … Leave headroom on every node. ### 2. `--mmap-experts off` allocates host experts per node, with no RAM budget For a non-GGUF pack, `file_experts` is false when `--mmap-experts off` (`ds4_model.cu:2566-2582`), and `NH = min(2, cores.size()) = 2` (`:3216`). Every layer then does: ```c++ // ds4_model.cu:5181-5198 (v1.1.28) } else if (n_host > 0) { const int n_parts = n_host + (l.spare_vram >= 0 ? 1 : 0); const size_t bytes = (size_t) n_parts * l.hl.bytes; for (int X = 0; X < NH; ++X) { void* m = node_map(bytes, X, NH); // <- per-node host block ... } } ``` `node_map()` (`:212`) is `os::anon_alloc()` (`src/ds4/ds4_os.hpp:363`): ```c++ void* m = ::mmap(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (m == MAP_FAILED) return nullptr; madvise(m, bytes, MADV_HUGEPAGE); if (node >= 0 && nodes > 1) { unsigned long mask[4] = {0, 0, 0, 0}; mask[node / 64] = 1ul << (node % 64); syscall(SYS_mbind, m, bytes, 2 /* MPOL_BIND */, mask, 256, 0); } ``` There is **no `ram_avail()` / `ram_room()` / per-node free-memory check** in `place_experts()` on Linux before this allocation. The only failure test is `mmap() == nullptr`, which does not fire under Linux overcommit. The `mbind()` return value is also ignored. The total host copy is 106.3 GB (6,771 experts), split into two parts: ~53.15 GB per node / ~49.5 GiB per node. Node 0 has ~59 GiB after the Engram lock, so only ~8–10 GiB remains for page cache, kernel, and other tenants. The load's page cache alone can exceed that. ### 3. First touch happens during the expert copy `load_experts()` (`:5734`) reads each expert and, for a non-VRAM expert, calls `repack_part()` (`:5831`) into the pre-allocated node-X block. `repack_part()` (`:2416`) does `memcpy()` into that block. That is the first touch of the anonymous pages — and the kernel trace's `rep movsb` fault path. When node 0 reaches its min watermark, the allocation is still `MPOL_BIND`-ed to node 0. The kernel cannot fall back to node 1, so it invokes the OOM killer for the allocating task: `CONSTRAINT_MEMORY_POLICY, nodemask=0`. ### 4. Why global RAM checks did not catch it `ram_room()` (`:1212`) is `MemAvailable` minus `helper_pending`; `kRamMargin` is 8 GiB (`:1119`). This is machine-global. The budget in `copy_experts()` (`:5432`) is: ```c++ const double can = std::min(avail == ~uint64_t{0} ? 1e300 : std::max(0.0, (double) avail - (double) kRamMargin), commit_room()); ``` But for a non-GGUF pack, `copy_experts()` is never called. The only call site is inside `load_experts_mx()` (`:5334`), which is entered only when `L[0].lay.fmt == kFmtMXFP4` (`:5735`). The reported pack is EXL3, so the fatal path is `place_experts()` → `load_experts()`, which has no budget at all. For `NH=2`, the correct budget is per node: a copy can fit globally but not on node 0. A global `can` therefore both over-selects experts and suppresses the "do not all fit" warning in exactly the case that fails. On the deployment side, the local preflight's only RAM gate is global `free -g` >= 300 GB (it passed at ~470 GB available at start), so it cannot catch a single-node shortfall either. For a GGUF/MXFP4 pack, `copy_experts()` has the analogous bug: its budget is machine-global, while `node_map()` binds each half to a node. On a 2-socket host with one node already full, the same `CONSTRAINT_MEMORY_POLICY` kill follows. `DS4_COPY_NUMA=1` works around that path by setting `NH=1`, which makes `anon_alloc()` skip the `mbind()` (`:5457-5460`). It does **not** affect `place_experts()`, so it is a no-op for the non-GGUF path in this report. ### 5. The missing "experts VRAM leaves over" line is expected That line is printed only inside `if (file_experts)` (`:3180-3206`). With `--mmap-experts off` on a non-GGUF pack, `file_experts` is false, so the line is not expected. Its absence is not evidence of an unknown allocation site; the site is `place_experts()` + `load_experts()`. ## Why restarting does not help After a SIGKILL, the kernel unlocks the mlocked file pages, but they stay in the page cache on the socket where they were. The next start's `mlock()` re-locks them in place rather than migrating them. The engine itself does not drop the page cache before `mlock()`, so node 0 stays full and every retry dies at the same point. This is the "ratchet" described in `docs/SETTINGS.md:508-510`. A separate `DS4_COPY_NUMA=1` attempt confirms this: `numa-watch` recorded node 0 falling from 232 GiB to 2 GiB while node 1 stayed at ~186 GiB, then `ENGINE GONE`: ```text 12:25:36 node0 232G node1 230G mlocked 6G avail 464G ... 12:28:40 node0 2G node1 186G mlocked 195G avail 189G 12:28:45 ENGINE GONE (was 1868674) ``` That run had `DS4_COPY_NUMA=1` in the config, which is consistent with the variable being ignored on this pack. ## Workarounds ### For this host (verified) Rebalance node 0 before starting, then start under an interleave policy: ```sh # stop other node-0 tenants first (vLLM workers, MATLAB, etc.) sudo sync echo 3 | sudo tee /proc/sys/vm/drop_caches numactl --interleave=all ./run-maya-ds4.sh ``` Keep `DS4_COPY_NUMA=2` (or leave it unset). This made the load succeed here. The successful start reports: ```text ds4: CUDA0 layers [0, 39] ... experts 76.49 GB (8589 of 15360 in VRAM) ... ds4: CUDA1 layers [0, 39] ... experts 76.49 GB (8589 of 15360 in VRAM) ... ds4: 6771 routed experts on the CPU lane (106.3 GB of RAM, 2 NUMA parts), 52 threads ready: https://127.0.0.1:8080/v1 ... ``` The per-node `Mlocked` is now balanced (~72 GiB on each node), instead of ~192 GiB on node 0. Note: `numactl --interleave=all` alone does not move pages already cached on node 0; the `drop_caches` step is required. The interleave policy fixes the Engram/page-cache placement, but the expert blocks themselves are still `MPOL_BIND`-ed by `mbind()`, so it does not override the per-node bind.
Author
Owner

@ChicoPinto70 commented on GitHub (Oct 26, 2026):

Wow!!! I had the same problem!!! I had a OOM every time I disabled the mmap in my Dual Xeon E5-2699v3. But with the drop_cache solution, now, I can disable it and the TG improved from around 40 tok/s to 43 tok/s.

THANK YOU, @zhangxiaoxing !!!!!

<!-- gh-comment-id:6422868275 --> @ChicoPinto70 commented on GitHub (Oct 26, 2026): Wow!!! I had the same problem!!! I had a OOM every time I disabled the mmap in my Dual Xeon E5-2699v3. But with the drop_cache solution, now, I can disable it and the TG improved from around 40 tok/s to 43 tok/s. THANK YOU, @zhangxiaoxing !!!!!
Author
Owner

@mw00 commented on GitHub (Oct 27, 2026):

Thank you for the very clear analysis. You were right: the CPU lane's RAM copies were bound to their node with MPOL_BIND, so a node full of locked Engram tables meant an OOM kill even with half the machine free. In v1.1.34 the copies prefer their node instead of requiring it: they land there while it has room, and the rest goes to the other node rather than the process being killed. Placement is unchanged when both nodes have room. Your drop_caches + numactl --interleave=all workaround still helps keep the Engram tables balanced across the sockets, which is faster.

Closing - please reopen if v1.1.34 still stops at load.

Released in v1.1.34: https://github.com/mw00/project-maya/releases/tag/v1.1.34

<!-- gh-comment-id:6456002479 --> @mw00 commented on GitHub (Oct 27, 2026): Thank you for the very clear analysis. You were right: the CPU lane's RAM copies were bound to their node with MPOL_BIND, so a node full of locked Engram tables meant an OOM kill even with half the machine free. In v1.1.34 the copies prefer their node instead of requiring it: they land there while it has room, and the rest goes to the other node rather than the process being killed. Placement is unchanged when both nodes have room. Your `drop_caches` + `numactl --interleave=all` workaround still helps keep the Engram tables balanced across the sockets, which is faster. Closing - please reopen if v1.1.34 still stops at load. Released in **v1.1.34**: https://github.com/mw00/project-maya/releases/tag/v1.1.34
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#210
No description provided.