From 69f4d948019d598f69876a855cf239a59fd310f2 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 2 Oct 2026 23:47:59 +0200 Subject: [PATCH] prefill: the resident lookup in the streamed walk indexes by the model's expert count (#531 follow-up) #531's peer-aware lookup indexed the residency table with the 512-expert constant NE instead of the model's own count. The Coder has 256 experts per layer, so from its second layer a resident expert was looked up in the wrong row, and a prompt long enough for the streamed walk stopped with "an expert is neither resident, streamed nor on the peer" (found by the 57K real-use check). The 512-expert models index the same row as before. --- src/prefill/prefill.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 03529cf1..0c77ad26 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -2521,8 +2521,8 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e consumed = ++k; if (!group_gather || gg_nslots == 0) give_back(consumed); // its group was gathered } else { - const bool r0 = m.host_res && m.cache && m.host_res[(size_t) l * NE + e] >= 0; - const uint8_t* bp = r0 ? m.cache->device_slot(m.host_res[(size_t) l * NE + e]) + const bool r0 = m.host_res && m.cache && m.host_res[(size_t) l * m.g->n_expert + e] >= 0; + const uint8_t* bp = r0 ? m.cache->device_slot(m.host_res[(size_t) l * m.g->n_expert + e]) : (m.pp ? m.pp->peer->slot_ptr(l, e) : nullptr); // over the cap: P2P if (bp == nullptr) { err = "prefill: an expert is neither resident, streamed nor on the peer"; return false; } ++stats_.experts_resident;