@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 0c1e6f63f5
Fork 0

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 1, 23:45 UTC

[Bugfix] Fix VLLMNotFoundError when using LoRA adapter name in poolin… (#44410)

Signed-off-by: Ted Mostly <wanghenshui@qq.com>

Ted Mostly committed Jun 4, 2026 at 10:22 UTC 0c1e6f63f5608f76f459355cb6e164f093bb807b
2 files changed +62
tests/entrypoints/serve/lora/test_serving_models.py
+61
@@ -6,6 +6,7 @@ from unittest.mock import MagicMock
6
7 import pytest
8
9 +from vllm import PoolingParams
10 from vllm.config import ModelConfig
11 from vllm.engine.protocol import EngineClient
12 from vllm.entrypoints.openai.engine.protocol import (
@@ -13,10 +14,13 @@ from vllm.entrypoints.openai.engine.protocol import (
14 )
15 from vllm.entrypoints.openai.models.protocol import BaseModelPath
16 from vllm.entrypoints.openai.models.serving import OpenAIServingModels
17 +from vllm.entrypoints.pooling.base.serving import PoolingServingBase
18 +from vllm.entrypoints.pooling.typing import PoolingServeContext
19 from vllm.entrypoints.serve.lora.protocol import (
20 LoadLoRAAdapterRequest,
21 UnloadLoRAAdapterRequest,
22 )
23 +from vllm.exceptions import VLLMNotFoundError
24 from vllm.lora.request import LoRARequest
25
26 MODEL_NAME = "hmellor/tiny-random-LlamaForCausalLM"
@@ -130,3 +134,60 @@ async def test_unload_lora_adapter_not_found():
134 assert isinstance(response, ErrorResponse)
135 assert response.error.type == "NotFoundError"
136 assert response.error.code == HTTPStatus.NOT_FOUND
137 +
138 +
139 +class _ConcretePoolingServing(PoolingServingBase):
140 + """Minimal concrete subclass used only in these unit tests."""
141 +
142 + request_id_prefix = "test"
143 +
144 + def get_io_processor(self, request):
145 + raise NotImplementedError
146 +
147 + def _build_response(self, ctx):
148 + raise NotImplementedError
149 +
150 +
151 +def _make_pooling_serving(lora_name: str) -> _ConcretePoolingServing:
152 + lora_request = LoRARequest(
153 + lora_name=lora_name, lora_int_id=1, lora_path="/path/to/lora"
154 + )
155 + mock_models = MagicMock()
156 + mock_models.lora_requests = {lora_name: lora_request}
157 + mock_models.is_base_model.side_effect = lambda name: name == MODEL_NAME
158 +
159 + serving = object.__new__(_ConcretePoolingServing)
160 + serving.models = mock_models
161 + return serving
162 +
163 +
164 +def _make_pooling_ctx(model_name: str) -> PoolingServeContext:
165 + mock_request = MagicMock()
166 + mock_request.model = model_name
167 + return PoolingServeContext(
168 + request=mock_request,
169 + model_name=MODEL_NAME,
170 + request_id="test-id",
171 + pooling_params=PoolingParams(),
172 + )
173 +
174 +
175 +def test_pooling_maybe_get_adapters_lora_name_sets_lora_request():
176 + """LoRA adapter name must populate ctx.lora_request without raising."""
177 + lora_name = "bot-embed-lora"
178 + serving = _make_pooling_serving(lora_name)
179 + ctx = _make_pooling_ctx(lora_name)
180 +
181 + serving._maybe_get_adapters(ctx)
182 +
183 + assert ctx.lora_request is not None
184 + assert ctx.lora_request.lora_name == lora_name
185 +
186 +
187 +def test_pooling_maybe_get_adapters_unknown_model_raises():
188 + """An unrecognised model name must still raise VLLMNotFoundError."""
189 + serving = _make_pooling_serving("some-lora")
190 + ctx = _make_pooling_ctx("unknown-model")
191 +
192 + with pytest.raises(VLLMNotFoundError):
193 + serving._maybe_get_adapters(ctx)
vllm/entrypoints/pooling/base/serving.py
+1
@@ -283,6 +283,7 @@ class PoolingServingBase(ABC):
283 request = ctx.request
284 if request.model in self.models.lora_requests:
285 ctx.lora_request = self.models.lora_requests[request.model]
286 + return None
287
288 # Currently only support default modality specific loras
289 # if we have exactly one lora matched on the request.