Skip to content

Conversation

@WHoutstanding
Copy link
Contributor

@WHoutstanding WHoutstanding commented Jan 4, 2026

PR Category

Description

  1. fix bug of ./graph_net/torch/dtyp_generlizer.py.
  2. use ./graph_net/config/small100_torch_samples_list.txt to test dtype generlization pass and graph_net.torch.validate to valiate.

@paddle-bot
Copy link

paddle-bot bot commented Jan 4, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Jan 4, 2026
from torch.fx.passes.shape_prop import ShapeProp


def parse_immutable_model_path_into_sole_graph_module(model_path, device=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个基础函数不可以改。它的名字没有shape propagate的语义。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些测试代码太复杂了,没法review。应该写成标准的sample_pass的test。可以借鉴#514 这个pr的graph_net/test/subgraph_input_shapes_naive_rewriter_test.sh的写法。

@WHoutstanding
Copy link
Contributor Author

  1. 在判断计算图need_rewrite之前, parse_immutable_model_path_into_sole_graph_module()返回的trace_model不包含tensor_meta导致dtype_pass.need_rewrite(traced_model)返回总是false,所以需要在need_rewrite之前为trace_model加入tensor_meta,需要调用ShapeProp(traced_model).propagate(*inputs),但是无法获得inputs,因此调用get_torch_module_and_inputs和parse_sole_graph_module,使trace_model包含tensor_meta,这样是否会破坏InitDataTypeGeneralizationPasses的语义
  2. 在写dtype_gen_test.sh时,我在测试时对torchision下的所有模型进行dtype generalizaion pass测试,并用 graph_net.torch.validate 验证生成的 samples of dtype generalization pass

Comment on lines 53 to 55
for sample in "$TORCHVISION_ROOT"/*; do
python3 -m graph_net.model_path_handler --model-path $sample --handler-config=$CONFIG_APPLY
done
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里直接指定了torchvision,这是不对的。应该取自graph_net/config/small100_torch_samples_list.txt。

else
echo "FAIL"
fi
done
Copy link
Collaborator

@lixinqi lixinqi Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

替换为

done | tee >(grep SUCCESS | wc -l | xargs -I{} echo SUCCESS {}) | tee >(grep FAIL | wc -l | xargs -I{} echo FAIL {}); wait

这样表示统计最终的成功与失败的个数

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_immutable_model_path_into_sole_graph_module()返回的trace_model不包含tensor_meta导致dtype_pass.need_rewrite(traced_model)返回总是false,所以改为调用get_torch_module_and_inputs和parse_sole_graph_module和ShapeProp(traced_model).propagate(*inputs),使trace_model包含tensor_meta

@WHoutstanding
Copy link
Contributor Author

微信图片_20260107233929_13_47 测试了small100_torch_samples_list.txt, dtype generlization pass 成功了 74个(float16 bfloat6),成功率74%

@@ -1,12 +1,12 @@
#!/bin/bash
# !/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个shabang是标准写法,不应该改。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

收到

@lixinqi lixinqi merged commit c036b77 into PaddlePaddle:develop Jan 8, 2026
3 checks passed
@WHoutstanding WHoutstanding deleted the dtype_gen_test branch January 8, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants