众所周知,Paddle 是一个历史悠久的框架,使得 Paddle 能够久经考验,应对各种场景稳定运行。但历史的沉淀同样带来一个严重的问题,就是框架内 API 语义不清晰,多种 API 能够做同样或者类似的事情。得益于我们的公开 API 审查机制和 fluid 清理,公开 API 中类似问题较少,但框架内部仍存在大量历史遗留的内部 API 的使用,这些 API 的存在导致框架内部需要一些兼容逻辑,使得框架难以维护和升级。
为了使得框架架构更加清晰,我们希望对框架内部的历史遗留 API 进行清理,以使得框架架构更加清晰,更易于维护。为了迎接 3.0 的新时代,希望大家能够一起清理这些「旧时代的残党」~
背景
众所周知,Paddle 是一个历史悠久的框架,使得 Paddle 能够久经考验,应对各种场景稳定运行。但历史的沉淀同样带来一个严重的问题,就是框架内 API 语义不清晰,多种 API 能够做同样或者类似的事情。得益于我们的公开 API 审查机制和 fluid 清理,公开 API 中类似问题较少,但框架内部仍存在大量历史遗留的内部 API 的使用,这些 API 的存在导致框架内部需要一些兼容逻辑,使得框架难以维护和升级。
为了使得框架架构更加清晰,我们希望对框架内部的历史遗留 API 进行清理,以使得框架架构更加清晰,更易于维护。为了迎接 3.0 的新时代,希望大家能够一起清理这些「旧时代的残党」~
提交规范介绍
⭐️ 提交PR 模版 ⭐️:
// ------- PR 标题 --------
⭐️ 认领方式 ⭐️: 请大家以 comment 的形式认领任务,如:
状态介绍: ✅:已经完全迁移,所有单测都OK! 🟢:审核完毕待合入,合入之后完全迁移! 🔵:可认领! 🟡:当前阶段不需要人力继续跟进,下阶段推进(大部分是精度问题) 🚧:迁移中,单测还没有过,还没有审核完。
大致正常流程为: 🔵 -> 🚧 -> 🟢 -> ✅
异常流程为: 🔵 -> 🚧 -> 🟡
⭐️ 提交 PR 注意事项 ⭐️:
@gouzil
,并链接本 issue#61385
,会由任务 Leader @gouzil 进行任务一审,一审通过后由 @SigureMo 进行二审任务详情
残党 A:
VarType
VarType
是定义在framework.proto
的一个枚举字段,用于表示VarDesc
的类型,其定义如下:https://github.com/PaddlePaddle/Paddle/blob/b88fd789482876b75b0184a65785a3ff39b2791e/paddle/fluid/framework/framework.proto#L142-L186
VarType
是同时表示 dtype 和 Tensor type 等多种信息的,语义不清晰,我们现在 paddle.dtype(含 paddle.int32、paddle.float32 等)就是VarType
相应字段的 re-export。众所周知,Paddle 是先有静态图的,而后动态图直接复用了静态图的
VarType
,而如今我们 PIR 下直接使用了语义更加清晰的DataType
,但框架现存代码中大量VarType
的使用阻碍了我们将VarType
替换为DataType
的进程。因此我们希望先对框架内的
VarType
使用进行清理,逐步隐藏 Python 端对VarType
的使用,初步希望替换dtype == VarType.FP32
的 case 为dtype == paddle.float32
gradient_checker.py
op_test.py
test_batch_norm_op.py
test_coalesce_tensor_op.py
test_cummin_op.py
test_cumsum_op.py
test_custom_conj.py
test_elementwise_add_op.py
test_imperative_auto_mixed_precision_for_eager.py
test_initializer.py
test_initializer_nn.py
test_ir_fusion_group_pass.py
test_pass_bf16.py
test_to_tensor.py
test/collective/fleet/test_fleet_gradient_merge_meta_optimizer.py
test/legacy_test/test_data.py
test/legacy_test/test_egr_python_api.py
test/legacy_test/test_executor_feed_non_tensor.py
test/legacy_test/test_lod_tensor.py
test/legacy_test/test_math_op_patch_var_base.py
test/legacy_test/test_math_op_patch.py
test/legacy_test/test_parameter.py
test/legacy_test/test_rand_op.py
test/legacy_test/test_tensor.py
test/legacy_test/test_uniform_random_op.py
test/legacy_test/test_var_base.py
test/sequence/test_sequence_pad_op.py
test/xpu/test_gaussian_random_op_xpu.py
python/paddle/base/dygraph/math_op_patch.py
python/paddle/base/dataset.py
python/paddle/base/framework.py
python/paddle/distributed/auto_parallel/static/cost/base_cost.py
python/paddle/distributed/fleet/dataset/dataset.py
python/paddle/distributed/fleet/meta_optimizers/sharding/offload_helper.py
python/paddle/distributed/fleet/utils/mix_precision_utils.py
python/paddle/distributed/passes/auto_parallel_amp.py
python/paddle/distributed/passes/auto_parallel_master_grad.py
python/paddle/hapi/model.py
python/paddle/incubate/distributed/models/moe/grad_clip.py
python/paddle/incubate/optimizer/distributed_fused_lamb.py
python/paddle/optimizer/optimizer.py
python/paddle/static/amp/bf16/amp_utils.py
python/paddle/static/amp/amp_nn.py
python/paddle/static/amp/debugging.py
python/paddle/static/amp/fp16_lists.py
python/paddle/static/amp/fp16_utils.py
python/paddle/static/nn/common.py
python/paddle/static/quantization/quantization_pass.py
python/paddle/tensor/creation.py
python/paddle/tensor/to_string.py
残党 B:
paddle.base.dygraph.to_variable
to_variable
是早期动态图下用来创建 Tensor 的 API,现在有一个语义更加清晰的paddle.to_tensor
API,但 Paddle 框架中遗留的to_variable
使用特别多,为了能够让paddle.to_tensor
替换掉to_variable
,我们需要将框架中现有使用处全部替换掉:check_flags_use_mkldnn.py
op_test.py
parallel_dygraph_control_flow_same.py
parallel_dygraph_mnist.py
parallel_dygraph_se_resnext.py
parallel_dygraph_shared_unused_var.py
parallel_dygraph_sparse_embedding.py
parallel_dygraph_sync_batch_norm.py
parallel_dygraph_transformer.py
simnet_dygraph_model.py
test_activation_op.py
test_adam_op.py
test_adaptive_avg_pool1d.py
test_adaptive_max_pool1d.py
test_addmm_op.py
test_affine_grid_function.py
test_array_read_write_op.py
test_basic_api_transformation.py
test_bicubic_interp_op.py
test_bicubic_interp_v2_op.py
test_bincount_op.py
test_bmm_op.py
test_bmn.py
test_cast.py
test_cholesky_op.py
test_chunk_op.py
test_coalesce_tensor_op.py
test_complex_getitem.py
test_complex_kron.py
test_complex_matmul.py
test_complex_reshape.py
test_complex_sum_layer.py
test_complex_trace_layer.py
test_complex_transpose.py
test_complex_variable.py
test_conv2d_api.py
test_conv3d_transpose_layer.py
test_correlation.py
test_cross_op.py
test_cycle_gan.py
test_declarative.py
test_detach.py
test_detection.py
test_dict.py
test_directory_migration.py
test_dropout_op.py
test_dropout_op_xpu.py
test_dygraph_mnist_fp16.py
test_dygraph_multi_forward.py
test_dygraph_weight_norm.py
test_egr_python_api.py
test_eig_op.py
test_elementwise_add_op.py
test_elementwise_add_op_xpu.py
test_elementwise_pow_op.py
test_elementwise_sub_op.py
test_erf_op.py
test_exception.py
test_fill_constant_op.py
test_fleet_base.py
test_flip.py
test_for_enumerate.py
test_functional_conv1d.py
test_functional_conv2d.py
test_functional_conv2d_transpose.py
test_functional_conv3d.py
test_functional_conv3d_transpose.py
test_gather_nd_op.py
test_gelu_op.py
test_grad_clip_minimize.py
test_gradient_clip.py
test_group_norm_op.py
test_imperative_auto_mixed_precision_for_eager.py
test_imperative_container_layerlist.py
test_imperative_container_parameterlist.py
test_imperative_container_sequential.py
test_imperative_deepcf.py
test_imperative_double_grad.py
test_imperative_framework.py
test_imperative_gan.py
test_imperative_gnn.py
test_imperative_layer_trainable.py
test_imperative_lod_tensor_to_selected_rows.py
test_imperative_mnist_sorted_gradient.py
test_imperative_named_members.py
test_imperative_ocr_attention_model.py
test_imperative_optimizer.py
test_imperative_optimizer_v2.py
test_imperative_parallel_coalesce_split.py
test_imperative_partitial_backward.py
test_imperative_ptb_rnn_sorted_gradient.py
test_imperative_recurrent_usage.py
test_imperative_reinforcement.py
test_imperative_resnet.py
test_imperative_resnet_sorted_gradient.py
test_imperative_save_load_v2.py
test_imperative_selected_rows.py
test_imperative_selected_rows_to_lod_tensor.py
test_imperative_star_gan_with_gradient_penalty.py
test_imperative_transformer_sorted_gradient.py
test_imperative_triple_grad.py
test_imperative_using_non_zero_gpu.py
test_index_select_op.py
test_index_select_op_xpu.py
test_instance_norm_op.py
test_instance_norm_op_v2.py
test_inverse_op.py
test_inverse_op_xpu.py
test_kron_op.py
test_label_smooth_functional.py
test_lac.py
test_learning_rate_scheduler.py
test_linear_interp_op.py
test_linear_interp_v2_op.py
test_matmul_op.py
test_matmul_op_xpu.py
test_matrix_power_op.py
#61534
test_merged_adam_op.py
test_merged_adam_op_xpu.py
test_meshgrid_op.py
test_mnist.py
test_mobile_net.py
test_mse_loss.py
test_nansum_api.py
test_nn_functional_hot_op.py
test_nonzero_api.py
test_one_hot_v2_op_xpu.py
test_op_function_generator.py
test_optimizer_in_control_flow.py
test_paddle_imperative_double_grad.py
test_partial_program.py
test_pylayer.py
test_reduce_op.py
test_regularizer.py
test_regularizer_api.py
test_repeat_interleave_op.py
test_roll_op.py
test_rot90_op.py
test_save_load.py
test_scatter_nd_op.py
test_scatter_op.py
test_se_resnet.py
test_sentiment.py
test_slice_op.py
test_softmax_mask_fuse_op.py
test_softmax_mask_fuse_upper_triangle_op.py
test_solve_op.py
test_stack_op.py
test_traced_layer_err_msg.py
test_transpose_op.py
test_tril_triu_op.py
test_unfold_op.py
test_unfold_op_xpu.py
test_where_op.py
test_where_op_xpu.py
test_word2vec.py
transformer_dygraph_model.py
python/paddle/base/dygraph/tensor_patch_methods.py
python/paddle/base/layers/math_op_patch.py
python/paddle/base/framework.py
python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_utils.py
python/paddle/distributed/fleet/utils/mix_precision_utils.py
python/paddle/hapi/model.py
python/paddle/nn/functional/loss.py
python/paddle/nn/layer/layers.py
python/paddle/nn/layer/norm.py
python/paddle/pir/math_op_patch.py
残党 C:
Program.random_seed
Program.random_seed
是 Paddle 早期静态图下用来设置随机种子的方式,之后动态图也直接复用了Program.random_seed
,并有一些random_seed
的处理逻辑。但我们现在有另一个更常用的paddle.seed
API,更加符合动态图的惯用范式,因此希望完全将Program.random_seed
的用法用paddle.seed
来替代,同样,我们需要先清理掉框架内已有的用法,比如:dist_ctr.py
dist_fleet_ctr.py
dist_fleet_ctr_ps_gpu.py
dist_fleet_heter_pipeline_ctr.py
dist_fleet_simnet_bow.py
dist_fleet_sync_batch_norm.py
dist_mnist.py
dist_mnist_dgc.py
dist_mnist_lars.py
dist_se_resnext.py
dist_sharding_save.py
dist_word2vec.py
ir_memory_optimize_net_base.py
op_test_ipu.py
test_cond.py
test_custom_leaky_relu_ipu.py
test_detection.py
test_dist_base.py
test_dist_data_parallel_ipu.py
test_dist_pod128_sample.py
test_dist_transpiler.py
test_dropout_nd_op.py
test_eager_deletion_dynamic_rnn_base.py
test_eager_deletion_padding_rnn.py
test_fused_attention_op.py
test_fused_attention_op_xpu.py
test_fused_attention_pass.py
test_fused_bias_dropout_residual_layer_norm_op.py
test_fused_feedforward_op.py
test_fused_feedforward_op_xpu.py
test_fused_feedforward_pass.py
test_fused_multi_transformer_int8_op.py
test_fused_resnet_basic_block_op_xpu.py
test_fused_transformer_encoder_layer.py
test_identity_loss_ipu.py
test_imperative_deepcf.py
test_imperative_mnist.py
test_imperative_mnist_sorted_gradient.py
test_imperative_out_scale.py
test_imperative_ptq.py
test_imperative_qat_amp.py
test_imperative_qat_lsq.py
test_imperative_qat_matmul.py
test_imperative_qat_user_defined.py
test_inference_model_io_ipu.py
test_initializer.py
test_initializer_nn.py
test_lambv2_op.py
test_llm_int8_linear.py
test_metrics.py
test_model_parallel_ipu.py
test_modelruntime_ipu.py
test_multiprocess_dataloader_dynamic.py
test_multiprocess_dataloader_iterable_dataset_dynamic.py
test_multiprocess_dataloader_iterable_dataset_static.py
test_multiprocess_dataloader_static.py
test_optimizer_ipu.py
test_program.py
test_quantization_mkldnn_pass.py
test_quantization_pass.py
test_rnn_decode_api.py
test_save_inference_model.py
test_seq2seq.py
test_static_save_load.py
test_sync_batch_norm_op.py
test_trt_conv_quant_dequant_pass.py
test_trt_fc_fuse_quant_dequant_pass.py
test_trt_matmul_quant_dequant.py
test_weight_decay.py
test_weight_only_linear.py
test_word2vec.py
test_yolov3.py
看板信息