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

Resolve issues between kv_cache and flash attention. #1178

Merged
Merged
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
3 changes: 2 additions & 1 deletion megatron/model/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def flash_attention(self, query_layer, key_layer, value_layer):
q_shape = query_layer.shape
k_shape = key_layer.shape
v_shape = value_layer.shape
is_causal = max_seqlen_q == max_seqlen_k
output = self.flash_varlen_qkv_fn(
query_layer.reshape(
(q_shape[0] * q_shape[1], q_shape[2], q_shape[3])
Expand All @@ -641,7 +642,7 @@ def flash_attention(self, query_layer, key_layer, value_layer):
max_seqlen_q,
max_seqlen_k,
softmax_scale=None,
causal=True,
causal=is_causal,
**extra_kwargs,
)
output = output.reshape(q_shape)
Expand Down
Loading