Skip to content

Commit

Permalink
[RWKV] Fix RWKV 4bit (huggingface#23910)
Browse files Browse the repository at this point in the history
fix RWKV 4bit
  • Loading branch information
younesbelkada authored May 31, 2023
1 parent 55451c6 commit c63bfc3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/transformers/models/rwkv/modeling_rwkv.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,13 @@ def _rescale_layers(self):
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))
elif hasattr(block.attention.output.weight, "quant_state"):
block.attention.output.weight.quant_state[0].div_(
2 ** int(block_id // self.config.rescale_every)
)
block.feed_forward.value.weight.quant_state[0].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))
Expand Down

0 comments on commit c63bfc3

Please sign in to comment.