模型无法转换怎么办?
模型无法转换怎么办?
02/03 10:46:39 - mmengine - INFO - Load PTH model from /private/xtuner/work_dirs/llava_llama3_8b_instruct_clip_vit_large_p14_336_e1_gpu8_sharegpt4v_pretrain/iter_7038.pth
02/03 10:46:39 - mmengine - INFO - Convert LLM to float16
Traceback (most recent call last):
File "/private/xtuner/xtuner/tools/model_converters/pth_to_hf.py", line 142, in .half() is not supported for quantized model. Please use the model as it is, since the model has already been casted to the correct dtype.
1. 修改模型权重加载
def parse_model_states(files, dtype=DEFAULT_DTYPE): zero_model_states = [] for file in files: # Modify model weight loading state_dict = torch.load(file, map_location='cpu', weights_only=False) # 添加参数 # ...后续处理...
2. 涉及优化器状态加载,同样需修改
@torch.no_grad() def parse_optim_states(files, ds_checkpoint_dir, dtype=DEFAULT_DTYPE): zero_stage = None world_size = None total_files = len(files) flat_groups = [] torch.serialization.add_safe_globals([ConfigDict]) for f in tqdm(files, desc="Load Checkpoints"): state_dict = torch.load(f, map_location=device, weights_only=False) # 添加参数 # ...后续处理...