Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
21bd3be1
Unverified
Commit
21bd3be1
authored
May 19, 2023
by
Younes Belkada
Committed by
GitHub
May 19, 2023
Browse files
[`RWKV`] Rwkv fix for 8bit inference (#23468)
* rwkv fix for 8bit inference * add comment
parent
1c460a52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
src/transformers/models/rwkv/modeling_rwkv.py
src/transformers/models/rwkv/modeling_rwkv.py
+7
-2
No files found.
src/transformers/models/rwkv/modeling_rwkv.py
View file @
21bd3be1
...
@@ -709,8 +709,13 @@ class RwkvModel(RwkvPreTrainedModel):
...
@@ -709,8 +709,13 @@ class RwkvModel(RwkvPreTrainedModel):
block
.
attention
.
output
.
weight
.
mul_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
block
.
attention
.
output
.
weight
.
mul_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
block
.
feed_forward
.
value
.
weight
.
mul_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
block
.
feed_forward
.
value
.
weight
.
mul_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
else
:
else
:
block
.
attention
.
output
.
weight
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
# Deal with quantization statistics
block
.
feed_forward
.
value
.
weight
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
if
hasattr
(
block
.
attention
.
output
.
weight
,
"SCB"
):
block
.
attention
.
output
.
weight
.
SCB
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
block
.
feed_forward
.
value
.
weight
.
SCB
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
else
:
block
.
attention
.
output
.
weight
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
block
.
feed_forward
.
value
.
weight
.
div_
(
2
**
int
(
block_id
//
self
.
config
.
rescale_every
))
self
.
layers_are_rescaled
=
not
self
.
training
self
.
layers_are_rescaled
=
not
self
.
training
...
...
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