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
183a88cf
Commit
183a88cf
authored
Oct 23, 2025
by
zhaochao
Browse files
fix some note
Signed-off-by:
zhaochao
<
zhaochao1@sugon.com
>
parent
ca2958a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
transformer_engine/pytorch/attention/dot_product_attention/backends.py
...ngine/pytorch/attention/dot_product_attention/backends.py
+2
-2
No files found.
transformer_engine/pytorch/attention/dot_product_attention/backends.py
View file @
183a88cf
...
@@ -890,12 +890,12 @@ class FlashAttention(torch.nn.Module):
...
@@ -890,12 +890,12 @@ class FlashAttention(torch.nn.Module):
elif
q_format
==
"thd"
:
elif
q_format
==
"thd"
:
# thd -> t(hd)
# thd -> t(hd)
output
=
output
.
reshape
(
output
.
shape
[
0
],
-
1
)
output
=
output
.
reshape
(
output
.
shape
[
0
],
-
1
)
# Handle output shape when V head dim differs from Q/K head dim
if
value_layer
.
shape
[
-
1
]
!=
query_layer
.
shape
[
-
1
]:
if
value_layer
.
shape
[
-
1
]
!=
query_layer
.
shape
[
-
1
]:
v_dim
=
value_layer
.
shape
[
-
1
]
v_dim
=
value_layer
.
shape
[
-
1
]
num_heads
=
query_layer
.
shape
[
-
2
]
num_heads
=
query_layer
.
shape
[
-
2
]
# 恢复为 (..., num_heads, head_dim_qk)
out_shape_heads
=
output
.
shape
[:
-
1
]
+
(
num_heads
,
query_layer
.
shape
[
-
1
])
out_shape_heads
=
output
.
shape
[:
-
1
]
+
(
num_heads
,
query_layer
.
shape
[
-
1
])
output
=
output
.
view
(
out_shape_heads
)[...,
:
v_dim
]
# 裁剪到 V 的维度
output
=
output
.
view
(
out_shape_heads
)[...,
:
v_dim
]
output
=
output
.
reshape
(
output
.
shape
[:
-
2
]
+
(
num_heads
*
v_dim
,))
output
=
output
.
reshape
(
output
.
shape
[:
-
2
]
+
(
num_heads
*
v_dim
,))
return
output
.
contiguous
()
return
output
.
contiguous
()
...
...
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