Unverified Commit 98dda8ed authored by Ahmed Elnaggar's avatar Ahmed Elnaggar Committed by GitHub
Browse files

Fix Switch Transformers When sparse_step = 1 (#28564)

Fix sparse_step = 1

I case sparse_step = 1, the current code will not work.
parent fa6d12f7
...@@ -898,7 +898,7 @@ class SwitchTransformersStack(SwitchTransformersPreTrainedModel): ...@@ -898,7 +898,7 @@ class SwitchTransformersStack(SwitchTransformersPreTrainedModel):
config.num_layers = config.num_decoder_layers if self.is_decoder else config.num_layers config.num_layers = config.num_decoder_layers if self.is_decoder else config.num_layers
self.block = nn.ModuleList() self.block = nn.ModuleList()
for i in range(config.num_layers): 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( self.block.append(
SwitchTransformersBlock(config, has_relative_attention_bias=bool(i == 0), is_sparse=is_sparse) SwitchTransformersBlock(config, has_relative_attention_bias=bool(i == 0), is_sparse=is_sparse)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment