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 17, 03:00 UTC
[Core][Logging] Add last frame information for better debugging (#4278)
youkaichao committed
Apr 23, 2024 at 09:45 UTC
d86285a4a4b79b883620d2878c0b52b22ad4c640
1 file changed
+16
-2
vllm/logger.py
+16
-2
@@ -83,13 +83,27 @@ def _trace_calls(log_path, root_dir, frame, event, arg=None):
83
return
84
# Log every function call or return
85
try:
86
+ last_frame = frame.f_back
87
+ if last_frame is not None:
88
+ last_filename = last_frame.f_code.co_filename
89
+ last_lineno = last_frame.f_lineno
90
+ last_func_name = last_frame.f_code.co_name
91
+ else:
92
+ # initial frame
93
+ last_filename = ""
94
+ last_lineno = 0
95
+ last_func_name = ""
96
with open(log_path, 'a') as f:
97
if event == 'call':
98
f.write(f"{datetime.datetime.now()} Call to"
89
- f" {func_name} in {filename}:{lineno}\n")
99
+ f" {func_name} in {filename}:{lineno}"
100
+ f" from {last_func_name} in {last_filename}:"
101
+ f"{last_lineno}\n")
102
else:
103
f.write(f"{datetime.datetime.now()} Return from"
92
- f" {func_name} in {filename}:{lineno}\n")
104
+ f" {func_name} in {filename}:{lineno}"
105
+ f" to {last_func_name} in {last_filename}:"
106
+ f"{last_lineno}\n")
107
except NameError:
108
# modules are deleted during shutdown
109
pass