Conversation
llama_context::decode calls qwen4exp_ple_prefetch for every architecture once
a batch reaches 4096 tokens, and the function immediately downcasts the model
to llama_model_qwen4exp. On any other architecture that reads ple_disk out of
an unrelated object; when those bytes are non-zero the null check passes and
page_cached() dereferences them.
Reproduced on gfx1151 (ROCm 7.2.1) with Signal-3.8-27B-AP-Q4_K_XL (qwen35):
llama-bench -m <model> -ngl 99 -fa on -p 4096 -b 4096 -ub 4096
-> SIGSEGV in llama_ple_disk::page_cached() const
from qwen4exp_ple_prefetch(llama_model const&, int const*, int)
from llama_context::decode(llama_batch const&)
Any non-qwen4exp model crashes at ubatch >= 4096; ubatch <= 2048 never reaches
the call. qwen4exp models are unaffected, which is why this survived review.
Guards both the call site and the function. After this, the same command runs
at ubatch 4096, 8192 and 16384 on qwen35 (dense) and gemma4/gpt-oss (MoE).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
llama_context::decodecallsqwen4exp_ple_prefetchfor every architecture once a batchreaches 4096 tokens (
src/llama-context.cpp:1745), and the function immediately downcasts themodel to
llama_model_qwen4expand readsple_diskfrom it. On any other architecture thatoffset holds an unrelated object; when those bytes are non-zero the
!pmodel.ple_diskcheckpasses and
page_cached()dereferences them.Any non-qwen4exp model therefore segfaults at ubatch >= 4096. qwen4exp models are unaffected,
because there the cast is valid — which is why this survived review of #63.
Reproducer, on master
8c1c282ec:llama-bench -m Signal-3.8-27B-AP-Q4_K_XL.gguf -ngl 99 -fa on -p 4096 -n 0 -b 4096 -ub 4096 # -> exit 139 (SIGSEGV)Guards both the call site and the function, so any future caller is safe too.
Measurements
Not applicable: this only stops a call that must not happen on these architectures. The guarded
path is qwen4exp-only and unchanged there; no kernel, dispatch or graph behaviour is touched.
Prefill/decode throughput on qwen4exp is unaffected by construction.
Correctness: before this patch, ubatch 4096 / 8192 / 16384 all exit 139 on
Signal-3.8-27B-AP-Q4_K_XL(qwen35) andQwen3.8-27B-GSQ-RCO-IQ3_S(qwen35). After it, all ofthem complete:
gemma-4-26B-A4B and gpt-oss-20b (MoE) also run clean at ubatch 2048-16384 after the fix.
test-backend-ops -b ROCm0passes 29695/29695 on master, before and after — the crash is on thehost side, so op coverage never saw it.
Additional information
Noted while reading, not fixed here: the detached prefetch thread captures
&pmodeland&hpbyreference, so a model freed while it runs would leave it reading dead memory. It needs the model
to outlive a detached thread that nothing joins.
The default ubatch is 512, so this never fires in a default
llama-serverorllama-benchrun —only when someone raises
-ubto 4096 or beyond, which is exactly what the large-prefillconfigurations do.
qwen4exp verification (added after the first draft)
The guarded-in path was since exercised with
ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUFQ2_0(
qwen4exp), to confirm this does not guard out the architecture the prefetch exists for:pwilkin/strix-halo official merge #63 alone — no crash, no change.
--lazy-mode on-direct, the only route intollama_ple_diskand therefore the only configurationwhere
qwen4exp_ple_prefetchdoes real work: pp4096 548.48 / tg32 29.82 with this PR, 549.72 /29.31 on master. The reader and the prefetch both run.
So qwen4exp keeps the prefetch and every other architecture stops taking the invalid downcast.
Requirements
belong in halo-box/llama.cpp instead
description, and ran every measurement; the owner reviews.
readahead help?) was not measured, only that the path runs without crashing.