PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
21.8k stars 5.47k forks source link

[PIR] test_ir_save_load.py 执行报错 #65685

Closed qzylalala closed 1 day ago

qzylalala commented 5 days ago

bug描述 Describe the Bug

python 版本 3.9.6 paddle 版本 3.0.0b0,安装命令使用 python3 -m pip install paddlepaddle==3.0.0b0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/

test/ir/pir 目录下执行命令 python3 test_ir_save_load.py 报错:

EEEEEEEE
======================================================================
ERROR: test_builtin_save (__main__.TestSaveModuleWithCommonOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 109, in test_builtin_save
    base.core.serialize_pir_program(
TypeError: serialize_pir_program(): incompatible function arguments. The following argument types are supported:
    1. (program: pir::Program, file_path: str, pir_version: int, overwrite: bool = True, readable: bool = False, trainable: bool = True) -> None

Invoked with: { // block_idx:0  parent_idx:-1  forward_idx:-1  backward_idx:-1
    var x_2 : LOD_TENSOR.shape(4, 5).dtype(int32).stop_gradient(True)
    var split_0.tmp_0 : LOD_TENSOR.shape(2, 5).dtype(int32).stop_gradient(True)
    var split_0.tmp_1 : LOD_TENSOR.shape(2, 5).dtype(int32).stop_gradient(True)
    var concat_0.tmp_0 : LOD_TENSOR.shape(2, 10).dtype(int32).stop_gradient(True)

    {Out=['split_0.tmp_0', 'split_0.tmp_1']} = split(inputs={AxisTensor=[], SectionsTensorList=[], X=['x_2']}, axis = 0, num = 2, op_device = , op_namescope = /, op_role = 0, op_role_var = [], sections = [], with_quant_attr = False)
    {Out=['concat_0.tmp_0']} = concat(inputs={AxisTensor=[], X=['split_0.tmp_0', 'split_0.tmp_1']}, axis = 1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
, '/var/folders/2h/l53mnfy93m9_6fp6t252tpq40000gp/T/tmpx2epozg2/test_save_program2.json', 1, True, True, True

======================================================================
ERROR: test_save_load (__main__.TestSaveModuleWithCommonOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 46, in test_save_load
    base.core.serialize_pir_program(main_program, file_path, pir_version)
TypeError: serialize_pir_program(): incompatible function arguments. The following argument types are supported:
    1. (program: pir::Program, file_path: str, pir_version: int, overwrite: bool = True, readable: bool = False, trainable: bool = True) -> None

Invoked with: { // block_idx:0  parent_idx:-1  forward_idx:-1  backward_idx:-1
    var fill_constant_1.tmp_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(True)
    var fill_constant_3.tmp_0 : LOD_TENSOR.shape(64, 64).dtype(float32).stop_gradient(True)
    var fill_constant_5.tmp_0 : LOD_TENSOR.shape(64,).dtype(float32).stop_gradient(True)
    var matmul_v2_0.tmp_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(True)
    var elementwise_add_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(True)

    {Out=['fill_constant_1.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1, 512, 64], str_value = 0.5, value = 0.5, with_quant_attr = False)
    {Out=['fill_constant_3.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [64, 64], str_value = 0.5, value = 0.5, with_quant_attr = False)
    {Out=['fill_constant_5.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [64], str_value = 1.0, value = 1.0, with_quant_attr = False)
    {Out=['matmul_v2_0.tmp_0']} = matmul_v2(inputs={X=['fill_constant_1.tmp_0'], Y=['fill_constant_3.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], trans_x = False, trans_y = False, with_quant_attr = False)
    {Out=['elementwise_add_0']} = elementwise_add(inputs={X=['matmul_v2_0.tmp_0'], Y=['fill_constant_5.tmp_0']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
, '/var/folders/2h/l53mnfy93m9_6fp6t252tpq40000gp/T/tmpf00czj80/test_save_program1.json', 1

======================================================================
ERROR: test_save_no_trainable (__main__.TestSaveModuleWithCommonOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 82, in test_save_no_trainable
    base.core.serialize_pir_program(
TypeError: serialize_pir_program(): incompatible function arguments. The following argument types are supported:
    1. (program: pir::Program, file_path: str, pir_version: int, overwrite: bool = True, readable: bool = False, trainable: bool = True) -> None

Invoked with: { // block_idx:0  parent_idx:-1  forward_idx:-1  backward_idx:-1
    var fill_constant_1.tmp_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(False)
    var fill_constant_3.tmp_0 : LOD_TENSOR.shape(64, 64).dtype(float32).stop_gradient(True)
    var fill_constant_5.tmp_0 : LOD_TENSOR.shape(64,).dtype(float32).stop_gradient(True)
    var matmul_v2_0.tmp_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(False)
    var elementwise_add_0 : LOD_TENSOR.shape(1, 512, 64).dtype(float32).stop_gradient(False)

    {Out=['fill_constant_1.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1, 512, 64], str_value = 0.5, value = 0.5, with_quant_attr = False)
    {Out=['fill_constant_3.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [64, 64], str_value = 0.5, value = 0.5, with_quant_attr = False)
    {Out=['fill_constant_5.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [64], str_value = 1.0, value = 1.0, with_quant_attr = False)
    {Out=['matmul_v2_0.tmp_0']} = matmul_v2(inputs={X=['fill_constant_1.tmp_0'], Y=['fill_constant_3.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], trans_x = False, trans_y = False, with_quant_attr = False)
    {Out=['elementwise_add_0']} = elementwise_add(inputs={X=['matmul_v2_0.tmp_0'], Y=['fill_constant_5.tmp_0']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
, '/var/folders/2h/l53mnfy93m9_6fp6t252tpq40000gp/T/tmp5mc7rxh0/test_save_program1_0.json', 1, True, True, False

======================================================================
ERROR: test_if_with_multiple_output (__main__.TestSaveModuleWithIfOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 194, in test_if_with_multiple_output
    cond_value = main_program.global_block().ops[-1].operand_source(0)
AttributeError: 'Operator' object has no attribute 'operand_source'

======================================================================
ERROR: test_if_with_single_output (__main__.TestSaveModuleWithIfOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 181, in test_if_with_single_output
    base.core.serialize_pir_program(main_program, file_path, pir_version)
TypeError: serialize_pir_program(): incompatible function arguments. The following argument types are supported:
    1. (program: pir::Program, file_path: str, pir_version: int, overwrite: bool = True, readable: bool = False, trainable: bool = True) -> None

Invoked with: { // block_idx:0  parent_idx:-1  forward_idx:-1  backward_idx:-1
    var x : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)
    var y : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)
    var tmp_0 : LOD_TENSOR.shape(6, 1).dtype(bool).stop_gradient(False)
    var _generated_var_0 : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)
    var _generated_var_1 : STEP_SCOPES)
    var logical_not_0.tmp_0 : LOD_TENSOR.shape(6, 1).dtype(bool).stop_gradient(False)
    var _generated_var_2 : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)
    var _generated_var_3 : STEP_SCOPES)
    var cast_0.tmp_0 : LOD_TENSOR.shape(6, 1).dtype(int32).stop_gradient(False)
    var _generated_var_4 : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)

    {Out=['tmp_0']} = less_than(inputs={X=['x'], Y=['y']}, axis = -1, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['_generated_var_0'], Scope=['_generated_var_1']} = conditional_block(inputs={Cond=['tmp_0'], Input=['y', 'x']}, is_scalar_condition = True, op_device = , op_namescope = /, op_role = 0, op_role_var = [], sub_block = block[1], with_quant_attr = False)
    {Out=['logical_not_0.tmp_0']} = logical_not(inputs={X=['tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['_generated_var_2'], Scope=['_generated_var_3']} = conditional_block(inputs={Cond=['logical_not_0.tmp_0'], Input=['y', 'x']}, is_scalar_condition = True, op_device = , op_namescope = /, op_role = 0, op_role_var = [], sub_block = block[2], with_quant_attr = False)
    {Out=['cast_0.tmp_0']} = cast(inputs={X=['tmp_0']}, in_dtype = 0, op_device = , op_namescope = /, op_role = 0, op_role_var = [], out_dtype = 2, with_quant_attr = False)
    {Out=['_generated_var_4']} = select_input(inputs={Mask=['cast_0.tmp_0'], X=['_generated_var_2', '_generated_var_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
{ // block_idx:1  parent_idx:0  forward_idx:-1  backward_idx:-1
    var tmp_1 : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)

    {Out=['tmp_1']} = elementwise_add(inputs={X=['x'], Y=['y']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['_generated_var_0']} = assign(inputs={X=['tmp_1']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
{ // block_idx:2  parent_idx:0  forward_idx:-1  backward_idx:-1
    var tmp_2 : LOD_TENSOR.shape(6, 1).dtype(float32).stop_gradient(False)

    {Out=['tmp_2']} = elementwise_sub(inputs={X=['x'], Y=['y']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['_generated_var_2']} = assign(inputs={X=['tmp_2']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
, '/var/folders/2h/l53mnfy93m9_6fp6t252tpq40000gp/T/tmpzz24g78x/test_save_program_if.json', 1

======================================================================
ERROR: test_get_used_external_value (__main__.TestSaveModuleWithwhileOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  ...
  File "site-packages/paddle/pir/core.py", line 274, in program_guard
    check_type(
  File "site-packages/paddle/base/data_feeder.py", line 188, in check_type
    raise TypeError(
TypeError: The type of 'main_program' in paddle.static.program_guard must be <class 'paddle.base.libpaddle.pir.Program'>, but received <class 'paddle.base.framework.Program'>. 

======================================================================
ERROR: test_nested_net (__main__.TestSaveModuleWithwhileOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Paddle/test/ir/pir/test_ir_save_load.py", line 358, in test_nested_net
    base.core.serialize_pir_program(main_program, file_path, pir_version)
TypeError: serialize_pir_program(): incompatible function arguments. The following argument types are supported:
    1. (program: pir::Program, file_path: str, pir_version: int, overwrite: bool = True, readable: bool = False, trainable: bool = True) -> None

Invoked with: { // block_idx:0  parent_idx:-1  forward_idx:-1  backward_idx:-1
    var fill_constant_1.tmp_0 : LOD_TENSOR.shape(1,).dtype(int64).stop_gradient(True)
    var fill_constant_3.tmp_0 : LOD_TENSOR.shape(1,).dtype(int64).stop_gradient(True)
    var init : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var sums : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var fill_constant_5.tmp_0 : LOD_TENSOR.shape(1,).dtype(int64).stop_gradient(True)
    var fill_constant_7.tmp_0 : LOD_TENSOR.shape(1,).dtype(int64).stop_gradient(True)
    var fill_constant_9.tmp_0 : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var less_than_0.tmp_0 : LOD_TENSOR.shape(1,).dtype(bool).stop_gradient(True)
    var _generated_var_1 : STEP_SCOPES)

    {Out=['fill_constant_1.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 3, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1], str_value = 0, value = 0.0, with_quant_attr = False)
    {Out=['fill_constant_3.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 3, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1], str_value = 0, value = 0.0, with_quant_attr = False)
    {Out=['fill_constant_5.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 3, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1], str_value = 2, value = 2.0, with_quant_attr = False)
    {Out=['fill_constant_7.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 3, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [1], str_value = 3, value = 3.0, with_quant_attr = False)
    {Out=['fill_constant_9.tmp_0']} = fill_constant(inputs={ShapeTensor=[], ShapeTensorList=[], ValueTensor=[]}, dtype = 5, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], place_type = -1, shape = [3, 3], str_value = 1.0, value = 1.0, with_quant_attr = False)
    {Out=['less_than_0.tmp_0']} = less_than(inputs={X=['fill_constant_1.tmp_0'], Y=['fill_constant_5.tmp_0']}, axis = -1, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['less_than_0.tmp_0', 'sums', 'init', 'fill_constant_3.tmp_0', 'fill_constant_1.tmp_0'], StepScopes=['_generated_var_1']} = while(inputs={Condition=['less_than_0.tmp_0'], X=['init', 'sums', 'fill_constant_3.tmp_0', 'fill_constant_1.tmp_0', 'fill_constant_9.tmp_0', 'fill_constant_7.tmp_0', 'fill_constant_5.tmp_0']}, is_test = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], sub_block = block[1], with_quant_attr = False)
}
{ // block_idx:1  parent_idx:0  forward_idx:-1  backward_idx:-1
    var less_than_1.tmp_0 : LOD_TENSOR.shape(1,).dtype(bool).stop_gradient(True)
    var _generated_var_0 : STEP_SCOPES)
    var elementwise_add_2 : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var less_than_3.tmp_0 : LOD_TENSOR.shape(1,).dtype(bool).stop_gradient(True)

    {Out=['less_than_1.tmp_0']} = less_than(inputs={X=['fill_constant_3.tmp_0'], Y=['fill_constant_7.tmp_0']}, axis = -1, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['init', 'sums', 'fill_constant_3.tmp_0', 'less_than_1.tmp_0'], StepScopes=['_generated_var_0']} = while(inputs={Condition=['less_than_1.tmp_0'], X=['init', 'sums', 'fill_constant_3.tmp_0', 'fill_constant_9.tmp_0', 'fill_constant_7.tmp_0']}, is_test = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], sub_block = block[2], with_quant_attr = False)
    {Out=['elementwise_add_2']} = elementwise_add(inputs={X=['init'], Y=['sums']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['fill_constant_1.tmp_0']} = increment(inputs={X=['fill_constant_1.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], step = 1.0, with_quant_attr = False)
    {Out=['less_than_3.tmp_0']} = less_than(inputs={X=['fill_constant_1.tmp_0'], Y=['fill_constant_5.tmp_0']}, axis = -1, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['sums']} = assign(inputs={X=['elementwise_add_2']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['less_than_0.tmp_0']} = assign(inputs={X=['less_than_3.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
{ // block_idx:2  parent_idx:1  forward_idx:-1  backward_idx:-1
    var elementwise_add_0 : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var elementwise_add_1 : LOD_TENSOR.shape(3, 3).dtype(float32).stop_gradient(True)
    var less_than_2.tmp_0 : LOD_TENSOR.shape(1,).dtype(bool).stop_gradient(True)

    {Out=['elementwise_add_0']} = elementwise_add(inputs={X=['init'], Y=['fill_constant_9.tmp_0']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['elementwise_add_1']} = elementwise_add(inputs={X=['elementwise_add_0'], Y=['sums']}, axis = -1, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['fill_constant_3.tmp_0']} = increment(inputs={X=['fill_constant_3.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], step = 1.0, with_quant_attr = False)
    {Out=['less_than_2.tmp_0']} = less_than(inputs={X=['fill_constant_3.tmp_0'], Y=['fill_constant_7.tmp_0']}, axis = -1, force_cpu = False, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['init']} = assign(inputs={X=['elementwise_add_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['sums']} = assign(inputs={X=['elementwise_add_1']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
    {Out=['less_than_1.tmp_0']} = assign(inputs={X=['less_than_2.tmp_0']}, op_device = , op_namescope = /, op_role = 0, op_role_var = [], with_quant_attr = False)
}
, '/var/folders/2h/l53mnfy93m9_6fp6t252tpq40000gp/T/tmpwzcbnj2h/test_save_program_while_nest.json', 1

======================================================================
ERROR: test_while_base (__main__.TestSaveModuleWithwhileOp)
----------------------------------------------------------------------
Traceback (most recent call last):
  ...
  File "site-packages/paddle/pir/core.py", line 274, in program_guard
    check_type(
  File "site-packages/paddle/base/data_feeder.py", line 188, in check_type
    raise TypeError(
TypeError: The type of 'main_program' in paddle.static.program_guard must be <class 'paddle.base.libpaddle.pir.Program'>, but received <class 'paddle.base.framework.Program'>. 

----------------------------------------------------------------------
Ran 8 tests in 0.036s

FAILED (errors=8)

8 个 单测一个没过。

其他补充信息 Additional Supplementary Information

No response

xiaoguoguo626807 commented 4 days ago

这个单测运行需要开启两个flag FLAGS_enable_pir_in_executor, FLAGS_enable_pir_api

qzylalala commented 4 days ago

这个单测运行需要开启两个flag FLAGS_enable_pir_in_executor, FLAGS_enable_pir_api

感谢,实测 FLAGS_enable_pir_api=True python3 test_ir_save_load.py 可以通过测试。