diff --git a/src/models/qwen35.cpp b/src/models/qwen35.cpp index 2f143d36..df95c5f8 100644 --- a/src/models/qwen35.cpp +++ b/src/models/qwen35.cpp @@ -755,9 +755,13 @@ llama_model_qwen35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr cur = build_norm(cur, head_norm_w, nullptr, LLM_NORM_RMS, -1); cb(cur, "h_nextn", -1); - res->t_h_nextn = cur; - cur = ggml_get_rows(ctx0, cur, inp_out_ids); + // a masked context reads h back by output row, so publish only the output rows: a batch that carries + // catch-up rows ahead of the draft row would otherwise hand back the first catch-up row's h + ggml_tensor * h_out = ggml_get_rows(ctx0, cur, inp_out_ids); + res->t_h_nextn = cparams.embeddings_nextn_masked ? h_out : cur; + + cur = h_out; cb(cur, "mtp_shared_head_norm", -1); ggml_tensor * head_w = layer.nextn.shared_head_head ? layer.nextn.shared_head_head : model.output;