Skip to content

Commit 92f3183

Browse files
committed
lint
Signed-off-by: மனோஜ்குமார் பழனிச்சாமி <smartmanoj42857@gmail.com>
1 parent ef5e072 commit 92f3183

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

tests/test_seed_behavior.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
1-
import random
2-
import numpy as np
3-
import torch
4-
from vllm.platforms.interface import Platform
5-
6-
def test_seed_behavior():
7-
# Test with seed=None
8-
Platform.seed_everything(None)
9-
random_value_1 = random.randint(0, 100)
10-
np_random_value_1 = np.random.randint(0, 100)
11-
torch_random_value_1 = torch.randint(0, 100, (1,)).item()
12-
13-
Platform.seed_everything(None)
14-
random_value_2 = random.randint(0, 100)
15-
np_random_value_2 = np.random.randint(0, 100)
16-
torch_random_value_2 = torch.randint(0, 100, (1,)).item()
17-
18-
assert random_value_1 != random_value_2
19-
assert np_random_value_1 != np_random_value_2
20-
assert torch_random_value_1 != torch_random_value_2
21-
22-
# Test with a specific seed
23-
Platform.seed_everything(42)
24-
random_value_3 = random.randint(0, 100)
25-
np_random_value_3 = np.random.randint(0, 100)
26-
torch_random_value_3 = torch.randint(0, 100, (1,)).item()
27-
28-
Platform.seed_everything(42)
29-
random_value_4 = random.randint(0, 100)
30-
np_random_value_4 = np.random.randint(0, 100)
31-
torch_random_value_4 = torch.randint(0, 100, (1,)).item()
32-
33-
assert random_value_3 == random_value_4
34-
assert np_random_value_3 == np_random_value_4
35-
assert torch_random_value_3 == torch_random_value_4
1+
# SPDX-License-Identifier: Apache-2.0
2+
import random
3+
4+
import numpy as np
5+
import torch
6+
7+
from vllm.platforms.interface import Platform
8+
9+
10+
def test_seed_behavior():
11+
# Test with seed=None
12+
Platform.seed_everything(None)
13+
random_value_1 = random.randint(0, 100)
14+
np_random_value_1 = np.random.randint(0, 100)
15+
torch_random_value_1 = torch.randint(0, 100, (1, )).item()
16+
17+
Platform.seed_everything(None)
18+
random_value_2 = random.randint(0, 100)
19+
np_random_value_2 = np.random.randint(0, 100)
20+
torch_random_value_2 = torch.randint(0, 100, (1, )).item()
21+
22+
assert random_value_1 != random_value_2
23+
assert np_random_value_1 != np_random_value_2
24+
assert torch_random_value_1 != torch_random_value_2
25+
26+
# Test with a specific seed
27+
Platform.seed_everything(42)
28+
random_value_3 = random.randint(0, 100)
29+
np_random_value_3 = np.random.randint(0, 100)
30+
torch_random_value_3 = torch.randint(0, 100, (1, )).item()
31+
32+
Platform.seed_everything(42)
33+
random_value_4 = random.randint(0, 100)
34+
np_random_value_4 = np.random.randint(0, 100)
35+
torch_random_value_4 = torch.randint(0, 100, (1, )).item()
36+
37+
assert random_value_3 == random_value_4
38+
assert np_random_value_3 == np_random_value_4
39+
assert torch_random_value_3 == torch_random_value_4

0 commit comments

Comments
 (0)