vllm/tests/test_seed_behavior.py
மனோஜ்குமார் பழனிச்சாமி 110f59a33e
[Bugfix] fix flaky test (#13089)
Signed-off-by: மனோஜ்குமார் பழனிச்சாமி <smartmanoj42857@gmail.com>
2025-02-11 14:41:20 +00:00

25 lines
748 B
Python

# SPDX-License-Identifier: Apache-2.0
import random
import numpy as np
import torch
from vllm.platforms.interface import Platform
def test_seed_behavior():
# Test with a specific seed
Platform.seed_everything(42)
random_value_1 = random.randint(0, 100)
np_random_value_1 = np.random.randint(0, 100)
torch_random_value_1 = torch.randint(0, 100, (1, )).item()
Platform.seed_everything(42)
random_value_2 = random.randint(0, 100)
np_random_value_2 = np.random.randint(0, 100)
torch_random_value_2 = torch.randint(0, 100, (1, )).item()
assert random_value_1 == random_value_2
assert np_random_value_1 == np_random_value_2
assert torch_random_value_1 == torch_random_value_2