mtp: use inp_out_ids for skipping logit computation (#23433)
when doing a follow-up decode for the draft model, we were always doing the logit computation even though it is not required.
This commit is contained in:
@@ -526,6 +526,7 @@ llama_model_qwen35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr
|
|||||||
res->add_input(std::move(inp));
|
res->add_input(std::move(inp));
|
||||||
|
|
||||||
ggml_tensor * inp_pos = build_inp_pos();
|
ggml_tensor * inp_pos = build_inp_pos();
|
||||||
|
ggml_tensor * inp_out_ids = build_inp_out_ids();
|
||||||
auto * inp_attn = build_attn_inp_kv();
|
auto * inp_attn = build_attn_inp_kv();
|
||||||
|
|
||||||
ggml_tensor * h_norm = build_norm(h_input, layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
|
ggml_tensor * h_norm = build_norm(h_input, layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
|
||||||
@@ -615,6 +616,8 @@ llama_model_qwen35::graph_mtp::graph_mtp(const llama_model & model, const llm_gr
|
|||||||
cb(cur, "h_pre_norm", -1);
|
cb(cur, "h_pre_norm", -1);
|
||||||
res->t_h_pre_norm = cur;
|
res->t_h_pre_norm = cur;
|
||||||
|
|
||||||
|
cur = ggml_get_rows(ctx0, cur, inp_out_ids);
|
||||||
|
|
||||||
ggml_tensor * head_norm_w = layer.nextn.shared_head_norm
|
ggml_tensor * head_norm_w = layer.nextn.shared_head_norm
|
||||||
? layer.nextn.shared_head_norm
|
? layer.nextn.shared_head_norm
|
||||||
: model.output_norm;
|
: model.output_norm;
|
||||||
|
|||||||
@@ -589,8 +589,10 @@ llama_model_qwen35moe::graph_mtp::graph_mtp(const llama_model & model, const llm
|
|||||||
res->add_input(std::move(inp));
|
res->add_input(std::move(inp));
|
||||||
|
|
||||||
ggml_tensor * inp_pos = build_inp_pos();
|
ggml_tensor * inp_pos = build_inp_pos();
|
||||||
|
ggml_tensor * inp_out_ids = build_inp_out_ids();
|
||||||
auto * inp_attn = build_attn_inp_kv();
|
auto * inp_attn = build_attn_inp_kv();
|
||||||
|
|
||||||
|
|
||||||
ggml_tensor * h_norm = build_norm(h_input, layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
|
ggml_tensor * h_norm = build_norm(h_input, layer.nextn.hnorm, nullptr, LLM_NORM_RMS, il);
|
||||||
cb(h_norm, "mtp_hnorm", il);
|
cb(h_norm, "mtp_hnorm", il);
|
||||||
|
|
||||||
@@ -710,6 +712,8 @@ llama_model_qwen35moe::graph_mtp::graph_mtp(const llama_model & model, const llm
|
|||||||
cb(cur, "h_pre_norm", -1);
|
cb(cur, "h_pre_norm", -1);
|
||||||
res->t_h_pre_norm = cur;
|
res->t_h_pre_norm = cur;
|
||||||
|
|
||||||
|
cur = ggml_get_rows(ctx0, cur, inp_out_ids);
|
||||||
|
|
||||||
ggml_tensor * head_norm_w = layer.nextn.shared_head_norm
|
ggml_tensor * head_norm_w = layer.nextn.shared_head_norm
|
||||||
? layer.nextn.shared_head_norm
|
? layer.nextn.shared_head_norm
|
||||||
: model.output_norm;
|
: model.output_norm;
|
||||||
|
|||||||
Reference in New Issue
Block a user