Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/llama-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,9 @@ int llama_context::decode(const llama_batch & batch_inp) {
{ // warm the page cache for this batch's per-layer-embedding rows while the first chunk is on the GPU;
// posix_fadvise only, so a wrong prediction costs readahead and nothing else
extern void qwen4exp_ple_prefetch(const llama_model & model, const llama_token * tokens, int32_t n_tokens);
if (batch_inp.token && batch_inp.n_tokens >= 4096) { qwen4exp_ple_prefetch(model, batch_inp.token, batch_inp.n_tokens); }
if (model.arch == LLM_ARCH_QWEN4EXP && batch_inp.token && batch_inp.n_tokens >= 4096) {
qwen4exp_ple_prefetch(model, batch_inp.token, batch_inp.n_tokens);
}
}
const uint32_t n_outputs_all = balloc->get_n_outputs();

Expand Down
6 changes: 6 additions & 0 deletions src/models/qwen4exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,12 @@ void qwen4exp_ple_prefetch(const llama_model & model_base, const llama_token * t
if (!tokens || n_tokens < 4096) {
return;
}
// llama_context::decode calls this for every architecture, so the downcast below is only valid
// once the arch is known: on any other model it reads ple_disk out of an unrelated object and
// dereferences whatever that happens to hold.
if (model_base.arch != LLM_ARCH_QWEN4EXP) {
return;
}
const auto & pmodel = static_cast<const llama_model_qwen4exp &>(model_base);
if (!pmodel.ple_disk || !pmodel.ple_disk->page_cached()) {
return;
Expand Down
Loading