Skip to content

Commit 390be74

Browse files
[Misc] Print stack trace using logger.exception (#9461)
1 parent e312e52 commit 390be74

File tree

8 files changed

+26
-30
lines changed

8 files changed

+26
-30
lines changed

vllm/entrypoints/openai/serving_chat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ async def chat_completion_stream_generator(
324324
else:
325325
tool_parsers = [None] * num_choices
326326
except RuntimeError as e:
327-
logger.error("Error in tool parser creation: %s", e)
327+
logger.exception("Error in tool parser creation.")
328328
data = self.create_streaming_error_response(str(e))
329329
yield f"data: {data}\n\n"
330330
yield "data: [DONE]\n\n"
@@ -600,7 +600,7 @@ async def chat_completion_stream_generator(
600600

601601
except ValueError as e:
602602
# TODO: Use a vllm-specific Validation Error
603-
logger.error("error in chat completion stream generator: %s", e)
603+
logger.exception("Error in chat completion stream generator.")
604604
data = self.create_streaming_error_response(str(e))
605605
yield f"data: {data}\n\n"
606606
# Send the final done message after all response.n are finished
@@ -687,7 +687,7 @@ async def chat_completion_full_generator(
687687
try:
688688
tool_parser = self.tool_parser(tokenizer)
689689
except RuntimeError as e:
690-
logger.error("Error in tool parser creation: %s", e)
690+
logger.exception("Error in tool parser creation.")
691691
return self.create_error_response(str(e))
692692

693693
tool_call_info = tool_parser.extract_tool_calls(

vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def extract_tool_calls(
103103
tool_calls=tool_calls,
104104
content=content if content else None)
105105

106-
except Exception as e:
107-
logger.error("Error in extracting tool call from response %s",
108-
e)
106+
except Exception:
107+
logger.exception(
108+
"Error in extracting tool call from response.")
109109
return ExtractedToolCallInformation(tools_called=False,
110110
tool_calls=[],
111111
content=model_output)
@@ -333,6 +333,6 @@ def extract_tool_calls_streaming(
333333

334334
return delta
335335

336-
except Exception as e:
337-
logger.error("Error trying to handle streaming tool call: %s", e)
336+
except Exception:
337+
logger.exception("Error trying to handle streaming tool call.")
338338
return None # do not stream a delta. skip this token ID.

vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def extract_tool_calls_streaming(
166166
tool_call_arr["arguments"] = self.get_argments(tool_call_arr)
167167
self.prev_tool_call_arr = [tool_call_arr]
168168
return delta
169-
except Exception as e:
170-
logger.error("Error trying to handle streaming tool call: %s", e)
169+
except Exception:
170+
logger.exception("Error trying to handle streaming tool call.")
171171
logger.debug(
172172
"Skipping chunk as a result of tool streaming extraction "
173173
"error")

vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ def extract_tool_calls(
112112
content=None)
113113
return ret
114114

115-
except Exception as e:
116-
logger.error("Error in extracting tool call from response: %s", e)
117-
print("ERROR", e)
115+
except Exception:
116+
logger.exception("Error in extracting tool call from response.")
118117
# return information to just treat the tool call as regular JSON
119118
return ExtractedToolCallInformation(tools_called=False,
120119
tool_calls=[],
@@ -269,8 +268,8 @@ def extract_tool_calls_streaming(
269268
self.prev_tool_call_arr = tool_call_arr
270269
return delta
271270

272-
except Exception as e:
273-
logger.error("Error trying to handle streaming tool call: %s", e)
271+
except Exception:
272+
logger.exception("Error trying to handle streaming tool call.")
274273
logger.debug(
275274
"Skipping chunk as a result of tool streaming extraction "
276275
"error")

vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def extract_tool_calls(
111111
tool_calls=tool_calls,
112112
content=content if len(content) > 0 else None)
113113

114-
except Exception as e:
115-
logger.error("Error in extracting tool call from response: %s", e)
114+
except Exception:
115+
logger.exception("Error in extracting tool call from response.")
116116
# return information to just treat the tool call as regular JSON
117117
return ExtractedToolCallInformation(tools_called=False,
118118
tool_calls=[],
@@ -298,8 +298,8 @@ def extract_tool_calls_streaming(
298298
self.prev_tool_call_arr = tool_call_arr
299299
return delta
300300

301-
except Exception as e:
302-
logger.error("Error trying to handle streaming tool call: %s", e)
301+
except Exception:
302+
logger.exception("Error trying to handle streaming tool call.")
303303
logger.debug(
304304
"Skipping chunk as a result of tool streaming extraction "
305305
"error")

vllm/executor/multiproc_worker_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import sys
55
import threading
6-
import traceback
76
import uuid
87
from dataclasses import dataclass
98
from multiprocessing import Queue
@@ -227,10 +226,9 @@ def _run_worker_process(
227226
except KeyboardInterrupt:
228227
break
229228
except BaseException as e:
230-
tb = traceback.format_exc()
231-
logger.error(
232-
"Exception in worker %s while processing method %s: %s, %s",
233-
process_name, method, e, tb)
229+
logger.exception(
230+
"Exception in worker %s while processing method %s.",
231+
process_name, method)
234232
exception = e
235233
result_queue.put(
236234
Result(task_id=task_id, value=output, exception=exception))

vllm/model_executor/model_loader/weight_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ def kv_cache_scales_loader(
499499
logger.error("File or directory '%s' not found.", filename)
500500
except json.JSONDecodeError:
501501
logger.error("Error decoding JSON in file '%s'.", filename)
502-
except Exception as e:
503-
logger.error("An error occurred while reading '%s': %s", filename, e)
502+
except Exception:
503+
logger.exception("An error occurred while reading '%s'.", filename)
504504
# This section is reached if and only if any of the excepts are hit
505505
# Return an empty iterable (list) => no KV cache scales are loaded
506506
# which ultimately defaults to 1.0 scales

vllm/platforms/cuda.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ def is_full_nvlink(cls, physical_device_ids: List[int]) -> bool:
137137
pynvml.NVML_P2P_CAPS_INDEX_NVLINK)
138138
if p2p_status != pynvml.NVML_P2P_STATUS_OK:
139139
return False
140-
except pynvml.NVMLError as error:
141-
logger.error(
140+
except pynvml.NVMLError:
141+
logger.exception(
142142
"NVLink detection failed. This is normal if your"
143-
" machine has no NVLink equipped.",
144-
exc_info=error)
143+
" machine has no NVLink equipped.")
145144
return False
146145
return True

0 commit comments

Comments
 (0)