@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / ba84b8728a
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 17, 09:15 UTC

Fix attention

Woosuk Kwon committed Feb 23, 2023 at 22:29 UTC ba84b8728a8d0a766a636b30661836c30b17fbe6
1 file changed +5 -1
cacheflow/models/attention.py
+5 -1
@@ -1,4 +1,4 @@
1 -from typing import Optional, Tuple
1 +from typing import Optional
2
3 import torch
4 import torch.nn as nn
@@ -24,8 +24,12 @@ class OPTCacheFlowAttention(nn.Module):
24 key: torch.Tensor,
25 value: torch.Tensor,
26 ) -> None:
27 + query = query.unsqueeze(0)
28 + key = key.unsqueeze(0)
29 + value = value.unsqueeze(0)
30 out = xops.memory_efficient_attention(
31 query, key, value, attn_bias=self.attention_mask, scale=self.scale)
32 + out = out.squeeze(0)
33 # FIXME(woosuk): Directly write the attention output.
34 output.copy_(out, non_blocking=True)
35