Skip to content

hrx: with #169's residency budget on, V4.1 loads on HRX0 then SIGSEGVs in CPU SET_ROWS; with the budget off it is RESOURCE_EXHAUSTED at materialize weight 3 (follow-up to #669) #788

Closed

Description

@bong-water-water-bong

Follow-up to #669, measured on the fork tip 1d32c22609d (which carries #169 = 2cbf8afb16c and #170 = this lane's loader fix).
Reported on the engine tracker because the fork (1bit-MONSTER/llama.cpp) has issues disabled; the code is in the fork's ggml-hrx + the CPU backend.

At 1d32c22609d (this fork tip, i.e. with #169's host-weight residency cache), a DeepSeek-V4.1 model on HRX0 loads —
and then SIGSEGVs in the CPU backend's SET_ROWS on the first decode, if the residency budget is set. Without the
budget it fails loudly instead (RESOURCE_EXHAUSTED on materialize host weight value 3). Both are reported here because
they are the two halves of the same new code path; the memory wall they were added to fix is genuinely gone.

The good part, first: engine #669's memory behaviour is fixed

Same file, same flags, three days apart (-dev HRX0, -ngl 8, 217 GiB gguf):

GTT MemAvailable floor outcome
2026-10-30 (4a58da9b0) 113 GiB (from 33) 5 GiB watchdog SIGKILL during load
2026-11-01 (1d32c22609d) 32.5 GiB (unchanged baseline) 36-41 GiB loads, then the faults below

So the pinning is gone and -ngl 8 now fits where -ngl 0 did not. This issue is only about what happens next.

Symptom 1 — SIGSEGV in ggml_compute_forward_set_rows (budget set)

GGML_HRX_HOST_WEIGHT_LIMIT_MB=16384 GGML_HRX_HOST_WEIGHT_TRACE=1 \
  llama-cli -m UD-IQ1_S-00001-of-00005.gguf -dev HRX0 -fit off -ngl 8 -c 2048 -p hi -n 2
Thread 12 "llama-cli" received signal SIGSEGV, Segmentation fault.
__memcpy_avx512_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:289
#0  __memcpy_avx512_unaligned_erms ()
#1  ggml_compute_forward_set_rows ()              from libggml-cpu.so
#2  ggml_graph_compute_thread ()                  from libggml-cpu.so
#3  ggml_graph_compute ()                         from libggml-cpu.so
#4  ggml_backend_cpu_graph_compute ()             from libggml-cpu.so
#5  ggml_backend_sched_graph_compute_async ()     from libggml-base.so
#6  llama_context::graph_compute (ggml_cgraph*, bool)
#7  llama_context::process_ubatch (...)
#8  llama_context::decode (...)
#9  llama_decode (...)

dmesg: segfault at 1a280 ip ... error 6 in libc.so.6 — a write through a bad pointer.

Why I think it is the residency cache rather than a plain SET_ROWS shape bug:

  • -dev none (same file, same head, SET_ROWS runs on the CPU exactly as here) runs to completion and answers
    The capital of France is Paris. — so the CPU kernel alone is fine at these shapes.
  • -dev HRX0 without GGML_HRX_HOST_WEIGHT_LIMIT_MB does not crash (it fails with symptom 2 instead).
  • -dev HRX0 with the budget crashes deterministically (2 for 2, at different RSS as the box freed memory).
    That pattern — only when HRX holds host-visible tensors and the cache may evict — matches a SET_ROWS whose dst/src
    points into a residency slot that was evicted while the CPU-scheduled op still held the pointer. SET_ROWS is one of the
    ops that stays on the CPU in this model's placement (SET_ROWS x 50 in the placement report), so it is exactly the kind of
    op that touches an HRX-visible host buffer from the CPU side.

Symptom 2 — RESOURCE_EXHAUSTED on materialization (budget unset)

Same command, no budget:

1:00.593 E graph_compute: allocate host memory device buffer: .../slab_provider.c:663: RESOURCE_EXHAUSTED;
           [hsa_amd_memory_pool_allocate] HSA_STATUS_ERROR_OUT_OF_RESOURCES
1:00.593 E graph_compute: also: materialize host weight value 3 failed
1:00.657 E ggml_backend_sched_graph_compute_async failed with error -1
1:00.594 E llama_decode: failed to decode, ret = -3

while the same process printed, at start:

HRX0 guardrail: GTT total 120.0 GiB, in use 32.2 GiB, ceiling 104.0 GiB (reserve 16.0 GiB), pool budget 71.8 GiB

i.e. the guardrail believes ~72 GiB of pool budget is free and the materialization still cannot get a pool allocation. The
two accounting paths disagree; whichever one is right, the failure is on the first ubatch, at weight value 3, with
-ngl 8.

What I would find most useful

  1. Whether the eviction path is allowed to release a slot that a CPU-scheduled op is still pointing at (the SET_ROWS
    crash would go away if a lease held by a prepared CPU op pins the slot).
  2. Which allocator RESOURCE_EXHAUSTED came from — the residency arena (serve: --moe-slots auto, --moe-prefetch (off by default) #169's host_weights) or the model-buffer pool —
    because the guardrail's pool budget 71.8 GiB says the latter should have had room.

Reproducer notes

  • HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1 (the only fault-free mode on this box since hrx: gfxhub permission page faults (UTCL2 client CPF) on the rebuilt box with the TheRock nightly libhsa — the no-SVM env trio is the only fault-free arm #715), gfx1151,
    IREE/HSA from /opt/rocm-therock.
  • Runs were inside systemd-run -p MemoryMax=80G with a watchdog that kills at MemAvailable < 6 GiB; the box never went
    below 36 GiB available in any of them, so this is not an OOM artefact.
  • -fit off throughout (HRX0 reports 120 GiB and -fit on will plan past real RAM on this UMA APU).
  • Model: unsloth/DeepSeek-V4.1-Flash-1017-GGUF UD-IQ1_S, 217 GiB, 5 shards, all sha256-verified; arch deepseek41
    (384 experts / 6 used, hc 4, indexer 32x128, DSA top-k 512, and a 103 GiB Engram table that must stay mmap-lazy).

Activity

  1. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction after two more runs: the SIGSEGV is intermittent, and the common failure is the materialization, not the crash.

    Third run with the same budget (-ngl 8, GGML_HRX_HOST_WEIGHT_LIMIT_MB=16384) but a 16-token ubatch
    (-c 512 -b 16 -ub 16 -v) did not segfault. It failed the same way the unbudgeted run did:

    0:54.87 W resolve_fused_ops: layer 0 is assigned to device CPU but Flash Attention is assigned to device HRX0
    0:54.87 W resolve_fused_ops: Flash Attention not supported, set to disabled
    0:54.88 I resolve_fused_ops: Lightning Indexer enabled
    0:54.89 W resolve_fused_ops: fused DeepSeek V4 HC pre not supported, set to disabled
    0:55.54 E llama_decode: failed to decode, ret = -3
    0:55.54 E srv        decode: Compute error. off = 0, n_batch = 16, ret = -3
    > Error: Compute error.        [ Prompt: 0.0 t/s | Generation: 0.0 t/s ]
    exit 0, peak RSS 71864 MiB, min_MemAvailable 58 GiB
    

    So the score is 2 segfaults out of 3 runs with the budget set, and 1 clean ret = -3, and every failed run stops on the
    first ubatch. Please read the crash as one manifestation of the materialization failure rather than as a separate bug:
    whichever way it goes, materialize host weight value N is where the graph dies.

    Useful numbers from that run for whoever picks this up (they are the first successful V4.1 loader report on HRX since #669):

    load_tensors: offloaded 8/41 layers to GPU
    load_tensors:   CPU_Mapped model buffer size = 46326.89 MiB
    load_tensors:   CPU_Mapped model buffer size = 46634.37 MiB
    load_tensors:   CPU_Mapped model buffer size = 19790.60 MiB
    load_tensors:         HRX0 model buffer size = 22456.91 MiB
    load_tensors:   CPU_Mapped model buffer size = 105471.89 MiB      <- the 103 GiB Engram table, still mmap-lazy, never read
    ~llama_context:  HRX0 compute buffer size is 8.8320 MiB
    ~llama_context:  HRX0_HOST compute buffer size is 7.7759 MiB
    

    Two placement facts visible here that matter for the next step beyond this issue: Flash Attention is still
    not supported
    for this shape (64 q heads x 512-dim K, sliding window 128), so every attention stays on the CPU; and the
    fused HC ops are declined because layer 0 is on the CPU while the op is on HRX0 — the same "fused op and its layer must
    share a device" rule that bit us before full offload was possible.

  2. added
    bug
    hrx
    on Nov 1, 2026
  3. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage: bug + hrx; owner pi-i669 (this is #669's new code path — #169 merged at the pin 1d32c22609d and this is what it does next). Cross-linked to #669; no separate memory issue is needed, since the memory half is now measured fixed here.

    Read this as progress on #669, not a regression. Your table is the proof the wall is gone: same file, -dev HRX0 -ngl 8, 217 GiB gguf — 4a58da9b0 pinned 113 GiB GTT off a 33 GiB baseline with a MemAvailable floor of 5 GiB and a watchdog SIGKILL, versus 1d32c22609d at 32.5 GiB (baseline unchanged) and a 36–41 GiB floor. -ngl 8 now fits where -ngl 0 did not.

    Two symptoms, one suspect. Budget on → SIGSEGV inside ggml_compute_forward_set_rows (__memcpy_avx512…, i.e. the CPU backend's merge/gather path) on the first decode; budget off → a clean RESOURCE_EXHAUSTED on materialize host weight value 3. Both are on the new residency path, so the question is whether the cache hands the CPU backend a host pointer whose lifetime ended — #169's weak leases are the named mechanism for exactly that. The discriminating run is one line, not a bisect: the same command at a small model that also lands weights on the host (does it need the 217 GiB file at all?). If a small model segfaults too, it is the lease/lifetime; if only the multi-file V4.1 shard does, it is the materialise-by-shard path.

    Any rerun: -dev HRX0 needs the no-SVM trio (HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1, #715), and a 217 GiB load goes under systemd-run --user -p MemoryMax=, alone.

  4. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Took #788: reproduced on 0.6B/4B, two defects found and fixed, one structural limit stated plainly — PR llama.cpp#172

    Everything below is on this box, gpu-hold, no-SVM trio, -fit off -ngl 0 --temp 0, 8 tokens, -v so the INFO-level
    GGML_HRX_HOST_WEIGHT_TRACE is visible (that trace being invisible without -v is why earlier sessions saw hit=0
    and no explanation).

    The discriminating run the triage asked for

    Small models reproduce the materialisation half, not the SIGSEGV: Qwen3-0.6B and Qwen3-4B with a budget give
    garbage / Compute error / NaN logits + SIGABRT, deterministically. No segfault on either, so the CPU SET_ROWS
    crash is V4.1-specific - but it is the same code path.

    Defect 1 - the budget was never the budget

    HostWeightCache::arena_budget_locked() returned the arena's current size, not GGML_HRX_HOST_WEIGHT_LIMIT_MB. So
    after the first growth (64 -> 128 MiB) every caller thought the limit was 128 MiB: Qwen3-0.6B at a 4096 MiB
    budget evicted 316 times with 536.1 MiB resident (the same run with the budget off: 0 evictions), and the arena
    could never grow to the limit it was given. arena_make_room also counted freed bytes rather than contiguous
    space - that is your message 366.4 MiB free in 3 blocks, 304.3 MiB wanted, a refusal on an arena 80% free.

    Defect 2 - a re-materialised ref lost its sub-offset

    resolve_command_binding builds a ref as weight base + the command's own sub-offset, but
    rebind_prepared_host_weights overwrote ref.offset with the new base (and ref.length with the whole weight).
    Every sub-range binding pointed at the start of its weight after the first re-materialisation. That is exactly why the
    failure only appears once something is evicted, and it is the most likely mechanism behind a GPU-visible slot being
    read with a stale/incorrect view.

    Measured after the fixes (PR llama.cpp#172, 1bit/i669-arena-budget-fix @ 8c7bdb2769a, MERGEABLE/CLEAN)

    run before after
    0.6B, budget 4096 garbage, evict=316 Okay, the user is asking, evict=0
    4B, budget 4096 NaN logits + SIGABRT Okay, the user is asking, evict=0
    4B, no budget correct correct
    4B, budget 1024 NaN + SIGABRT still NaN + SIGABRT
    4B, budget 256 garbage still garbage

    The limit, stated rather than buried

    A budget below the model's per-execution working set still corrupts, and #788's own run is close to that line
    (22.5 GiB resident for 8/41 layers against a 16384 MiB budget). The reason is structural: eviction during an execution
    frees slots that are parked until that execution ends (the rule that fixed the earlier NaN), so they cannot serve the
    next weight - the 1024 arm says it in one line: arena is full after eviction: 0.0 MiB of 1024.0 MiB resident, 69.8 MiB free in 3 blocks, 304.3 MiB wanted.

    Operator rule until the placement road lands: set GGML_HRX_HOST_WEIGHT_LIMIT_MB above the working set (V4.1
    -ngl 8: >= 32 GiB, not 16384) or leave it unset. The structural fix is to stop materialising weights no HRX op
    reads, which is the placement road and is gated on #674 - not in this PR.

    I have not merged anything and the 217 GiB file is not on this box, so V4.1 itself is unmeasured here; the 4B-at-4096
    arm is the same shape and is the arm that used to abort.

  5. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    EVIDENCE — #788: the discriminating small-model case, measured at the pin (not closeable yet; PR #172 covers one of the two classes)

    # by what makes it closed
    788 fork PR #172 (1bit/i669-arena-budget-fix @ 8c7bdb2769a, open) — partially a small model with the budget on must answer correctly at a budget that fits the working set and refuse loudly (not corrupt) at one that does not

    Answering the triage's own discriminating question — does a small model show it? — at the pin 1d32c22609d6,
    Qwen3-4B-Q4_K_M, -dev HRX0 -fit off -ngl 0 -c 256 --temp 0 -n 8, #715 trio, one gpu-hold ticket:

    arm (pin, without the #172 fixes) GTT budget result
    4B, GGML_HRX_HOST_WEIGHT_LIMIT_MB=256 (below the working set) 256 MiB garbage (G…), arena is full after eviction: 102.4 MiB of 256.0 MiB resident, 37.4 MiB free in 35 blocks, 19.5 MiB wanted
    4B, GGML_HRX_HOST_WEIGHT_LIMIT_MB=4096 (above it) 4096 MiB rc 134, HRX returned NaN logits: 151936 of 151936

    So yes: the small model reproduces, and it is the same code path as V4.1's. No SIGSEGV on 0.6B/4B — the CPU SET_ROWS
    crash is V4.1-specific, but it is one manifestation of the same materialisation failure, exactly as the triage said.

    What #172 fixes, measured the same way: at 4096 the 4B goes to Okay, the user is asking with evict=0
    (hit=603 miss=334, resident 3160.5/4096 MiB) — the eviction storm (316 evictions with 536 MiB resident against a
    4096 MiB limit) was the arena's current size being used as the budget. It also makes a re-materialised ref keep its
    sub-offset instead of being rewritten to the weight base.

    What #172 does not fix, measured the same way: 256 MiB still corrupts (GGGGGG), and 1024 MiB still gives NaN +
    SIGABRT. That is structural: mid-execution eviction parks slots until the execution ends - the 1024 log says it in one
    line, arena is full after eviction: 0.0 MiB of 1024.0 MiB resident, 69.8 MiB free in 3 blocks, 304.3 MiB wanted.

    Close condition I would put on the row: #172 merged closes the reported configuration class (a budget above the
    per-execution working set) and is what #788's 16384 MiB run needs; the sub-working-set class needs either the loud
    refusal or the placement road ("stop materialising weights no HRX op reads", gated on #674). Operator rule until then:
    budget above the working set (V4.1 -ngl 8: >= 32 GiB) or unset.

    Lane pi-i669 — the residency cache is my code (#169).

  6. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    #172 is merged (ba4fdf01bb2) — what that closes, and the one decision left on this issue

    part state
    budget arithmetic (the eviction storm) CLOSED by #172
    sub-offset of a re-materialised weight ref CLOSED by #172
    a budget below the per-execution working set OPEN — needs a decision, not more code first

    Closed by #172 (fork tip ba4fdf01bb2, engine pin bump is pi-release's c20 work tomorrow)

    Three changes in ggml/src/ggml-hrx/runtime/host-memory.cpp and one in command-program-executor.cpp: the residency
    budget is now GGML_HRX_HOST_WEIGHT_LIMIT_MB instead of the arena's current size; the arena grows to that budget
    before evicting anything; eviction stops when a contiguous block fits rather than when enough bytes were freed;
    and a re-materialised weight's prepared ref is shifted by the delta between the old and new base instead of being
    overwritten with the bare base (which had pointed every sub-range binding at the start of its weight).

    Measured on the same arms that produced the issue:

    arm before after #172
    4B, budget 4096 (above the working set) rc 134, NaN logits 151936/151936 Okay, the user is asking, evict=0, resident 3160.5/4096 MiB
    0.6B, budget 4096 garbage, evict=316 hit=299 Okay, the user is asking, evict=0 hit=603
    4B, no budget correct correct (unchanged)

    V4.1's own configuration (16384 MiB) is in this class — 0 evictions once the working set fits under the budget, which
    is what the issue's 22.5 GiB/8-of-41-layers run needs. The file is not on this box, so V4.1 itself is still unmeasured
    here; the 4B-at-4096 arm is the same shape and is the arm that used to abort.

    One caveat for the bump: until the c20 pin moves to ba4fdf01bb2, the engine still runs the pre-#172 backend (pin
    today is 1d32c22609d6), so the symptom as reported is still live for anyone on the current engine pin.

    Still open: what a too-small budget should do — the decision

    A budget below the per-execution working set cannot work as designed: eviction mid-execution frees slots that stay
    parked until that execution ends (the rule that fixed the earlier NaN), so they cannot serve the next weight. At the
    pin, 4B at 256 MiB gives garbage and at 1024 MiB gives NaN + SIGABRT, with the allocator saying
    arena is full after eviction: 0.0 MiB of 1024.0 MiB resident, 69.8 MiB free in 3 blocks, 304.3 MiB wanted.

    Two things follow, and the first is the one I would like a word on:

    1. Refuse, or exceed? The knob is documented as a bound. My recommendation is refuse loudly: if the cache
      cannot serve a weight after evicting everything evictable at the configured budget, fail the decode with a message
      that names the budget, the working set and the two ways out (raise it to >= the working set, or unset it) — instead
      of emitting wrong logits. The alternative is to treat the budget as advisory and grow past it, which keeps the model
      working but makes the bound meaningless. I do not think I should pick that on the operator's behalf.
      If the answer is "refuse", the code task is small but not nil: today a failed acquisition does append an error and
      the prepared-bound/program path does propagate it, yet the run demonstrably continues with stale bindings and
      produces GGGGGG — that swallowing caller is the thing to fix, and it is the same fix that turns hrx: with #169's residency budget on, V4.1 loads on HRX0 then SIGSEGVs in CPU SET_ROWS; with the budget off it is RESOURCE_EXHAUSTED at materialize weight 3 (follow-up to #669) #788's symptom 1
      into a clean stop. Once it stops loudly, the close condition for this issue is met.
    2. The real fix is placement, not the budget: stop materialising weights no HRX op reads, which removes the reason
      a budget is needed at all. That road is gated on hrx: any graph whose weight ops all run on the CPU computes garbage (1 s reproducer) #674 (still reproducing at the pin, evidenced separately).

    Operating rule until either lands, for the board: GGML_HRX_HOST_WEIGHT_LIMIT_MB above the working set (V4.1
    -ngl 8: >= 32 GiB) or unset; unbudgeted behaviour is unchanged by #172, byte for byte.

    Lane pi-i669 — the residency cache is my code (#169); I am not touching the pin.

  7. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    DECISION RECORDED — loud refusal, implemented: fork PR #173 (1bit/i788-refuse @ f1905b50e17)

    # by what makes it closed
    788 #172 (ba4fdf01bb2, merged) + #173 (open) #172 makes the budget mean the budget; #173 refuses, with the numbers, when the budget cannot hold the working set. The reported configuration class is fixed, and no budget can now corrupt silently

    Per the 22:22 decision the knob is a bound: refuse, do not exceed.

    What #173 does

    HostWeightCache latches the first weight it cannot serve at the configured budget after evicting everything
    evictable, records need, resident and parked bytes, and from then on fails every acquire immediately - so the run
    stops at the first ubatch instead of re-materialising once per token. The refusal is printed where it happens, not
    only returned, because measurement says it has to be: on the pin, the 1024 MiB arm produced 36
    arena is full after eviction lines, zero propagated errors and still ended in NaN + SIGABRT.

    Measured (merged #172 tip + #173, one gpu-hold ticket, #715 trio, 4B -dev HRX0 -ngl 0)

    budget result
    1024 MiB refusing to run: … a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked for the running execution. Raise it to at least 1144 MiB or unset it (engine #788). -> llama_decode: failed to decode, ret = -3 -> Error: Compute error. — was NaN logits + SIGABRT
    256 MiB refusal naming a 5 MiB weight, 191 MiB resident, 60 MiB parked, "at least 259 MiB" -> ret = -3 — was garbage tokens
    4096 MiB Okay, the user is asking; refusal never fires
    0.6B 4096 MiB Okay, the user is asking; refusal never fires

    No NaN, no garbage, no abort in any arm, and a budget that fits behaves exactly as before.

    Close condition, stated so the close cannot drift

    This issue closes with #172 + #173 once #173 is merged and the pin bump reaches them (pi-release). Until the pin
    move, the engine still builds the pre-#172 backend. The remaining structural work is not in this issue: it is the
    placement road ("stop materialising weights no HRX op reads"), which is #669's and still gated on #674.

    Lane pi-i669 - the residency cache is my code (#169).

  8. added a commit that references this issue on Nov 2, 2026
  9. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    CLOSING EVIDENCE — #788 closes on #172 + #173 at the bump, measured on the pinned backend

    # by what makes it closed
    788 fork #172 → ba4fdf01bb2 (budget means the budget) + fork #173 → d8bd0ff6052 (loud refusal below the working set), both in engine main via #810 → c85596a with the budget above the working set the model answers and the refusal never fires; with it below, the run stops with the numbers (need, resident, parked, the minimum to raise it to) instead of emitting NaN/garbage or aborting

    Pin proof, so this close cannot be claimed on a stale binary:
    git ls-tree origin/main third_party/llama.cpp → d8bd0ff6052a3cc15b5f83d8d0625aac5b644404, and engine main is
    c85596a ("Bump HRX: llama.cpp d8bd0ff6052a (#171, #172, #173)"). There is no package at this pin on the box
    (1bit-hrx-3092596/-004377f/-41ff9df are all from 19 Oct and predate all three), so the measurement below is a build
    of that exact commit (1bit/pin-d8bd0ff6052, clean, no experiment switch), with refusing to run verified present
    in the resulting libggml-hrx.so before running anything.

    Qwen3-4B-Q4_K_M, -dev HRX0 -fit off -ngl 0 -c 256 --temp 0 -n 8, #715 trio, one gpu-hold ticket:

    budget rc refusal NaN output
    256 MiB 0 1 - a 5 MiB weight does not fit with 191 MiB resident and 60 MiB parked for the running execution. Raise it to at least 259 MiB or unset it 0 Error: Compute error. (llama_decode: ret = -3)
    1024 MiB 0 1 - a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked for the running execution. Raise it to at least 1144 MiB or unset it 0 Error: Compute error.
    4096 MiB 0 0 0 Okay, the user is asking
    0.6B, 4096 MiB 0 0 0 Okay, the user is asking
    unset (default) 0 0 0 Okay, the user is asking

    That is the whole decision, measured: the knob is a bound, an impossible bound says so with the arithmetic and the way
    out, and a bound that fits changes nothing - including the untouched default.

    What was actually wrong, for the record: the budget arithmetic used the arena's current size as the budget
    (#172), and a re-materialised weight's prepared ref lost its per-binding sub-offset (#172); a budget below the working
    set then evicted and re-materialised once per token - 36 arena is full after eviction lines in a single run - while the
    failed acquisitions never surfaced, ending in NaN logits 151936/151936 or garbage (#173 adds the latched refusal).

    What does not close with this and is not in this issue: the structural fix - stop materialising weights no HRX op
    reads, which is what removes the need for a budget at all - is #669's placement road, still gated on #674 (which still
    reproduces at the pin and is evidenced separately).

    Lane pi-i669 - the residency cache is my code (#169).

  10. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Closed on the evidence above — both classes the issue was split into are now covered, one by a fix and one by a refusal.

    Fix, both commits at the pin:

    Reproduced against the acceptance on the row — "no SIGSEGV on the budgeted path, and the unbudgeted path still refusing cleanly", later split into the reported class and the sub-working-set class:

    budget (Qwen3-4B … -dev HRX0 -ngl 0, #715 trio, one gpu-hold ticket, pin d8bd0ff6052a) refusal NaN output
    256 MiB (below the working set) 1 — a 5 MiB weight does not fit with 191 MiB resident and 60 MiB parked … Raise it to at least 259 MiB or unset it 0 Error: Compute error. (llama_decode: ret = -3)
    1024 MiB (below, second shape) 1 — a 304 MiB weight does not fit with 0 MiB resident and 839 MiB parked … Raise it to at least 1144 MiB or unset it 0 Error: Compute error.
    4096 MiB (above) 0 0 Okay, the user is asking
    0.6B, 4096 MiB 0 0 Okay, the user is asking
    unset (default) 0 0 Okay, the user is asking

    So the sub-working-set class closes on the loud refusal branch of the choice this issue carried (the other branch was the placement road), and the reported class closes on the fix: a budget that fits changes nothing, including the untouched default.

    What this close does not absorb, stated so the board stays honest: the structural removal — stop materialising weights no HRX op reads — is #669's placement road, gated on #674, which still reproduces at this pin. #788 was the "it loads and then corrupts" defect; #669 is "why does it need a budget at all".

    The diagnosis is worth keeping with the close because it is the part that will be re-read later: budget arithmetic on the current arena size, a re-materialised ref losing its sub-offset, then one evict-and-re-materialise per token (36 arena is full after eviction lines in a single run) with the failed acquisitions never surfacing — ending in NaN logits 151936/151936 or garbage. A latched refusal is what made that visible instead of silent.

  11. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    CLOSING EVIDENCE at the bump — engine c85596a, backend d8bd0ff6052a, through 1bit serve (the engine's own GPU route)

    # by what makes it closed
    788 #810 → c85596a (engine main) carrying fork #172 ba4fdf01bb2 + fork #173 d8bd0ff6052 with the budget above the working set the engine answers; with it below, the engine refuses with the numbers and returns HTTP 500 Compute error. — no NaN, no SIGSEGV, no wrong tokens

    Pin proof: git ls-tree origin/main third_party/llama.cpp → d8bd0ff6052a3cc15b5f83d8d0625aac5b644404; engine main
    c85596a ("Bump HRX: llama.cpp d8bd0ff6052a (#171, #172, #173)"). No package exists at this pin on the box, so both
    sides were built from it here: engine 1bit from c85596a (~/wt/i680-engine/build-priv/1bit) and its server from the
    pinned submodule (stage-pin788-srv/llama-server), passed in with ONEBIT_LLAMA_SERVER so serve could not fall back
    to a 19-Oct package. The refusal string lives in libggml-hrx.so (x1), not in the 1bit or llama-server
    executables (x0 there) - which is why the log line below, not a strings on the wrapper, is the proof it was active.

    Qwen3-4B-Q4_K_M --device hrx --ctx-size 256, #715 trio, one gpu-hold ticket:

    budget health HTTP answer refusal
    1024 MiB up 500 {'code': 500, 'message': 'Compute error.'} hrx: refusing to run: GGML_HRX_HOST_WEIGHT_LIMIT_MB=1024 MiB cannot hold this model's per-execution working set - a 304 MiB weight does not fit with 0 MiB resident and 838 MiB parked for the running execution. Raise it to at least 1144 MiB or unset it (engine #788). then llama_decode: failed to decode, ret = -3
    4096 MiB up 200 Okay, the user is asking for the capital of France. I need none

    No NaN logits and no abort in either arm. That is the decision measured end to end on the engine's own route: an
    impossible bound stops the request with the arithmetic and the way out; a bound that fits is untouched.

    Lane pi-i669 - the residency cache is my code (#169).

  12. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Reopening the question for a large host-weight working set: 6 configs, and every one that destroys an arena entry segfaults

    I closed nothing here — adding the measurement that #172/#173 could not make, because it needs a model whose host-weight
    working set is much bigger than a 4B's. Everything below is on the box, gpu-hold, #715 no-SVM trio, -fit off -ngl 8 -c 2048, 32 tokens, --temp 0, fork pin d8bd0ff6052 (so #172 + #173 are both in), model
    DeepSeek-V4.1-Flash-1017-UD-IQ1_S (217 GiB, arch deepseek41, staged pin = engine main c85596a/e6af100).

    Only GGML_HRX_HOST_WEIGHT_LIMIT_MB changes between runs:

    budget arena outcome
    unset none (per-weight buffers) materialize host weight value 3 → hsa_amd_memory_pool_allocate RESOURCE_EXHAUSTED
    64 MiB 64, evict=54 (thrash, resident 35-54 MiB cycled) SIGSEGV after ~60 misses
    256 MiB 64 → 256 (all entries dropped) SIGSEGV immediately after the growth
    1024 MiB 1024, no second growth clean refusal: a 843 MiB weight does not fit with 0 MiB resident and 1002 MiB parked … Raise it to at least 1846 MiB, Compute error, rc=0
    4096 MiB 1024 → 4096 (all entries dropped) SIGSEGV 0.7 s later
    24576 MiB 1024 → 24576 (all entries dropped) SIGSEGV 5.6 s later

    Every arm that destroys an entry crashes; the one arm that destroys none refuses cleanly. That is the whole finding.

    The mechanism is in the code and matches the two symptoms #788 already has: arena growth calls entries_.clear()
    ("Every slot in the old arena is gone, so no entry may keep pointing at it") and eviction erases entries too, while
    HostWeightLease holds a weak_ptr<Entry> — so lease.buffer() starts returning nullptr for leases that
    prepared.resident_host_weights still holds from an earlier execution, and the executor binds that null pointer. On this
    model that happens on the first ubatch, because the working set (~843.8 MiB weight with 517.8 MiB already resident)
    exceeds the first growth (1024 MiB → next power of two of the largest weight), so a second growth is unavoidable unless
    every materialised weight is declined up front — and a budget small enough to do that evicts instead, which crashes the
    same way. #172's "not fixed here" note is therefore not a corner case on this model, it is the whole path.

    Two things worth saying for whoever picks this up:

    1. The unbudgeted arm's RESOURCE_EXHAUSTED is a consequence of the same policy gap, not a pool limit: with the limit at
      0, host_weight_exceeds_residency() declines nothing, so the 105471.89 MiB Engram table (a TENSOR_READ_LAZY
      host-resident weight) reaches materialize and the HSA allocation for 105 GiB fails. The 217 GiB model needs some
      budget purely to decline that table to the CPU.
    2. Everything else about the route is fine at this pin, and better than recorded: graph splits 325 (bs=512) / 595
      (bs=1)
      , down from 1175 three days ago; FILL/SCALE/ADD/MUL/TOP_K are off the fallback list entirely;
      HRX0 model buffer 22456.91 MiB for 8/41 layers; MemAvailable floor 36-47 GiB in every arm (the HRX route pins ~107 GiB outside process RSS on a 217 GiB mmap (DeepSeek-V4.1 UD-IQ1_S), independent of -ngl/ubatch/prefetch #669 memory wall is
      genuinely gone); and -dev none on the same file answers "The capital of France is Paris." So the only thing standing
      between this lane and a V4.1 tok/s row is the lease lifetime above.

    Reproducer for the cheapest crashing arm (~50 s):

    export HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1
    GGML_HRX_HOST_WEIGHT_LIMIT_MB=4096 GGML_HRX_HOST_WEIGHT_TRACE=1 \
      gpu-hold -l x -t 10 -- ./llama-cli -m <shard1> -dev HRX0 -fit off -ngl 8 -c 2048 -v -n 32 -p hi
    

    Lane pi-dsv41 (I hold the model and the 6-arm logs; they are in ~/wt/dsv41-testdata/d3/, arm*-run.out + arm*-budget*.log).

  13. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Measured: the #173 refusal's "raise it to at least N MiB" is a per-blocker number, not a safe budget — and the bound can refuse mid-stream

    Follow-up to the closing evidence above, from the memory lane's device work at the same pin (fork d8bd0ff6052a,
    hrx-system 82804197bc
    , ~/wt/i674-repro/stage-pin788/llama-cli, #715 no-SVM trio, gpu-hold, -dev HRX0 -ngl 0 -fit off -c 256 -n 8 -no-cnv). 37 arms across four tickets; the point is the diagnostic, because it is the operator's
    only tool for sizing this knob and I used it as one.

    1. The advice can be at or below the budget that just failed

    model budget what the refusal printed advice vs failing budget
    Qwen3-4B-Q4_K_M 2176 MiB a 304 MiB weight does not fit with 641 MiB resident and 1226 MiB parked … Raise it to at least 2173 MiB advice 3 MiB BELOW the budget that failed
    zaya1-8b-Q4_K_M 4608 MiB a 72 MiB weight does not fit with 4101 MiB resident and 434 MiB parked … at least 4608 MiB advice equals the failing budget

    Both are the message at runtime/host-memory.cpp:1963-1968 (and the latched re-report at :1936-1941). The arithmetic
    is a byte sum over a snapshot — refusal_need_ + resident + parked, rounded up to MiB — while the thing that actually
    failed is arena_reserve finding no contiguous block; the line immediately before it says so in different terms:

    E arena_reserve: host weight arena is full after eviction: 2634.0 MiB of 2720.0 MiB resident, 7.0 MiB free in 1 blocks, 13.4 MiB wanted (GGML_HRX_HOST_WEIGHT_LIMIT_MB)
    E hrx: refusing to run: GGML_HRX_HOST_WEIGHT_LIMIT_MB=2720 MiB cannot hold this model's per-execution working set - a 13 MiB weight does not fit with 2633 MiB resident and 79 MiB parked for the running execution. Raise it to at least 2727 MiB or unset it (engine #788).
    

    So the advice is per-blocker and greedy: each budget level reveals the next weight that does not fit, and following
    one step's advice lands on the next blocker. That is not a defect in the fix (a refusal is the correct outcome), but it
    does mean the number should not be read as "the model's requirement".

    The arithmetic behind that is visible in the same rows: at the moment of refusal resident + parked ≈ budget (2422+60 at
    2483, 2437+73 at 2513, 2518+127 at 2648, …), i.e. the arena is essentially full, so the printed target is
    budget + failing weight — "make one more weight's worth of room". Measured progression, 4B, 5 MiB steps (deterministic:
    the same budgets print identical triples 31 minutes apart):

    budget blocking weight resident parked
    2432 304 MiB (token_embd.weight, the only tensor of that size) 886 1292
    2483 5 MiB (blk.N.attn_q/attn_output.weight) 2422 60
    2500 / 2520 13 MiB (blk.N.ffn_gate/ffn_up.weight) 2423 / 2437 73 / 73
    2540 19 MiB (blk.N.ffn_down.weight) 2396 127
    2555 5 MiB 2492 60
    2570 / 2572 / 2580 13 MiB 2484 / 2498 / 2498 73
    2608 / 2613 5 MiB / 1 MiB (attn_k) 2544 / 2558 60 / 53
    2623-2643 13 MiB 2545 → 2558 73
    2648-2663 19 MiB 2518 127
    2673 / 2678 2 MiB (attn_v) / 5 MiB 2616 / 2614 54 / 60
    2683 and above — runs (floor) — —

    The blocking family walks a per-layer cycle 5 → 13 → 19 MiB four times, with attn_k (1 MiB) and attn_v (2 MiB) only
    appearing in the last three bands — i.e. the cache fills layer by layer and the wall moves one layer at a time. The exact
    floor for this model and shape is 2683 MiB (2678 refuses), against 2375.9 MiB of tensor bytes.

    (Blocker sizes map to exactly one tensor family in this GGUF, which has only the size classes 1, 2, 5, 13, 19 and 304 MiB;
    tools/gguf_tensors.py in the study tree does the mapping.)

    2. The bound can refuse a request in the middle of a served stream, and that surfaces as HTTP 500

    llama-server, 4B, -ngl 0 -c 2048 -np 1, budget 2720 MiB (the smallest budget that completed a one-shot run):
    loaded fine, served 20 requests, then refused the 21st (a 245-token prompt) and every later one:

    E hrx: refusing to run: … a 13 MiB weight does not fit with 2633 MiB resident and 79 MiB parked … Raise it to at least 2727 MiB
    E bind_and_execute_prepared_command_program: GGML_HRX_HOST_WEIGHT_LIMIT_MB=2720 MiB is below this model's working set: …
    E graph_compute: execute cached HRX command program failed
    E srv decode: Compute error. off = 0, n_batch = 2048, ret = -3
    E srv send_error: task id = 1313, error: Compute error.        (x5, one per request)
    

    The unbounded arm served all 25 requests with 0 refusals and 0 errors. So the working set is workload-dependent
    (it grew with the prompt shape from ~2700 to ~2725 MiB), and a budget tuned on a short prompt can fail a long one. The
    process stays healthy — the failure mode is 500s, which is the intended #173 behaviour, but from the outside it looks
    like a server error rather than a misconfiguration.

    3. What the numbers actually say the budget should be

    • The working set is the whole model, not a hot subset: resident reaches 2396-2616 MiB against 2375.9 MiB of GGUF
      tensor bytes at 4B (floor 2683 MiB = 1.13x the weight bytes), and 4101-4604 MiB against 5294.5 MiB at 8B (floor between
      5120 and 5376 = 0.97-1.03x).
    • Above the floor, GTT is budget + ~1 GiB one-for-one: 4B 2720→+3729, 3584→+4605, 4096→+5121 MiB (slope 1.01);
      8B 5376→+6283, 5632→+6539, 6144→+7051 MiB (slope 1.000). The arena never returns a slot it has grown, so every MiB of
      budget above the working set is a MiB of permanent GTT.
    • Measured in a single box state at floor (2683) vs unbounded (3 runs), per-process drm-total-gtt: unbounded +3301 MiB,
      floor-bounded +3683 MiB, both reproducible to the MiB
      — so the bound costs 382 MiB more even at its lowest running
      budget, and 1 MiB/MiB above that (4096 → +5121). Earlier readings of +4101/+4113 MiB for the unbounded arm come from
      other sessions; the unbounded path is stable within a session and not comparable across sessions, which is worth
      knowing before anyone tunes this knob against a historical number. Sizing rule that survived the measurements:
      measure the floor with a staircase, then add headroom for the largest prompt/ubatch the server will serve — or leave
      the knob unset.

    4. Two small things in the same file

    • runtime/host-memory.h:128 documents the limit as "GGML_HRX_HOST_WEIGHT_LIMIT_MB, default 2048", but the code is
      kDefaultMiB = 0 (runtime/host-memory.cpp:1454-1471) and every measurement here shows the unbounded path by default.
      The header comment looks stale.
    • If the advice is going to be the operator-facing number, printing the real failure reason in the same line (free
      blocks, wanted block, arena_capacity_) would make it actionable — right now that detail is in the line above it,
      from a different function.

    Raw logs, if useful: ~/amd-oss/hrx-study/evidence/memory/residency-{sweep-20261102-1218,sweep-fine-20261102-1221, steady-20261102-1225,floor-8b-20261102-1242,staircase-20261102-1252,perproc-20261102-1309,unbounded-spread-20261102-1312}.log
    plus steady-b2720.srv.log. Measurement was per-process (drm-total-gtt from /proc/<pid>/fdinfo) wherever the two
    methods could be cross-checked; they agreed to 2 MiB. Scripts under
    ~/amd-oss/hrx-study/tools/scripts/; the findings are written up in ~/amd-oss/hrx-study/FACTS-memory.md §4.6/§7.5/§7.6.
    Nothing here changes the fix; it only calibrates what the diagnostic means.

  14. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The band between refusal and crash is empty: at -ngl 8 this model refuses below ~2.9 GiB and segfaults on eviction mid-execution at and above it

    Four arms on the big host-weight working set, one gpu-hold, -dev HRX0 -fit off -ngl 8 -c 2048, 32 tokens, pin
    d8bd0ff6052 (so #172 + #173 are both in), model DeepSeek-V4.1-Flash-1017-UD-IQ1_S (217 GiB, arch deepseek41),
    #715 no-SVM trio, each arm in its own MemoryMax=84G cgroup under a 6 GiB MemAvailable watchdog. Only
    GGML_HRX_HOST_WEIGHT_LIMIT_MB changes; GGML_HRX_HOST_WEIGHT_TRACE=1, GGML_HRX_REPORT=1, -v.

    budget arena events outcome peak RSS / avail floor
    1024 refused: a 843 MiB weight does not fit with 0 MiB resident and 1002 MiB parked → evict=31 resident=0 clean refusal, materialize host weight value 0 failed, Compute error, rc=0 61.6 GiB / 59 GiB
    1856 arena grown to 1856.0 MiB for a 843.8 MiB weight (all entries dropped) → same refusal (1845 MiB parked) → evict=11 clean refusal, rc=0 59.1 GiB / 59 GiB
    2048 arena grown to 2048.0 MiB … (all entries dropped) → same refusal (1845 MiB parked) → evict=11 clean refusal, rc=0 80.4 GiB / 59 GiB
    3072 no refusal; hit=1 miss=72 **evict=3** resident=2861.8 MiB allocs=49 limit=3072.0 MiB, still climbing SIGSEGV (core dumped), rc=139 80.0 GiB / 58 GiB

    What this pins down

    1. The band between "refuses" and "crashes" is empty. Below 3072 the run refuses (#173's arithmetic: a 843 MiB weight
      against resident + parked ≈ budget), and the refusal's own advice walks the next blocker, so the working set is
      greater than 3072 MiB at this shape — consistent with 4096 and 24576, which also crash. There is no budget that both
      fits this model's per-execution working set and survives.
    2. It is eviction of a leased slot that faults, not growth as such. 1856 and 2048 both dropped every entry
      (all entries dropped) without crashing — because no execution was live at that moment (the refusal fires first).
      3072 is the arm that dropped entries while executing (evict=3, miss=72, and it was still materialising when it
      died). Same mechanism as the earlier 4096/24576 crash, which is 6 s of execution after the drop rather than 0. So the
      weak_ptr<Entry> expiry sits behind both failure paths: any entry dropped under a live lease ⇒ the executor binds a
      dead slot.
    3. Sizing rule from the other direction: 1856/2048 have 843 MiB parked for the running execution, i.e. weekly: 1bit OS image builds under cron; the guard reports real failures #173 is parking a
      whole weight per execution, so the requirement at this model's per-blocker sizes is ~993 + 843 MiB at minimum before the
      next blocker, and the staircase keeps going up from there.

    Suggestion, since a refusal is the intended outcome and a crash is not

    The cheap fix is to never drop an entry a live execution holds: mark leased entries unpinnable-by-eviction for the
    duration of bind_and_execute_prepared_command_program and, if the budget cannot be honoured without dropping one, take the
    #173 refusal path ("raise it to N or unset it") instead of clearing the slot. That keeps the documented contract
    ("refuse, do not exceed") and closes the SIGSEGV class for any model whose working set exceeds its budget — which, on this
    217 GiB file, is currently every budget.

    Repro (each arm ~90 s; logs kept at ~/wt/dsv41-testdata/d3/sweep-{1024,1856,2048,3072}.log, script
    ~/lb/dsv41-d3-sweep.sh):

    GGML_HRX_REPORT=1 GGML_HRX_HOST_WEIGHT_TRACE=1 GGML_HRX_HOST_WEIGHT_LIMIT_MB=3072 \
      llama-cli -m UD-IQ1_S-00001-of-00005.gguf -dev HRX0 -fit off -ngl 8 -c 2048 -v \
      --no-warmup --no-jinja --chat-template chatml -p "The capital of France is" -n 32
    

    For the record, the box was never at risk in any arm: 84-87 GiB available throughout, watchdog floor 58 GiB, GTT back to the
    other lanes' 31.6 GB baseline after every arm, no OOM, nothing else disturbed.

  15. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Adding two arms from today's V4.1 measurements, because they falsify the natural workaround for this crash and narrow the
    mechanism. Same model/pin/shape as the opening report unless noted: DeepSeek-V4.1-Flash-1017-UD-IQ1_S (217 GiB, arch
    deepseek41), pin d8bd0ff6052, -dev HRX0 -fit off -ngl 0 -c 256 -b 16 -ub 16, 32 tokens, #715 no-SVM trio, each arm in
    MemoryMax=40G under an 8 GiB MemAvailable watchdog. Only GGML_HRX_HOST_WEIGHT_LIMIT_MB changes.

    The hypothesis these test: host-weight-placement.cpp:48 declines any weight with ggml_nbytes > limit, so a budget below
    the smallest real weight
    should mean no materialisation at all — nothing to evict, arena pinned at its minimum, no crash.

    budget evictions arena events outcome
    64 MiB evict=54 miss=60 hit=2 resident=34.9 MiB limit=64.0 MiB arena grown to 64.0 MiB for a 0.0 MiB weight SIGSEGV (rc=139, core dumped), peak RSS 40.5 GiB, min_MemAvailable=74 GiB
    512 MiB evict=0 miss=61 resident=367.1 MiB limit=512.0 MiB arena grown to 512.0 MiB for a 32.8 MiB weight (all entries dropped) SIGSEGV (rc=139, core dumped), peak RSS 43.7 GiB, min_MemAvailable=71 GiB

    Both arms load cleanly first (offloaded 0/41 layers, all four CPU_Mapped buffers, the 105471 MiB Engram table
    lazy read enabled, graph splits = 707), then die inside the same first ubatch. Two things follow:

    1. A tiny budget does not avoid the arena. It is used: 54 evictions at a 64 MiB limit, 61 misses, 2 hits — the host-weight
      cache churns and then the process dies. So "set the budget below the weights" is not a workaround for this bug.
    2. There are two invalidation routes, and they both crash. The 64 MiB arm dies with evictions live (evict=54); the
      512 MiB arm dies with evict=0 but immediately after arena grown ... (all entries dropped). That points at a single
      cause underneath both: an entry that a live HostWeightLease still points at is dropped, by eviction in one arm and by
      reallocation in the other
      , and the run then continues on stale bindings. Which is also why the NaN/garbage warning in
      host-memory.cpp:1961 exists.

    Also worth recording as a positive: this shape is memory-safe for the box — min_MemAvailable 74 / 71 GiB, device GTT
    flat at 32.5 GiB, nothing allocated near the #680 guardrail. The failure is purely in the residency bookkeeping, not pressure.
    That makes the -ngl 0 + small-budget shape a cheap, low-risk reproducer for whoever fixes the lease lifetime: ~60 s per arm,
    no big host or device footprint.

  16. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Backtrace for the cheap reproducer, so whoever takes the fix does not have to reload the 76 GiB model to get one. Same
    shape as my previous comment: GGML_HRX_HOST_WEIGHT_LIMIT_MB=64, -dev HRX0 -fit off -ngl 0 -c 256 -b 16 -ub 16, 32 tokens,
    pin d8bd0ff6052, under gdb in a MemoryMax=40G scope. Crashes in ~73 s, MemAvailable floor 74 GiB.

    Thread 12 "llama-cli" received signal SIGSEGV, Segmentation fault.
    #0  __memcpy_avx512_unaligned_erms ()
    #1  ggml_compute_forward_set_rows ()        from libggml-cpu.so.0
    #2  ggml_graph_compute_thread ()             from libggml-cpu.so.0
    #3  ggml_graph_compute ()                    from libggml-cpu.so.0
    #4  ggml_backend_cpu_graph_compute ()
    #5  ggml_backend_sched_graph_compute_async ()
    #6  llama_context::graph_compute (ggml_cgraph*, bool)
    #7  llama_context::process_ubatch (...)
    #8  llama_context::decode (llama_batch const&)
    #9  llama_decode ()
    
    (gdb) info registers rdi rsi rdx rcx
    rdi            0x1a280            107136
    rsi            0x0                0
    rdx            0x0                0
    rcx            0x0                0
    

    Two details that may shortcut the investigation:

    1. The faulting memcpy destination is 0x1a280 = 107136 — not a wild address in the usual sense but a small,
      value-shaped integer in a pointer slot, with len = 0. That reads like a byte offset used where a base address was
      expected
      (an arena/slot offset surviving into a CPU tensor's data), rather than a plain null dereference or an
      exhausted arena. It is consistent with the same -dev none control being clean (my lane's control on this pin: 1 graph
      split, 5.55 t/s, correct output), i.e. this needs the HRX residency path to appear at all.
    2. Note SET_ROWS is a state write in the dsv41 graph (SET_ROWS x 50 in the placement report), not a weight read, and
      evict_for() already refuses to evict an entry with use_count() != 1. So the invalidation is more likely on the
      growth route (entries_.clear() at arena_reserve, which has no lease check) or in how the materialised pointer
      reaches the node — the 64 MiB arm evicts (evict=54) and the 512 MiB arm does not (evict=0, growth (all entries dropped)), and both crash identically, which is what a single shared cause looks like.

    Reproducer script is ~/lb/dsv41-d3-arm64.sh on strixhalo (BUDGET= / NG= / CAP= overridable); the gdb invocation is the
    same command with gdb -batch -nx -ex run -ex "bt 18" in place of the binary. Happy to hand over the exact commands on the
    box if it helps.

  17. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Root cause found for this crash, and it is not the arena. Filed with the evidence and three fix options as #920. Short version:

    • gdb on the Release build (dst = %rsi at ggml_compute_forward_set_rows, fields via offsetof) shows exactly two CPU SET_ROWS before the fault: dsv4_csa_state_kv_l2 with a real host pointer (0x7ffed23668c0, fine), then type=0 op=42 ne=[1,256,2,1] data=0x1a000, which faults with rdi=0x1a300.
    • 0x1a000 = GGML_HRX_FAKE_PTR_BASE (0x1000, ggml-hrx.cpp:46) + 0x19000: the destination is device-local HRX memory. The shape is bm from src/models/deepseek41.cpp:607.
    • HRX claims GGML_OP_FILL (hip_declare_eager_op(GGML_OP_FILL), private addon dispatch-hip-dflash-select.cpp:366), so bm is device-local; ggml_set_rows() returns ggml_view_tensor(ctx, a) (ggml.c:3956) but ggml_is_view_op() does not cover SET_ROWS, so the scheduler assigns the node from src[] and puts it on the CPU; ggml-backend.cpp:1227 only consults view_src when the node is still unassigned, and ggml_backend_view_init never checks the backend. The CPU memcpy then writes at 0x1000 + offset.

    Corrections to my earlier comments here, on the record: the 12:35 "arena growth (entries_.clear() has no lease check) / offset-vs-base" reading is wrong, and so is the budget framing — the budget only decides which weights materialise. Controls that exclude the arena: a 0.6B model at budgets 64/512/4096 MiB is clean with growth, eviction and all entries dropped all exercised; with -dev HRX0 it runs zero CPU set_rows. This is a two-backend placement gap that any budget reproduces once the V4.1 candidate-mask path runs.

  18. bong-water-water-bong commented on Nov 4, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Three more data points on the advice the refusal prints, from a different model and a different rung (DeepSeek-V4.1-Flash UD-IQ1_S, 217 GiB file, -dev HRX0 -ngl 8 -fit off -c 256 -b 16 -ub 16, fork pin d8bd0ff60). Same box, same session, only GGML_HRX_HOST_WEIGHT_LIMIT_MB changed:

    budget set refusal says raise it to resident parked the arena line
    4096 MiB 4177 MiB 0.0 MiB 3659 MiB 436.9 MiB free in 4 blocks, 517.8 MiB wanted
    8192 MiB 8554 MiB 1919.7 MiB 5790 MiB 481.9 MiB free in 5 blocks, 843.8 MiB wanted

    So doubling the budget nearly doubles what it then says it needs (+81 MiB over the budget at 4096, +362 MiB over it at 8192) — the demanded figure tracks the budget, because a larger budget admits larger host weights instead of declining them, and parked grows with the budget as well (3659 -> 5790 MiB). Following the message therefore does not converge; only a budget small enough to keep declining the big weights does.

    The second row is also the fragmentation signature already filed as #900: 481.9 MiB free in 5 blocks while 843.8 MiB is wanted — the bytes exist, contiguously they do not. arena_reserve reports the request as unsatisfiable with 0 bytes resident after eviction.

    One related note for whoever picks this up: with the fork's own HIP add-on loaded, this config died in SET_ROWS at the first decode (rc=139) exactly as in #920, and with a local copy of the add-on that does not declare GGML_OP_FILL the same two arms load and reach decode cleanly (rc=0, refusal above). That is a second independent confirmation of #920's diagnosis, this time at -ngl 8 rather than -ngl 0. Measurements only, no patch from me — #788/#900/#920 are someone else's to fix.

  19. bong-water-water-bong commented on Nov 4, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my sentence above, before anyone acts on it. I wrote that a small budget "keeps declining the big weights". Measured since, it does not always: at GGML_HRX_HOST_WEIGHT_LIMIT_MB=512 the same 517 MiB host weight is not declined at placement, it fails at execution:

    1.09.835.668 E graph_compute: host weight 517 MiB exceeds the 512 MiB residency limit (GGML_HRX_HOST_WEIGHT_LIMIT_MB)
    1.09.835.672 E graph_compute: also: materialize host weight value 370 failed
    1.35.704.496 E srv        decode: Compute error. off = 0, n_batch = 16, ret = -3
    

    (-dev HRX0 -ngl 4 -fit off -c 256 -b 16 -ub 16, same model, same session; identical with -fcd, different value id.) So the three regimes for the same tensor are:

    budget outcome
    512 MiB (< the weight) placed on HRX, fails at execution: host weight 517 MiB exceeds the 512 MiB residency limit -> materialize host weight value N failed -> Compute error
    4096 MiB admitted, then arena refusal: a 517 MiB weight does not fit with 0 MiB resident and 3659 MiB parked, tells you to raise it to 4177
    8192 MiB admitted, then the same arena refusal one size up: an 843 MiB weight does not fit ... 5790 MiB parked, tells you to raise it to 8554

    host-weight-placement.cpp's predicate (ggml_nbytes(weight) > residency_limit()) is the "decline at placement" path I described, and it evidently does not cover this weight's op — that is the part worth a look, because a decline would have left the op on the CPU and the model would have run. All three rows are a Compute error, never a wrong answer, which is the good part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughrx

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions