From 281234a825d8cd5808d11f853cf0a64a20e3c8fa Mon Sep 17 00:00:00 2001 From: feixi139 <66367509+feixi139@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:13:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AF=20FLAGS=5Fcudnn=5Fdeterminis?= =?UTF-8?q?tic=20=E6=97=B6=E5=90=8C=E6=AD=A5=E5=90=AF=E7=94=A8=20Torch=20?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit accuracy_compatible 流水线增加 FLAGS_cudnn_deterministic; paddle_to_torch 在该 flag 打开时调用 torch.use_deterministic_algorithms(True)。 --- test_pipeline/generic_configs/run_accuracy_compatible.yaml | 1 + tester/paddle_to_torch/rules.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/test_pipeline/generic_configs/run_accuracy_compatible.yaml b/test_pipeline/generic_configs/run_accuracy_compatible.yaml index 957f7a7f..8453ee27 100644 --- a/test_pipeline/generic_configs/run_accuracy_compatible.yaml +++ b/test_pipeline/generic_configs/run_accuracy_compatible.yaml @@ -8,6 +8,7 @@ runner: foreground: true env: FLAGS_use_accuracy_compatible_kernel: "1" + FLAGS_cudnn_deterministic: "1" input: api_config_file: "${APITEST_MODEL}/accuracy_compatible/accuracy_compatible.txt" output: diff --git a/tester/paddle_to_torch/rules.py b/tester/paddle_to_torch/rules.py index 24f5d834..2611aa21 100644 --- a/tester/paddle_to_torch/rules.py +++ b/tester/paddle_to_torch/rules.py @@ -346,6 +346,11 @@ def code_lines(source: str | Sequence[str]) -> Sequence[str]: paddle_api, Code( preprocess=[ + # Keep Torch deterministic algorithms in lockstep with Paddle. + "import paddle", + "if paddle.get_flags('FLAGS_cudnn_deterministic')" + "['FLAGS_cudnn_deterministic']:", + " torch.use_deterministic_algorithms(True)", *self._build_default_code(), *code_lines(preprocess), *self._build_argument_map_code(ensure_args=generate_standard_call),