Skip to content

Add some frac config to torch_error_skip - #408

Merged
cangtianhuang merged 3 commits into
PFCCLab:mainfrom
zrr1999:big-tensor/frac
Jul 22, 2025
Merged

cangtianhuang merged 3 commits into
PFCCLab:mainfrom
zrr1999:big-tensor/frac

Conversation

@zrr1999

@zrr1999 zrr1999 commented Jul 22, 2025 •

Copy link
Copy Markdown
Collaborator

torch 的 frac 不支持int,加入 torch_error_skip。

修复 #402 的 mapping 错误

由于 pytorch 的batch_norm API 没有 use_global_stats 或 track_running_stats 参数(pytorch在class层面实现的),pytorch在class中使用了training and not track_running_stats,目的是使用当 track_running_stats为True时忽略 training的作用,而当track_running_stats=False时以training为准,这时的行为相当于paddle的 use_global_stats=None。

而 paddle的行为是当 use_global_stats =None时以training参数为准,而当use_global_stats =True时,不论training参数为何,均执行use_global_stats=True的逻辑(即使用全局参数),use_global_stats=False时,不论training参数为何,均执行use_global_stats=False的逻辑(即不使用全局参数)。

所以使用 training if use_global_stats is None else not use_global_stats 来替代 training 可以保证pytorch行为 与 paddle行为一致。

两个参数的组合情况可以看 #402 列出的结果。

@paddle-bot

paddle-bot Bot commented Jul 22, 2025

Copy link
Copy Markdown

Thanks for your contribution!

"torch_kwargs": {
"momentum": "1 - momentum",
"training": "training and not use_global_stats"
"training": "training if use_global_stats is None else not use_global_stats"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个逻辑好像有点问题,如果 use_global_stats = False,那就与 training 值无关了

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

由于 pytorch 的batch_norm API 没有 use_global_stats 或 track_running_stats 参数(pytorch在class层面实现的),pytorch在class中使用了training and not track_running_stats,目的是使用当 track_running_stats为True时忽略 training的作用,而当track_running_stats=False时以training为准,这时的行为相当于paddle的 use_global_stats=None。

而 paddle的行为是当 use_global_stats =None时以training参数为准,而当use_global_stats =True时,不论training参数为何,均执行use_global_stats=True的逻辑(即使用全局参数),use_global_stats=False时,不论training参数为何,均执行use_global_stats=False的逻辑(即不使用全局参数)。

所以使用 training if use_global_stats is None else not use_global_stats 来替代 training 可以保证pytorch行为 与 paddle行为一致。

两个参数的组合情况可以看 #402 列出的结果。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

great, got it

@cangtianhuang cangtianhuang self-assigned this Jul 22, 2025

@cangtianhuang cangtianhuang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@cangtianhuang
cangtianhuang merged commit 58f6185 into PFCCLab:main Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants