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
chenpangpang
transformers
Commits
4d9b76a8
"tests/models/vscode:/vscode.git/clone" did not exist on "f1e8c48c5eebf899a5c79b2c48c0ef8456e6bddc"
Unverified
Commit
4d9b76a8
authored
May 26, 2023
by
Sylvain Gugger
Committed by
GitHub
May 26, 2023
Browse files
Fix RWKV backward on GPU (#23774)
parent
8d28dba3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
src/transformers/models/rwkv/modeling_rwkv.py
src/transformers/models/rwkv/modeling_rwkv.py
+3
-6
No files found.
src/transformers/models/rwkv/modeling_rwkv.py
View file @
4d9b76a8
...
...
@@ -159,7 +159,7 @@ class RwkvLinearAttention(torch.autograd.Function):
@
staticmethod
# g stands for grad
def
backward
(
ctx
,
g_output
):
def
backward
(
ctx
,
g_output
,
g_state
=
None
):
input_dtype
=
ctx
.
input_dtype
time_decay
,
time_first
,
key
,
value
,
output
=
ctx
.
saved_tensors
...
...
@@ -188,17 +188,14 @@ class RwkvLinearAttention(torch.autograd.Function):
g_key
,
g_value
,
)
g_time_decay
=
torch
.
sum
(
g_time_decay
,
dim
=
0
)
g_time_first
=
torch
.
sum
(
g_time_first
,
dim
=
0
)
return
(
None
,
None
,
None
,
g_time_decay
.
to
(
input_dtype
),
g_time_first
.
to
(
input_dtype
),
g_key
.
to
(
input_dtype
),
g_value
.
to
(
input_dtype
),
None
,
None
,
)
...
...
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