[Tests] Standardize RNG seed utility across test files (#32982)

Signed-off-by: 7. Sun <jhao.sun@gmail.com>
This commit is contained in:
7. Sun
2026-01-24 06:47:14 +00:00
committed by GitHub
parent 0b9a735e11
commit 0ccecf8833
4 changed files with 13 additions and 20 deletions

View File

@@ -1,11 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import random
from typing import Any
import pytest
from tests.utils import create_new_process_for_each_test
from tests.utils import create_new_process_for_each_test, set_random_seed
from tests.v1.logits_processors.utils import (
DUMMY_LOGITPROC_ARG,
DUMMY_LOGITPROC_FQCN,
@@ -135,7 +134,7 @@ def test_custom_logitsprocs(monkeypatch, logitproc_source: CustomLogitprocSource
# Test that logitproc info is passed to workers
monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "1")
random.seed(40)
set_random_seed(40)
# Choose LLM args based on logitproc source
if logitproc_source == CustomLogitprocSource.LOGITPROC_SOURCE_NONE:
@@ -194,7 +193,7 @@ def test_custom_logitsprocs_req(monkeypatch):
# Test that logitproc info is passed to workers
monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "1")
random.seed(40)
set_random_seed(40)
_run_test(
{"logits_processors": [WrappedPerReqLogitsProcessor]}, logitproc_loaded=True
)
@@ -237,7 +236,7 @@ def test_rejects_custom_logitsprocs(
logitproc from
"""
monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "0")
random.seed(40)
set_random_seed(40)
test_params: dict[str, dict[str, Any]] = {
"pooling": {