From 9341ebd2138420dd6ef28eacd429ad578e8d7fb3 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Tue, 13 Oct 2026 07:39:25 +0200 Subject: [PATCH] strata-q36 hybrid: the whole-layer prompt copy when fewer than half the experts are resident Many small copies were slower than the one whole-layer copy on a 12 GB card (RTX 3060, UD-Q4_K_XL at 37 of 256 resident: pp2048 1540 in runs, 1974 whole). gfx1201 UD-Q6_K_XL (205/256) and Q8_0 (176/256) keep the per-expert copies: pp4096 3504-3588 and 3015-3079. --- src/qwen35/q36_engine.cu | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qwen35/q36_engine.cu b/src/qwen35/q36_engine.cu index 7bb26ec3..61af1115 100644 --- a/src/qwen35/q36_engine.cu +++ b/src/qwen35/q36_engine.cu @@ -1543,7 +1543,9 @@ struct Engine { static const bool all = std::getenv("STRATA_Q36_STREAM_ALL") != nullptr; const int ne = (int) m->g.n_expert; const Hy& H = hy[(size_t) stream_seq[(size_t) i]]; - if (all || L.n_slots <= 0) { + // fewer than half the experts resident (a 12 GB card): the one whole-layer copy is faster than many small ones + // (RTX 3060, UD-Q4_K_XL at 37 of 256: pp2048 1970 whole vs 1540 in runs) + if (all || 2 * L.n_slots < ne) { CK(cudaMemcpyAsync(stage[b], L.hblobs, L.stride * (size_t) ne, cudaMemcpyHostToDevice, cst)); } else { for (int x = 0; x < ne;) {