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),