Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
TransformerEngine
Commits
b172bad8
Unverified
Commit
b172bad8
authored
Jul 13, 2023
by
Kirthi Shankar Sivamani
Committed by
GitHub
Jul 13, 2023
Browse files
Fix dtype for KV inference cache (#319)
Signed-off-by:
Kirthi Shankar Sivamani
<
ksivamani@nvidia.com
>
parent
6bd35bf9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
transformer_engine/pytorch/attention.py
transformer_engine/pytorch/attention.py
+4
-4
No files found.
transformer_engine/pytorch/attention.py
View file @
b172bad8
...
...
@@ -1108,14 +1108,14 @@ class MultiHeadAttention(torch.nn.Module):
def
_allocate_memory
(
self
,
inference_max_sequence_len
:
int
,
batch_size
:
int
self
,
inference_max_sequence_len
:
int
,
batch_size
:
int
,
dtype
:
torch
.
dtype
)
->
torch
.
Tensor
:
return
torch
.
empty
(
inference_max_sequence_len
,
batch_size
,
self
.
num_attention_heads_per_partition
,
self
.
hidden_size_per_attention_head
,
dtype
=
self
.
params_
dtype
,
dtype
=
dtype
,
device
=
torch
.
cuda
.
current_device
(),
)
...
...
@@ -1154,10 +1154,10 @@ class MultiHeadAttention(torch.nn.Module):
inf_max_seq_len
=
inference_params
.
max_sequence_len
inf_max_batch_size
=
inference_params
.
max_batch_size
inference_key_memory
=
self
.
_allocate_memory
(
inf_max_seq_len
,
inf_max_batch_size
inf_max_seq_len
,
inf_max_batch_size
,
hidden_states
.
dtype
)
inference_value_memory
=
self
.
_allocate_memory
(
inf_max_seq_len
,
inf_max_batch_size
inf_max_seq_len
,
inf_max_batch_size
,
hidden_states
.
dtype
)
inference_params
.
key_value_memory_dict
[
self
.
layer_number
]
=
(
inference_key_memory
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment