Skip to content

Commit 7226b38

Browse files
amirafzalifacebook-github-bot
authored andcommitted
migrate existing set_worker_random_seed callsites
Summary: **Diff Purpose & Changes** - We can migrate all instances of worker.set_random_seed_impl to now use builtins.random.set_manual_seed. - Wonder if some of these cases would benefit from random_seed() instead. Maybe that can be checked out in the future. Reviewed By: suo Differential Revision: D72945165
1 parent ae89bec commit 7226b38

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

python/monarch/worker/worker.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@
6060
CONTROLLER_COMPILED_REPEAT = True
6161

6262

63-
def set_random_seed_impl(seed, process_idx):
64-
torch.manual_seed(seed ^ process_idx)
65-
66-
6763
def set_default_dtype(dtype: torch.dtype):
6864
torch.set_default_dtype(dtype)
6965

python/tests/test_remote_functions.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131
from monarch._testing import BackendType, TestingContext
3232
from monarch.builtins.log import log_remote
33+
from monarch.builtins.random import set_manual_seed_remote
3334
from monarch.cached_remote_function import remote_autograd_function
3435
from monarch.common import remote as remote_module
3536
from monarch.common.device_mesh import DeviceMesh
@@ -742,12 +743,8 @@ def something_else():
742743
something_else()
743744

744745
def test_setting_random_seed(self, backend_type):
745-
set_worker_random_seed = remote(
746-
"monarch.worker.worker.set_random_seed_impl", propagate="inspect"
747-
)
748-
749746
with self.local_device_mesh(2, 2, backend_type):
750-
set_worker_random_seed(12345, 0)
747+
set_manual_seed_remote(12345)
751748
t = torch.randn(3, 4)
752749
t_d = torch.randn(3, 4, device="cuda")
753750
ref = fetch_shard(t).result()

0 commit comments

Comments
 (0)