Skip to content

Commit

Permalink
Allow for warn_only selection in enable_full_determinism (#24496)
Browse files Browse the repository at this point in the history
* Warn only in enable full determinism

* Add option in the function definition
  • Loading branch information
Frank995 authored Jun 28, 2023
1 parent 11cb6e0 commit daccde1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/trainer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def seed_worker(_):
set_seed(worker_seed)


def enable_full_determinism(seed: int):
def enable_full_determinism(seed: int, warn_only: bool = False):
"""
Helper function for reproducible behavior during distributed training. See
- https://pytorch.org/docs/stable/notes/randomness.html for pytorch
Expand All @@ -70,7 +70,7 @@ def enable_full_determinism(seed: int):
# depending on the CUDA version, so we set them both here
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
torch.use_deterministic_algorithms(True)
torch.use_deterministic_algorithms(True, warn_only=warn_only)

# Enable CUDNN deterministic mode
torch.backends.cudnn.deterministic = True
Expand Down

0 comments on commit daccde1

Please sign in to comment.