Skip to content

Conversation

@G2uge
Copy link
Contributor

@G2uge G2uge commented Nov 6, 2025

Description

为了解决 GraphNet 计算图中使用不稳定 API torch._C._fft.fft_rfft 导致无法转换为 Paddle 计算图的问题,新增了 fft_rfft_to_rfft 方法。该方法会遍历 FX Graph 的所有节点,查找 target 为 torch._C._fft.fft_rfft 的节点,并将其替换为 PyTorch 官方稳定 API torch.fft.rfft。替换完成后,重新编译计算图,确保后续模型运行时只会调用稳定接口。

@paddle-bot
Copy link

paddle-bot bot commented Nov 6, 2025

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Nov 6, 2025
@G2uge
Copy link
Contributor Author

G2uge commented Nov 6, 2025

ES_result

if self.unstable_api == "torch._C._nn.avg_pool2d":
gm = self.avg_pool2d_to_avg_pool2d(gm)
elif self.unstable_api == "torch._C._fft.fft_rfft":
gm = self.fft_rfft_to_rfft(gm)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里每次提交都会冲突,给合入造成了一些小困扰。我建立在这里写一行这样的代码:

methods = (name for name in vars(type(self)).keys() if name.startswith('_impl_unstable_to_stable'))
for method in methods:
    gm = getattr(self, method)(gm)

这样每个人的代码就写到各自的_impl_unstable_to_stable_XXX方法里,不再彼此干扰。

@lixinqi lixinqi merged commit d5ce907 into PaddlePaddle:develop Nov 6, 2025
3 of 4 checks passed
@lixinqi
Copy link
Collaborator

lixinqi commented Nov 6, 2025

commit log尽量写英文

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants