-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into policy_compatibility
- Loading branch information
Showing
15 changed files
with
90 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
tests/data/save_policy_to_safetensors/aloha_act/actions.safetensors
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
tests/data/save_policy_to_safetensors/aloha_act/grad_stats.safetensors
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
tests/data/save_policy_to_safetensors/aloha_act/output_dict.safetensors
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
tests/data/save_policy_to_safetensors/aloha_act/param_stats.safetensors
Binary file not shown.
Binary file added
BIN
+928 Bytes
tests/data/save_policy_to_safetensors/xarm_tdmpc/actions.safetensors
Binary file not shown.
Binary file added
BIN
+16.5 KB
tests/data/save_policy_to_safetensors/xarm_tdmpc/grad_stats.safetensors
Binary file not shown.
Binary file added
BIN
+240 Bytes
tests/data/save_policy_to_safetensors/xarm_tdmpc/output_dict.safetensors
Binary file not shown.
Binary file added
BIN
+35.5 KB
tests/data/save_policy_to_safetensors/xarm_tdmpc/param_stats.safetensors
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import random | ||
from typing import Callable | ||
|
||
import numpy as np | ||
import pytest | ||
import torch | ||
|
||
from lerobot.common.utils.utils import seeded_context, set_global_seed | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"rand_fn", | ||
[ | ||
random.random, | ||
np.random.random, | ||
lambda: torch.rand(1).item(), | ||
] | ||
+ [lambda: torch.rand(1, device="cuda")] | ||
if torch.cuda.is_available() | ||
else [], | ||
) | ||
def test_seeding(rand_fn: Callable[[], int]): | ||
set_global_seed(0) | ||
a = rand_fn() | ||
with seeded_context(1337): | ||
c = rand_fn() | ||
b = rand_fn() | ||
set_global_seed(0) | ||
a_ = rand_fn() | ||
b_ = rand_fn() | ||
# Check that `set_global_seed` lets us reproduce a and b. | ||
assert a_ == a | ||
# Additionally, check that the `seeded_context` didn't interrupt the global RNG. | ||
assert b_ == b | ||
set_global_seed(1337) | ||
c_ = rand_fn() | ||
# Check that `seeded_context` and `global_seed` give the same reproducibility. | ||
assert c_ == c |