Skip to content

Commit fd0e36e

Browse files
ShunkangShunkang
authored andcommitted
Refactor
Signed-off-by: Shunkang <[email protected]>
1 parent 727582f commit fd0e36e

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

cpp/include/tensorrt_llm/common/tllmException.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#define NEW_TLLM_EXCEPTION(...) \
3838
tensorrt_llm::common::TllmException(__FILE__, __LINE__, tensorrt_llm::common::fmtstr(__VA_ARGS__).c_str())
3939

40-
#define NEW_TLLM_REQUEST_SPECIFIC_EXCEPTION_WITH_ERROR_CODE(requestID, errorCode, ...) \
40+
#define TLLM_REQUEST_EXCEPTION(requestID, errorCode, ...) \
4141
tensorrt_llm::common::RequestSpecificException( \
4242
__FILE__, __LINE__, tensorrt_llm::common::fmtstr(__VA_ARGS__).c_str(), requestID, errorCode)
4343

@@ -84,6 +84,7 @@ class TllmException : public std::runtime_error
8484
{
8585
throw TllmException(file, line, fmtstr("[TensorRT-LLM][ERROR] Assertion failed: %s", info.c_str()).c_str());
8686
}
87+
8788
class RequestSpecificException : public std::runtime_error
8889
{
8990
public:

cpp/tensorrt_llm/batch_manager/dataTransceiver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ class DataResponder::Impl
194194
catch (tensorrt_llm::common::RequestSpecificException const& e)
195195
{
196196
TLLM_LOG_ERROR("Exception in sendAndRemoveResponse: %s ", e.what());
197-
auto new_exception
198-
= NEW_TLLM_REQUEST_SPECIFIC_EXCEPTION_WITH_ERROR_CODE(id, e.getErrorCode(), "%s", e.what());
197+
auto new_exception = TLLM_REQUEST_EXCEPTION(id, e.getErrorCode(), "%s", e.what());
199198
resp.mPromise.set_exception(std::make_exception_ptr(new_exception));
200199
}
201200
catch (std::exception const& e)
@@ -506,10 +505,10 @@ class DataRequester::Impl
506505
}
507506
catch (tensorrt_llm::common::RequestSpecificException const& err)
508507
{
509-
TLLM_LOG_ERROR("Exception in DataRequester request(): request id:%ld , request context id:%ld : %s",
508+
TLLM_LOG_ERROR("Exception in DataRequester request(): request id:%zu , request context id:%zu : %s",
510509
requestAndPromise.mRequest->mRequestId,
511510
requestAndPromise.mRequest->getContextPhaseParams().value().getReqId(), err.what());
512-
auto new_exception = NEW_TLLM_REQUEST_SPECIFIC_EXCEPTION_WITH_ERROR_CODE(
511+
auto new_exception = TLLM_REQUEST_EXCEPTION(
513512
requestAndPromise.mRequest->mRequestId, err.getErrorCode(), "%s", err.what());
514513
requestAndPromise.mPromise->set_exception(std::make_exception_ptr(new_exception));
515514
}

cpp/tensorrt_llm/common/tllmException.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "tensorrt_llm/common/tllmException.h"
1818
#include "tensorrt_llm/common/stringUtils.h"
1919

20+
#include <cinttypes>
2021
#include <cstdlib>
2122
#if !defined(_MSC_VER)
2223
#include <cxxabi.h>
@@ -108,7 +109,7 @@ std::string TllmException::demangle(char const* name)
108109

109110
RequestSpecificException::RequestSpecificException(
110111
std::string const& file, std::size_t line, char const* msg, uint64_t requestID, RequestErrorCode errorCode)
111-
: std::runtime_error{fmtstr("%s (Request ID: %lu, Error Code: %u) (%s:%zu)", msg, requestID,
112+
: std::runtime_error{fmtstr("%s (Request ID: %" PRIu64 ", Error Code: %u) (%s:%zu)", msg, requestID,
112113
static_cast<uint32_t>(errorCode), file.c_str(), line)}
113114
, mRequestID{requestID}
114115
, mErrorCode{errorCode}

tensorrt_llm/_torch/pyexecutor/py_executor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import traceback
99
import weakref
1010
from contextlib import contextmanager
11-
from typing import Dict, Iterable, List, Optional, Tuple, Union
11+
from typing import Iterable, List, Optional, Tuple, Union
1212

1313
import torch
1414

@@ -1552,8 +1552,10 @@ def _handle_errors(self,
15521552
client_id=request.py_client_id)
15531553

15541554
if request_ids is not None:
1555-
for req_id in request_ids:
1556-
self.active_requests.remove(req_id)
1555+
req_id_set = set(request_ids)
1556+
for request in self.active_requests:
1557+
if request.py_request_id in req_id_set:
1558+
self.active_requests.remove(request)
15571559
else:
15581560
self.active_requests.clear()
15591561
self._enqueue_responses(error_responses)

0 commit comments

Comments
 (0)