Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions tensorrt_llm/_torch/modules/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,9 @@ def forward(
t.reshape(*orig_shape, -1) for t in torch.chunk(
q_gate.view(*orig_shape, self.num_heads, -1), 2, dim=-1)
]
### TODO: avoid the redundant split and concat
qkv = torch.concat([q, k, v], dim=-1)
else:
q, k, v = qkv, None, None

q, k, v = qkv, None, None
q, k, v = self.apply_rope(q, k, v, position_ids)
q, k, v = self.convert_qkv(q, k, v)

Expand Down
3 changes: 2 additions & 1 deletion tensorrt_llm/_torch/modules/qk_norm_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def apply_rope(self, q: torch.Tensor, k: Optional[torch.Tensor],
else:
return q, k, v

assert k is None and v is None, "The input should be a concatenated qkv tensor to apply_qk_norm_rope"
qkv = q
if k is not None and v is not None:
qkv = torch.concat([q, k, v], dim=-1)
return self.apply_qk_norm_rope(qkv, position_ids)