File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ def load_state_dict(
136136    checkpoint_file : Union [str , os .PathLike ],
137137    variant : Optional [str ] =  None ,
138138    dduf_entries : Optional [Dict [str , DDUFEntry ]] =  None ,
139+     disable_mmap : bool  =  False ,
139140):
140141    """ 
141142    Reads a checkpoint file, returning properly formatted errors if they arise. 
@@ -151,6 +152,8 @@ def load_state_dict(
151152                # tensors are loaded on cpu 
152153                with  dduf_entries [checkpoint_file ].as_mmap () as  mm :
153154                    return  safetensors .torch .load (mm )
155+             if  disable_mmap :
156+                 return  safetensors .torch .load (open (checkpoint_file , "rb" ).read ())
154157            else :
155158                return  safetensors .torch .load_file (checkpoint_file , device = "cpu" )
156159        elif  file_extension  ==  GGUF_FILE_EXTENSION :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments