Enable training purely based on number of iterations instead of epochs
🚀 Feature
Enable training purely based on number of iterations instead of epochs
Motivation
This can be useful for certain training runs. Without this feature, the user must set an unreachably high value for max_epochs and set max_steps to the desired iteration count. With this setup, the trainer will break from the training loop based on max_steps since we'd never reach max_epochs. For example, Detectron2 uses iteration-based training in their train loop.
Pitch
The solution could be pretty simple. We can make min_epochs and max_epochs as Optional. If all of min/max_epochs and max_steps are unset, use the defaults we have today (min_epochs=1, max_epochs=1000). If only max_steps is set, use that (and keep min/max_epochs as None). If all are set, stop based on whichever condition is hit first.
Specifically, we'd need to:

Initialize things correctly here: 
  
    
      pytorch-lightning/pytorch_lightning/trainer/training_loop.py
    
    
         Line 46
      in
      c64520e
    
  
  
    

        
          
           def on_trainer_init(self, max_epochs, min_epochs, max_steps, min_steps, num_sanity_val_steps): 
        
    
  


Update the training loop here to not depend on max_epochs: https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/trainer/trainer.py#L340-L375 .

Are there other spots I'm missing?
Alternatives
Without touching the Trainer code, a super hacky solution would be setting max_epochs to be an outrageously large value and set max_steps to my desired iteration count. then we'll break from the train loop according to max_steps since we'd meet this condition first instead of max_epochs. However this could be better handled