Skip to content
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

use selected index past past key value in attention when using contin… #2682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tensorrt_llm/layers/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,13 @@ def forward(
assert kv_cache_params is None or kv_cache_params.is_valid(
default_net().plugin_config.gpt_attention_plugin)

past_key_value = None if kv_cache_params is None else kv_cache_params.get_first_past_key_value(
)
if kv_cache_params is None:
past_key_value = None
else:
if paged_kv_cache:
past_key_value = kv_cache_params.get_first_past_key_value()
else:
past_key_value = kv_cache_params.past_key_value[self.local_layer_idx]

# if cross attention, cross QKV only needs to be calculated once in the
# 1st decoding step --> write to cross KV cache --> remains constant
Expand Down