Fix seed parameter behavior in vLLM (#13007)

Signed-off-by: மனோஜ்குமார் பழனிச்சாமி <smartmanoj42857@gmail.com>
This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி
2025-02-10 20:56:50 +05:30
committed by GitHub
parent 51f0b5f7f6
commit 2ae889052c
3 changed files with 95 additions and 4 deletions

View File

@@ -211,16 +211,17 @@ class Platform:
return torch.inference_mode(mode=True)
@classmethod
def seed_everything(cls, seed: int) -> None:
def seed_everything(cls, seed: Optional[int] = None) -> None:
"""
Set the seed of each random module.
`torch.manual_seed` will set seed on all devices.
Loosely based on: https://github.com/Lightning-AI/pytorch-lightning/blob/2.4.0/src/lightning/fabric/utilities/seed.py#L20
"""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if seed is not None:
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
@classmethod
def check_and_update_config(cls, vllm_config: VllmConfig) -> None: