Open hanyinrui opened 1 month ago
在加载模型进行quantizer = torch_quantizer('calib', model, (input_args))时,
KeyError Traceback (最近调用最后) /tmp/ipykernel_222/3548169973.py in 3 test_data=test_data.unsqueeze(1) 4 input_args = test_data[0:100] # 确保它是一个 torch.张量 ----> 5 量化器 = torch_quantizer('calib', model, (input_args)) 6 torch.save(quant_model, 'vit1.10_model.pth')
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/apis.py in init(self, quant_mode, module, input_args, state_dict_file, output_dir, bitwidth, mix_bit, device, lstm, app_deploy, qat_proc, custom_quant_ops, quant_config_file) 96 lstm_app = lstm_app, 97 custom_quant_ops = custom_quant_ops, ---> 98 quant_config_file = quant_config_file) 99 # 微调参数, 100 # 微调后,运行原始转发码进行校准
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/base.py in init(self, quant_mode, module, input_args, state_dict_file, output_dir, bitwidth_w, bitwidth_a, mix_bit, device, lstm_app, custom_quant_ops, quant_config_file) 149 state_dict_file=state_dict_file, 150 quant_mode=qmode, --> 151 device=device) 152 153 # 启用每层的记录输出
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/utils.py in prepare_quantizable_module (module, input_args, export_folder, state_dict_file, quant_mode, device) 191 # 解析原始模块到图 192 NndctScreenLogger().info(f“=>Parsing {_get_module_name(module)}...”) --> 193 graph = parse_module(module, input_args) 194 NndctScreenLogger().info(f“=>可量化模块生成。{export_file})”) 195 # 从 Graph 重新创建可量化模块
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/utils.py in parse_module(module, input_args, enable_opt, graph_name) 81 parser = TorchParser() 82 graph = parser(_get_module_name(module) if graph_name is None else graph_name, ---> 83 module, input_args) 84 if enable_opt: 85 graph = quant_optimize(graph)
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/parse/parser.py in call(self, graph_name, module, input_args) 75 unknown_op_type_check(nndct_graph) 76 self._convert_blob_tensor_type(nndct_graph) ---> 77 self._load_data(nndct_graph, module) 78 if NndctOption.nndct_parse_debug.value >= 2: 79 NndctDebugLogger.write(f“nndct 原始图:\n{nndct_graph}”)
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/parse/parser.py in _load_data(graph, module) 344 else: 345 for param_name, tensor in node.op.params.items(): --> 346 data = module.state_dict()[get_short_name(tensor.name)].cpu().numpy() 347 tensor.from_ndarray(data) 348 tensor = tensor_util.convert_parameter_tensor_format(
KeyError: '1504' 出现这个错误,但是前提是vit模型,并且已经确保了模型的参数和结构一致,那么出现这种情况的原因是什么呢?有没有好心人解决一下,呜呜呜
在加载模型进行quantizer = torch_quantizer('calib', model, (input_args))时,
KeyError Traceback (最近调用最后) /tmp/ipykernel_222/3548169973.py in 3 test_data=test_data.unsqueeze(1) 4 input_args = test_data[0:100] # 确保它是一个 torch.张量 ----> 5 量化器 = torch_quantizer('calib', model, (input_args)) 6 torch.save(quant_model, 'vit1.10_model.pth')
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/apis.py in init(self, quant_mode, module, input_args, state_dict_file, output_dir, bitwidth, mix_bit, device, lstm, app_deploy, qat_proc, custom_quant_ops, quant_config_file) 96 lstm_app = lstm_app, 97 custom_quant_ops = custom_quant_ops, ---> 98 quant_config_file = quant_config_file) 99 # 微调参数, 100 # 微调后,运行原始转发码进行校准
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/base.py in init(self, quant_mode, module, input_args, state_dict_file, output_dir, bitwidth_w, bitwidth_a, mix_bit, device, lstm_app, custom_quant_ops, quant_config_file) 149 state_dict_file=state_dict_file, 150 quant_mode=qmode, --> 151 device=device) 152 153 # 启用每层的记录输出
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/utils.py in prepare_quantizable_module (module, input_args, export_folder, state_dict_file, quant_mode, device) 191 # 解析原始模块到图 192 NndctScreenLogger().info(f“=>Parsing {_get_module_name(module)}...”) --> 193 graph = parse_module(module, input_args) 194 NndctScreenLogger().info(f“=>可量化模块生成。{export_file})”) 195 # 从 Graph 重新创建可量化模块
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/qproc/utils.py in parse_module(module, input_args, enable_opt, graph_name) 81 parser = TorchParser() 82 graph = parser(_get_module_name(module) if graph_name is None else graph_name, ---> 83 module, input_args) 84 if enable_opt: 85 graph = quant_optimize(graph)
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/parse/parser.py in call(self, graph_name, module, input_args) 75 unknown_op_type_check(nndct_graph) 76 self._convert_blob_tensor_type(nndct_graph) ---> 77 self._load_data(nndct_graph, module) 78 if NndctOption.nndct_parse_debug.value >= 2: 79 NndctDebugLogger.write(f“nndct 原始图:\n{nndct_graph}”)
/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.7/site-packages/pytorch_nndct/parse/parser.py in _load_data(graph, module) 344 else: 345 for param_name, tensor in node.op.params.items(): --> 346 data = module.state_dict()[get_short_name(tensor.name)].cpu().numpy() 347 tensor.from_ndarray(data) 348 tensor = tensor_util.convert_parameter_tensor_format(
KeyError: '1504' 出现这个错误,但是前提是vit模型,并且已经确保了模型的参数和结构一致,那么出现这种情况的原因是什么呢?有没有好心人解决一下,呜呜呜