Unverified Commit 110f59a3 authored by மனோஜ்குமார் பழனிச்சாமி's avatar மனோஜ்குமார் பழனிச்சாமி Committed by GitHub
Browse files
parent 2e3b969e
...@@ -8,32 +8,17 @@ from vllm.platforms.interface import Platform ...@@ -8,32 +8,17 @@ from vllm.platforms.interface import Platform
def test_seed_behavior(): def test_seed_behavior():
# Test with seed=None # Test with a specific seed
Platform.seed_everything(None) Platform.seed_everything(42)
random_value_1 = random.randint(0, 100) random_value_1 = random.randint(0, 100)
np_random_value_1 = np.random.randint(0, 100) np_random_value_1 = np.random.randint(0, 100)
torch_random_value_1 = torch.randint(0, 100, (1, )).item() torch_random_value_1 = torch.randint(0, 100, (1, )).item()
Platform.seed_everything(None) Platform.seed_everything(42)
random_value_2 = random.randint(0, 100) random_value_2 = random.randint(0, 100)
np_random_value_2 = np.random.randint(0, 100) np_random_value_2 = np.random.randint(0, 100)
torch_random_value_2 = torch.randint(0, 100, (1, )).item() torch_random_value_2 = torch.randint(0, 100, (1, )).item()
assert random_value_1 != random_value_2 assert random_value_1 == random_value_2
assert np_random_value_1 != np_random_value_2 assert np_random_value_1 == np_random_value_2
assert torch_random_value_1 != torch_random_value_2 assert torch_random_value_1 == torch_random_value_2
# Test with a specific seed
Platform.seed_everything(42)
random_value_3 = random.randint(0, 100)
np_random_value_3 = np.random.randint(0, 100)
torch_random_value_3 = torch.randint(0, 100, (1, )).item()
Platform.seed_everything(42)
random_value_4 = random.randint(0, 100)
np_random_value_4 = np.random.randint(0, 100)
torch_random_value_4 = torch.randint(0, 100, (1, )).item()
assert random_value_3 == random_value_4
assert np_random_value_3 == np_random_value_4
assert torch_random_value_3 == torch_random_value_4
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment