prefill: the fused layout's smaller MoE buffers only when the native kernels cover EVERY layer

fused_layout() (STRATA_PF_FUSED=1) shrinks GU / H / Xq to the fused kernels' needs whenever
fused_ring() is true, and fused_ring() was true when ANY layer of a native pack was covered. A pack
with an uncovered layer - Unsloth UD-IQ4_XS: 5 layers with Q8_0 down projections - then ran MMQ for
those layers at the full chunk in buffers sized for stream_all_min() - 1 tokens: on gfx1151 an 8K
prompt answered "!!!!..." and a 64K prompt hung (--prefill 2048: an illegal memory access). Such a
pack now keeps MMQ's buffers; its covered layers still take the fused kernels. UD-IQ4_XS 8K
retrieval after the fix: 3/3 correct, 837.9 prompt tok/s. (The CUDA path shares this code.)
This commit is contained in:
Niko1221 committed 2026-10-03 00:38:10 +02:00
1 parent 69f4d94801
commit 2c9fe45edb
1 file changed
+8 -4
+8 -4
View File
@@ -123,12 +123,16 @@ inline bool fused_ring() {
if (core::peer_portable()) return false; // multi-GPU: --peer-device keeps the MMQ path and its buffer sizes
const strata::kernels::cpu::ExpertLayout& lay = strata::kernels::cpu::expert_layout();
if (!lay.native) return true;
static const bool any = [&lay] {
// EVERY layer: fused_layout() shrinks the MoE buffers to the fused path's needs, so a layer the native kernels do
// not cover (Unsloth UD-IQ4_XS's Q8_0 down projections) would run MMQ in them at the full chunk and overflow them
// (garbage, an illegal memory access or a hung prompt on gfx1151). A pack with such a layer keeps MMQ's buffers;
// its covered layers still take the fused kernels.
static const bool all = [&lay] {
for (const auto& f : lay.fmt)
if (fused::native_supported(f.gu_type, f.d_type)) return true;
return false;
if (!fused::native_supported(f.gu_type, f.d_type)) return false;
return !lay.fmt.empty();
}();
return any;
return all;
}
// the largest ring: 512 slots; 1024 with the Q2_0 pack's fused experts (P3's smaller buffers, measured there) - the
// native packs' fused layers were measured at 512