Skip to content

Commit

Permalink
Non-determinstic Flag
Browse files Browse the repository at this point in the history
Summary: Provide optional support for non-determinstic behavor for more representative benchmarking

Reviewed By: joshuadeng

Differential Revision: D56690894

fbshipit-source-id: 29f0f0e61007dca2a56f938d6b396aecafa8d54b
  • Loading branch information
dstaay-fb authored and facebook-github-bot committed Apr 29, 2024
1 parent c80ebca commit fa37d69
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions torchrec/distributed/test_utils/multi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
world_size: int,
backend: str = "gloo",
local_size: Optional[int] = None,
use_deterministic_algorithms: bool = True,
) -> None:

self.rank = rank
Expand All @@ -42,11 +43,14 @@ def __init__(
self.device: torch.device = torch.device(f"cuda:{rank}")
torch.cuda.set_device(self.device)

torch.backends.cudnn.allow_tf32 = False
torch.backends.cuda.matmul.allow_tf32 = False
else:
self.device: torch.device = torch.device("cpu")
torch.use_deterministic_algorithms(True)

if use_deterministic_algorithms:
if torch.cuda.is_available():
torch.backends.cudnn.allow_tf32 = False
torch.backends.cuda.matmul.allow_tf32 = False
torch.use_deterministic_algorithms(True)

self.pg: Optional[dist.ProcessGroup] = None

Expand Down

0 comments on commit fa37d69

Please sign in to comment.