diff --git a/src/models/qwen35.cpp b/src/models/qwen35.cpp index c5f816e96268..2f143d367a4d 100644 --- a/src/models/qwen35.cpp +++ b/src/models/qwen35.cpp @@ -634,6 +634,20 @@ llama_model_qwen35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr ggml_tensor * tok_embd_w = layer.nextn.embed_tokens ? layer.nextn.embed_tokens : model.tok_embd; tok_embd = ggml_get_rows(ctx0, tok_embd_w, inp->tokens); + + // a Hadamard-latent embedding table stores rotated rows; restore the primal + // basis right after the lookup (h = s * (H z)), exactly like the trunk path in + // llm_graph_context::build_inp_embd. Without this the draft head consumes + // embeddings in the rotated basis and llama_verify_hadamard_graph refuses the graph. + if (hadamard_inverses) { + const auto it = hadamard_inverses->find(tok_embd_w); + if (it != hadamard_inverses->end()) { + tok_embd = llama_mul_mat_hadamard(ctx0, tok_embd, it->second.rot); + if (it->second.signs) { + tok_embd = ggml_mul(ctx0, tok_embd, it->second.signs); + } + } + } } else { tok_embd = inp->embd; }