[Dy2stat]support pure fp16 for dy2stat #36944
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
Others
Describe
本PR在
CastPureFp16Inputs函数中加入了特判逻辑:对于动转静中所调用的run_program op直接跳过,不再进行后续的cast操作。因为run_program op只有FP32 kernel,且我们在动转静pure fp16训练时在调用run_program op时已经将run_program op的输入cast为fp16类型,所以在CastPureFp16Inputs应该跳过对于run_program op的处理,避免将其输入再cast回fp32类型。1e-3,以确保单测通过。对于动转静pure fp16训练,已经在mnist和resnet网络上测试了网络的收敛性, 均可以正常收敛。paddle.amp.auto_cast接口中黑白名单(custom_white_list参数和custom_black_list参数)的设置。在此PR之前在动转静AMP训练中设置这两个参数并不会生效。