A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 9, 13:33 UTC
[CI][Pooling] Stabilize ModernBERT test (#32909)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Andreas Karatzas committed
Jan 26, 2026 at 23:26 UTC
6c006457123f802d78e0570471ee8ea2d2a87dfb
1 file changed
+27
tests/models/language/pooling/test_token_classification.py
+27
@@ -1,5 +1,8 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+import random
4
+
5
+import numpy as np
6
import pytest
7
import torch
8
from transformers import AutoModelForTokenClassification
@@ -8,6 +11,20 @@ from tests.models.utils import softmax
11
from vllm.platforms import current_platform
12
13
14
+@pytest.fixture(autouse=True)
15
+def seed_everything():
16
+ """Seed all random number generators for reproducibility."""
17
+ seed = 0
18
+ random.seed(seed)
19
+ np.random.seed(seed)
20
+ torch.manual_seed(seed)
21
+ if torch.cuda.is_available():
22
+ torch.cuda.manual_seed_all(seed)
23
+ torch.backends.cudnn.deterministic = True
24
+ torch.backends.cudnn.benchmark = False
25
+ yield
26
+
27
+
28
@pytest.mark.parametrize("model", ["boltuix/NeuroBERT-NER"])
29
# The float32 is required for this tiny model to pass the test.
30
@pytest.mark.parametrize("dtype", ["float"])
@@ -51,6 +68,7 @@ def test_bert_models(
68
69
@pytest.mark.parametrize("model", ["disham993/electrical-ner-ModernBERT-base"])
70
@pytest.mark.parametrize("dtype", ["float"])
71
+@pytest.mark.flaky(reruns=3)
72
@torch.inference_mode
73
def test_modernbert_models(
74
hf_runner,
@@ -59,6 +77,15 @@ def test_modernbert_models(
77
model: str,
78
dtype: str,
79
) -> None:
80
+ # NOTE: https://github.com/vllm-project/vllm/pull/32403
81
+ # `disham993/electrical-ner-ModernBERT-base` is a randomly initialized
82
+ # model, which can cause numerical precision variance and edge cases.
83
+ # We use @flaky(reruns=3) to mitigate intermittent failures.
84
+ print(
85
+ f"\n[NOTE] Testing {model} (randomly initialized weights) - "
86
+ "flaky tolerance enabled due to numerical precision variance."
87
+ )
88
+
89
with vllm_runner(model, max_model_len=None, dtype=dtype) as vllm_model:
90
vllm_outputs = vllm_model.token_classify(example_prompts)
91