fix: adjust token count for MTP draft generation in kv cache update (#2181)
This commit is contained in:
parent
3e2f5696a1
commit
de55d9e2f6
|
|
@ -6949,6 +6949,10 @@ static int32_t llama_kv_cache_update_internal(struct llama_context & lctx) {
|
||||||
// TODO: extract to a function
|
// TODO: extract to a function
|
||||||
// build worst-case graph
|
// build worst-case graph
|
||||||
int n_tokens = (int)std::min(lctx.cparams.n_ctx, lctx.cparams.n_ubatch);
|
int n_tokens = (int)std::min(lctx.cparams.n_ctx, lctx.cparams.n_ubatch);
|
||||||
|
// MTP draft generation consumes one token and one hidden-state vector per decode step.
|
||||||
|
if (lctx.cparams.mtp_op_type == MTP_OP_DRAFT_GEN) {
|
||||||
|
n_tokens = 1;
|
||||||
|
}
|
||||||
int n_past = lctx.cparams.n_ctx - n_tokens;
|
int n_past = lctx.cparams.n_ctx - n_tokens;
|
||||||
llama_token token = llama_token_bos(&lctx.model); // not actually used by llama_build_graph, but required to choose between token and embedding inputs graph
|
llama_token token = llama_token_bos(&lctx.model); // not actually used by llama_build_graph, but required to choose between token and embedding inputs graph
|
||||||
llama_batch reserve_batch = llama_batch_get_one(&token, n_tokens, n_past, 0);
|
llama_batch reserve_batch = llama_batch_get_one(&token, n_tokens, n_past, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue