Lightning Module's to_disk should use fsspec to write reusults
🚀 Feature
use fsspec here to support more storage backends besides local disk:

  
    
      pytorch-lightning/pytorch_lightning/trainer/supporters.py
    
    
        Lines 138 to 165
      in
      cea5f1f
    
  
  
    

        
          
               def to_disk(self): 
        

        
          
                   """Write predictions to file(s). 
        

        
          
                   """ 
        

        
          
                   for filename, predictions in self.predictions.items(): 
        

        
          
            
        

        
          
                       # Absolute path to defined prediction file. rank added to name if in multi-gpu environment 
        

        
          
                       outfile = Path(filename).absolute() 
        

        
          
                       outfile = outfile.with_name( 
        

        
          
                           f"{outfile.stem}{f'_rank_{self.global_rank}' if self.world_size > 1 else ''}{outfile.suffix}" 
        

        
          
                       ) 
        

        
          
                       outfile.parent.mkdir(exist_ok=True, parents=True) 
        

        
          
            
        

        
          
                       # Convert any tensor values to list 
        

        
          
                       predictions = {k: v if not isinstance(v, Tensor) else v.tolist() for k, v in predictions.items()} 
        

        
          
            
        

        
          
                       # Check if all features for this file add up to same length 
        

        
          
                       feature_lens = {k: len(v) for k, v in predictions.items()} 
        

        
          
                       if len(set(feature_lens.values())) != 1: 
        

        
          
                           raise ValueError('Mismatching feature column lengths found in stored EvalResult predictions.') 
        

        
          
            
        

        
          
                       # Switch predictions so each entry has its own dict 
        

        
          
                       outputs = [] 
        

        
          
                       for values in zip(*predictions.values()): 
        

        
          
                           output_element = {k: v for k, v in zip(predictions.keys(), values)} 
        

        
          
                           outputs.append(output_element) 
        

        
          
            
        

        
          
                       # Write predictions for current file to disk 
        

        
          
                       torch.save(outputs, outfile) 
        
    
  


cc @nateraw