Skip to content

Commit

Permalink
Fix Switch Transformers When sparse_step = 1 (#28564)
Browse files Browse the repository at this point in the history
Fix sparse_step = 1

I case sparse_step = 1, the current code will not work.
  • Loading branch information
agemagician authored Jan 17, 2024
1 parent fa6d12f commit 98dda8e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def __init__(self, config, embed_tokens=None):
config.num_layers = config.num_decoder_layers if self.is_decoder else config.num_layers
self.block = nn.ModuleList()
for i in range(config.num_layers):
is_sparse = (i % sparse_step == 1) if sparse_step > 0 else False
is_sparse = (i % sparse_step == 1 or sparse_step == 1) if sparse_step > 0 else False

self.block.append(
SwitchTransformersBlock(config, has_relative_attention_bias=bool(i == 0), is_sparse=is_sparse)
Expand Down

0 comments on commit 98dda8e

Please sign in to comment.