Skip to content

Commit f0bb7c8

Browse files
committed
pure Python LlmResponse
Signed-off-by: QI JUN <[email protected]>
1 parent 3c83644 commit f0bb7c8

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

tensorrt_llm/_torch/pyexecutor/llm_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,16 @@ class LlmResponse:
221221

222222
def __init__(self,
223223
request_id: int,
224-
error: str = None,
224+
error_msg: str = None,
225225
result: LlmResult = None,
226226
client_id: int = None):
227227
self.request_id = request_id
228-
self.error = error
228+
self.error_msg = error_msg
229229
self.result = result
230230
self.client_id = client_id
231231

232232
def has_error(self):
233-
return self.error is not None
233+
return self.error_msg is not None
234234

235235

236236
class LlmRequest(tensorrt_llm.bindings.internal.batch_manager.LlmRequest):

tensorrt_llm/_torch/pyexecutor/py_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ def _handle_errors(self, error_msg: Optional[str] = None):
19361936
self._terminate_request(request)
19371937
error_responses[req_id] = LlmResponse(
19381938
request_id=req_id,
1939-
error=error_msg,
1939+
error_msg=error_msg,
19401940
client_id=request.py_client_id)
19411941
self.active_requests.clear()
19421942
self._enqueue_responses(error_responses)

tensorrt_llm/executor/proxy.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
from .request import CancellingRequest, GenerationRequest
2525
from .result import GenerationResult, IterationResult
2626
from .utils import (ErrorResponse, IntraProcessQueue, WorkerCommIpcAddrs,
27-
create_mpi_comm_session, get_spawn_proxy_process_env,
28-
is_llm_response)
27+
create_mpi_comm_session, get_spawn_proxy_process_env)
2928
from .worker import GenerationExecutorWorker, worker_main
3029

3130
__all__ = [
@@ -172,8 +171,7 @@ def process_res(res):
172171
event_loop = event_loop or queue.loop
173172
else:
174173
queue.put(res)
175-
176-
if (is_llm_response(res) and res.result.is_final) or isinstance(
174+
if (hasattr(res, "result") and res.result.is_final) or isinstance(
177175
res, ErrorResponse):
178176
self._results.pop(client_id)
179177

tensorrt_llm/executor/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from strenum import StrEnum
99

1010
from tensorrt_llm._utils import mpi_rank
11-
from tensorrt_llm.bindings.executor import Response
1211
from tensorrt_llm.llmapi.utils import print_colored_debug
1312

1413
from ..llmapi.mpi_session import (MpiCommSession, MpiPoolSession, MpiSession,
@@ -141,11 +140,3 @@ class WorkerCommIpcAddrs(NamedTuple):
141140
result_queue_addr: tuple[str, Optional[bytes]]
142141
stats_queue_addr: tuple[str, Optional[bytes]]
143142
kv_cache_events_queue_addr: tuple[str, Optional[bytes]]
144-
145-
146-
def is_llm_response(instance):
147-
from tensorrt_llm._torch.pyexecutor.llm_request import \
148-
LlmResponse as PyLlmResponse
149-
150-
from .result import ResponseWrapper
151-
return isinstance(instance, (Response, PyLlmResponse, ResponseWrapper))

0 commit comments

Comments
 (0)