Skip to content

开启 FLAGS_cudnn_deterministic 时同步启用 Torch 确定算法 - #724

Merged
feixi139 merged 1 commit into
PFCCLab:mainfrom
feixi139:fix-cudnn-deterministic
Sep 7, 2026
Merged

feixi139 merged 1 commit into
PFCCLab:mainfrom
feixi139:fix-cudnn-deterministic

Conversation

@feixi139

@feixi139 feixi139 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

背景

accuracy_compatible 流水线需要在 Paddle 开启 FLAGS_cudnn_deterministic 时,与 Torch 对照侧同步走确定算法。原先 YAML 只打开了 FLAGS_use_accuracy_compatible_kernel,Torch 对照仍使用默认非确定实现,index_select 等存在重复 index 的反向 scatter-add 在 atol/rtol=0 下无法对齐。

修改内容

  • test_pipeline/generic_configs/run_accuracy_compatible.yaml:增加 FLAGS_cudnn_deterministic: "1"
  • tester/paddle_to_torch/rules.pyBaseRule.build_result() 的 preprocess 在该 flag 为真时调用 torch.use_deterministic_algorithms(True)。flag 关闭时不改变 Torch 行为。

验证

  • python -m py_compile tester/paddle_to_torch/rules.py
  • ruff check tester/paddle_to_torch/rules.pyruff format --check tester/paddle_to_torch/rules.py
  • python tools/check_comment_ratio.py(staged diff 评论比例 20%)
  • git diff --check
  • 在本分支用同一组 4 条 paddle.index_selectatol=0rtol=0FLAGS_use_accuracy_compatible_kernel=1 实测:
    • 开启 FLAGS_cudnn_deterministic=1:4/4 pass
    • 关闭该 flag:4/4 paddle_accuracy(反向约 35% 元素差 1 ulp)

未执行:仓库 pre-commit run --files ... 因首次拉取 hook 环境超时未跑完;等价的 yaml 解析、ruff、py_compile、comment-ratio 检查已通过。

accuracy_compatible 流水线增加 FLAGS_cudnn_deterministic;
paddle_to_torch 在该 flag 打开时调用 torch.use_deterministic_algorithms(True)。
@feixi139
feixi139 merged commit be7343a into PFCCLab:main Sep 7, 2026
1 check passed
@feixi139
feixi139 deleted the fix-cudnn-deterministic branch September 7, 2026 08:59
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.

1 participant