[Model Runner V2] Enable encoder token embedding (#50574)

Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
Taneem Ibrahim
2026-08-01 07:55:36 -04:00
committed by GitHub
parent 3986b967b2
commit 652ba59229
4 changed files with 106 additions and 7 deletions
+13 -2
View File
@@ -379,8 +379,16 @@ def test_colbert_embed_not_supported(
vllm_model.embed([TEXTS_1[0]])
@pytest.mark.parametrize("backend", list(COLBERT_MODELS.keys()))
def test_colbert_hf_comparison(vllm_runner, backend):
@pytest.mark.parametrize(
("backend", "use_v2"),
[
pytest.param("bert", True, id="bert-v2"),
pytest.param("modernbert", True, id="modernbert-v2"),
pytest.param("jina", False, id="jina-v1"),
pytest.param("lfm2", False, id="lfm2-v1"),
],
)
def test_colbert_hf_comparison(vllm_runner, monkeypatch, backend, use_v2):
"""Test that vLLM ColBERT embeddings match HuggingFace for each backend."""
from transformers import AutoTokenizer
@@ -393,6 +401,8 @@ def test_colbert_hf_comparison(vllm_runner, backend):
assert isinstance(extra_kwargs, dict)
test_texts = [TEXTS_1[0], TEXTS_2[0]]
monkeypatch.setenv("VLLM_USE_V2_MODEL_RUNNER", "1" if use_v2 else "0")
with vllm_runner(
model_name,
runner="pooling",
@@ -401,6 +411,7 @@ def test_colbert_hf_comparison(vllm_runner, backend):
enforce_eager=True,
**extra_kwargs,
) as vllm_model:
assert vllm_model.llm.llm_engine.vllm_config.use_v2_model_runner == use_v2
vllm_outputs = vllm_model.token_embed(test_texts)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")