From 749db7f034d43d6de01a01f6d8c872d02afa6c7b Mon Sep 17 00:00:00 2001 From: Pascal Date: Tue, 3 Nov 2026 12:47:23 +0100 Subject: [PATCH] qwen4exp: write the conv state tail without an intermediate cont (#31443) build_conv_state_at makes a contiguous copy of the conv input tail before writing it into the recurrent state, so every GDN layer issues two device copies per generated token where one is enough. On Qwen3.8-Flash-Next (36 GDN layers) that is 72 copies per token, now 36. Speculative decoding adds one more per rollback slot. ggml_cpy reads the strided view directly, as the shared build_conv_state already does, so the extra copy is dropped. --- src/models/qwen4exp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/qwen4exp.cpp b/src/models/qwen4exp.cpp index 60665381c..e4848cb77 100644 --- a/src/models/qwen4exp.cpp +++ b/src/models/qwen4exp.cpp @@ -1443,7 +1443,7 @@ ggml_tensor * llama_model_qwen4exp::graph::build_conv_state_at( conv_states_all->nb[1], (slot * mem_size + kv_head) * row_size); - ggml_build_forward_expand(gf, ggml_cpy(ctx0, ggml_cont(ctx0, tail), dst)); + ggml_build_forward_expand(gf, ggml_cpy(ctx0, tail, dst)); } return conv_input;