Skip to content

[LLM:Bugfix] Fix incorrect kv_seq_len in gen_attention_mask() for autoregressive decoding #3403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HirokenOvo
Copy link

During the decoding phase (auto-regressive generation), Llm::generate() calls forward(input_ids, is_prefill) with input_ids.size() == 1. The current logic in Llm::gen_attention_mask() sets kv_seq_len = seq_len (where seq_len=1 for decoding), which is incorrect. This ignores the accumulated history length(mContext->all_seq_len), leading to mismatched attention masks and affecting the calculation of attention scores, thereby influencing the model's inference results.

@CLAassistant
Copy link

CLAassistant commented Apr 28, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants