mirror of
				https://github.com/hiyouga/LLaMA-Factory.git
				synced 2025-11-04 18:02:19 +08:00 
			
		
		
		
	[file] Resolve file lock issue when deleting safetensors on Windows (#8839)
This commit is contained in:
		
							parent
							
								
									c244b1edb9
								
							
						
					
					
						commit
						ef507ae8e0
					
				@ -73,7 +73,7 @@ def fix_valuehead_checkpoint(
 | 
			
		||||
    if safe_serialization:
 | 
			
		||||
        path_to_checkpoint = os.path.join(output_dir, SAFE_WEIGHTS_NAME)
 | 
			
		||||
        with safe_open(path_to_checkpoint, framework="pt", device="cpu") as f:
 | 
			
		||||
            state_dict: dict[str, torch.Tensor] = {key: f.get_tensor(key) for key in f.keys()}
 | 
			
		||||
            state_dict: dict[str, torch.Tensor] = {key: f.get_tensor(key).clone() for key in f.keys()}
 | 
			
		||||
    else:
 | 
			
		||||
        path_to_checkpoint = os.path.join(output_dir, WEIGHTS_NAME)
 | 
			
		||||
        state_dict: dict[str, torch.Tensor] = torch.load(path_to_checkpoint, map_location="cpu", weights_only=True)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user