Add strict option to scheduler
🚀 Feature
When a ReduceLROnPlateau scheduler is used, training stops with a raised MisconfigurationException if the monitor is not found. We should add a strict option (same as in the EarlyStopping callback) so it is configurable.
EarlyStopping:

  
    
      pytorch-lightning/pytorch_lightning/callbacks/early_stopping.py
    
    
        Lines 61 to 62
      in
      c64520e
    
  
  
    

        
          
                   strict: whether to crash the training if `monitor` is 
        

        
          
                       not found in the validation metrics. Default: ``True``. 
        
    
  



  
    
      pytorch-lightning/pytorch_lightning/callbacks/early_stopping.py
    
    
        Lines 107 to 116
      in
      c64520e
    
  
  
    

        
          
           error_msg = (f'Early stopping conditioned on metric `{self.monitor}`' 
        

        
          
                        f' which is not available. Either add `{self.monitor}` to the return of ' 
        

        
          
                        f' validation_epoch end or modify your EarlyStopping callback to use any of the ' 
        

        
          
                        f'following: `{"`, `".join(list(logs.keys()))}`') 
        

        
          
            
        

        
          
           if monitor_val is None: 
        

        
          
               if self.strict: 
        

        
          
                   raise RuntimeError(error_msg) 
        

        
          
               if self.verbose > 0: 
        

        
          
                   rank_zero_warn(error_msg, RuntimeWarning) 
        
    
  


OptimizerConnector:

  
    
      pytorch-lightning/pytorch_lightning/trainer/connectors/optimizer_connector.py
    
    
        Lines 53 to 59
      in
      c64520e
    
  
  
    

        
          
           if monitor_val is None: 
        

        
          
               avail_metrics = ','.join(list(self.trainer.logger_connector.callback_metrics.keys())) 
        

        
          
               raise MisconfigurationException( 
        

        
          
                   f'ReduceLROnPlateau conditioned on metric {monitor_key}' 
        

        
          
                   f' which is not available. Available metrics are: {avail_metrics}.' 
        

        
          
                   ' Condition can be set using `monitor` key in lr scheduler dict' 
        

        
          
               ) 
        
    
  


Motivation
If my first epoch fails to produce a valid loss, the scheduler stops training.
Pitch
    def configure_optimizers(self):
        optimizer = ...
        scheduler = {
            "scheduler": torch.optim.lr_scheduler.ReduceLROnPlateau(
                optimizer,
                mode="min",
            ),
            "monitor": "checkpoint_on",
            "interval": "epoch",
            "frequency": 1,
            "strict": False  # Allow this
        }
        return [optimizer], [scheduler]