Skip to content

Commit

Permalink
enable deterministic mode for npu (#31253)
Browse files Browse the repository at this point in the history
  • Loading branch information
statelesshz authored Jun 5, 2024
1 parent 4a60249 commit 41cf409
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/transformers/trainer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def enable_full_determinism(seed: int, warn_only: bool = False):
# depending on the CUDA version, so we set them both here
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
# The environment variable required to enable deterministic mode on Ascend NPUs.
os.environ["ASCEND_LAUNCH_BLOCKING"] = 1
os.environ["HCCL_DETERMINISTIC"] = 1
torch.use_deterministic_algorithms(True, warn_only=warn_only)

# Enable CUDNN deterministic mode
Expand Down

0 comments on commit 41cf409

Please sign in to comment.