@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 390be74649
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 16, 10:45 UTC

[Misc] Print stack trace using `logger.exception` (#9461)

Cyrus Leung committed Oct 17, 2024 at 21:55 UTC 390be746494c625030c44749c8fbd04b899266af
8 files changed +26 -30
vllm/entrypoints/openai/serving_chat.py
+3 -3
@@ -324,7 +324,7 @@ class OpenAIServingChat(OpenAIServing):
324 else:
325 tool_parsers = [None] * num_choices
326 except RuntimeError as e:
327 - logger.error("Error in tool parser creation: %s", e)
327 + logger.exception("Error in tool parser creation.")
328 data = self.create_streaming_error_response(str(e))
329 yield f"data: {data}\n\n"
330 yield "data: [DONE]\n\n"
@@ -600,7 +600,7 @@ class OpenAIServingChat(OpenAIServing):
600
601 except ValueError as e:
602 # 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.")
604 data = self.create_streaming_error_response(str(e))
605 yield f"data: {data}\n\n"
606 # Send the final done message after all response.n are finished
@@ -687,7 +687,7 @@ class OpenAIServingChat(OpenAIServing):
687 try:
688 tool_parser = self.tool_parser(tokenizer)
689 except RuntimeError as e:
690 - logger.error("Error in tool parser creation: %s", e)
690 + logger.exception("Error in tool parser creation.")
691 return self.create_error_response(str(e))
692
693 tool_call_info = tool_parser.extract_tool_calls(
vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py
+5 -5
@@ -103,9 +103,9 @@ class Hermes2ProToolParser(ToolParser):
103 tool_calls=tool_calls,
104 content=content if content else None)
105
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.")
109 return ExtractedToolCallInformation(tools_called=False,
110 tool_calls=[],
111 content=model_output)
@@ -333,6 +333,6 @@ class Hermes2ProToolParser(ToolParser):
333
334 return delta
335
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.")
338 return None # do not stream a delta. skip this token ID.
vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py
+2 -2
@@ -166,8 +166,8 @@ class Internlm2ToolParser(ToolParser):
166 tool_call_arr["arguments"] = self.get_argments(tool_call_arr)
167 self.prev_tool_call_arr = [tool_call_arr]
168 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.")
171 logger.debug(
172 "Skipping chunk as a result of tool streaming extraction "
173 "error")
vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py
+4 -5
@@ -112,9 +112,8 @@ class Llama3JsonToolParser(ToolParser):
112 content=None)
113 return ret
114
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.")
117 # return information to just treat the tool call as regular JSON
118 return ExtractedToolCallInformation(tools_called=False,
119 tool_calls=[],
@@ -269,8 +268,8 @@ class Llama3JsonToolParser(ToolParser):
268 self.prev_tool_call_arr = tool_call_arr
269 return delta
270
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.")
273 logger.debug(
274 "Skipping chunk as a result of tool streaming extraction "
275 "error")
vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py
+4 -4
@@ -111,8 +111,8 @@ class MistralToolParser(ToolParser):
111 tool_calls=tool_calls,
112 content=content if len(content) > 0 else None)
113
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.")
116 # return information to just treat the tool call as regular JSON
117 return ExtractedToolCallInformation(tools_called=False,
118 tool_calls=[],
@@ -298,8 +298,8 @@ class MistralToolParser(ToolParser):
298 self.prev_tool_call_arr = tool_call_arr
299 return delta
300
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.")
303 logger.debug(
304 "Skipping chunk as a result of tool streaming extraction "
305 "error")
vllm/executor/multiproc_worker_utils.py
+3 -5
@@ -3,7 +3,6 @@ import multiprocessing
3 import os
4 import sys
5 import threading
6 -import traceback
6 import uuid
7 from dataclasses import dataclass
8 from multiprocessing import Queue
@@ -227,10 +226,9 @@ def _run_worker_process(
226 except KeyboardInterrupt:
227 break
228 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)
232 exception = e
233 result_queue.put(
234 Result(task_id=task_id, value=output, exception=exception))
vllm/model_executor/model_loader/weight_utils.py
+2 -2
@@ -499,8 +499,8 @@ def kv_cache_scales_loader(
499 logger.error("File or directory '%s' not found.", filename)
500 except json.JSONDecodeError:
501 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)
504 # This section is reached if and only if any of the excepts are hit
505 # Return an empty iterable (list) => no KV cache scales are loaded
506 # which ultimately defaults to 1.0 scales
vllm/platforms/cuda.py
+3 -4
@@ -137,10 +137,9 @@ class CudaPlatform(Platform):
137 pynvml.NVML_P2P_CAPS_INDEX_NVLINK)
138 if p2p_status != pynvml.NVML_P2P_STATUS_OK:
139 return False
140 - except pynvml.NVMLError as error:
141 - logger.error(
140 + except pynvml.NVMLError:
141 + logger.exception(
142 "NVLink detection failed. This is normal if your"
143 - " machine has no NVLink equipped.",
144 - exc_info=error)
143 + " machine has no NVLink equipped.")
144 return False
145 return True