[BUG] nn.Module.train() and eval() have NO effect on TransformerLayer's dropout
Describe the bug
When performing model evaluation during training, using model.eval() doesn't bring any change (to dropout) as expected.
DeepSpeedTransformerLayer's forward dropout behaviour is determined by self.config.training (specified during construction) rather than self.training.
This may hurt accuracy when users construct a model for training and then call model.eval() to disable dropout for evaluation.
To Reproduce N/A
Expected behavior
After model.eval() and model.train(), the dropout in TransformerLayers should be disabled and enabled.
A typical fix should be like
class DeepSpeedTransformerLayer(nn.Module):
...
def train(self, mode: bool = True):
self.config.training = mode
return super().train(mode=mode)ds_report output N/A
Screenshots N/A
System info (please complete the following information): N/A
Launcher context N/A
Docker context N/A
Additional context N/A
Source: deepspeedai/DeepSpeed