Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
efffb63f
Unverified
Commit
efffb63f
authored
Apr 25, 2024
by
Nick Hill
Committed by
GitHub
Apr 25, 2024
Browse files
[Core] Move function tracing setup to util function (#4352)
parent
15e7c675
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
vllm/utils.py
vllm/utils.py
+20
-1
vllm/worker/worker_base.py
vllm/worker/worker_base.py
+4
-14
No files found.
vllm/utils.py
View file @
efffb63f
import
asyncio
import
asyncio
import
datetime
import
enum
import
enum
import
gc
import
gc
import
glob
import
glob
import
os
import
os
import
socket
import
socket
import
subprocess
import
subprocess
import
tempfile
import
threading
import
uuid
import
uuid
import
warnings
import
warnings
from
collections
import
defaultdict
from
collections
import
defaultdict
...
@@ -18,7 +21,7 @@ import psutil
...
@@ -18,7 +21,7 @@ import psutil
import
torch
import
torch
from
packaging.version
import
Version
,
parse
from
packaging.version
import
Version
,
parse
from
vllm.logger
import
init_logger
from
vllm.logger
import
enable_trace_function_call
,
init_logger
T
=
TypeVar
(
"T"
)
T
=
TypeVar
(
"T"
)
logger
=
init_logger
(
__name__
)
logger
=
init_logger
(
__name__
)
...
@@ -607,3 +610,19 @@ def find_nccl_library():
...
@@ -607,3 +610,19 @@ def find_nccl_library():
raise
ValueError
(
"NCCL only supports CUDA and ROCm backends."
)
raise
ValueError
(
"NCCL only supports CUDA and ROCm backends."
)
logger
.
info
(
f
"Found nccl from library
{
so_file
}
"
)
logger
.
info
(
f
"Found nccl from library
{
so_file
}
"
)
return
so_file
return
so_file
def
enable_trace_function_call_for_thread
()
->
None
:
"""Set up function tracing for the current thread,
if enabled via the VLLM_TRACE_FUNCTION environment variable
"""
if
int
(
os
.
getenv
(
"VLLM_TRACE_FUNCTION"
,
"0"
)):
tmp_dir
=
tempfile
.
gettempdir
()
filename
=
(
f
"VLLM_TRACE_FUNCTION_for_process_
{
os
.
getpid
()
}
"
f
"_thread_
{
threading
.
get_ident
()
}
_"
f
"at_
{
datetime
.
datetime
.
now
()
}
.log"
).
replace
(
" "
,
"_"
)
log_path
=
os
.
path
.
join
(
tmp_dir
,
"vllm"
,
get_vllm_instance_id
(),
filename
)
os
.
makedirs
(
os
.
path
.
dirname
(
log_path
),
exist_ok
=
True
)
enable_trace_function_call
(
log_path
)
vllm/worker/worker_base.py
View file @
efffb63f
import
datetime
import
importlib
import
importlib
import
os
import
os
import
tempfile
import
threading
from
abc
import
ABC
,
abstractmethod
from
abc
import
ABC
,
abstractmethod
from
typing
import
Dict
,
List
,
Set
,
Tuple
from
typing
import
Dict
,
List
,
Set
,
Tuple
from
vllm.logger
import
enable_trace_function_call
,
init_logger
from
vllm.logger
import
init_logger
from
vllm.lora.request
import
LoRARequest
from
vllm.lora.request
import
LoRARequest
from
vllm.sequence
import
SamplerOutput
,
SequenceGroupMetadata
from
vllm.sequence
import
SamplerOutput
,
SequenceGroupMetadata
from
vllm.utils
import
get_vllm_instance_id
,
update_environment_variables
from
vllm.utils
import
(
enable_trace_function_call_for_thread
,
update_environment_variables
)
logger
=
init_logger
(
__name__
)
logger
=
init_logger
(
__name__
)
...
@@ -128,15 +126,7 @@ class WorkerWrapperBase:
...
@@ -128,15 +126,7 @@ class WorkerWrapperBase:
function tracing if required.
function tracing if required.
Arguments are passed to the worker class constructor.
Arguments are passed to the worker class constructor.
"""
"""
if
int
(
os
.
getenv
(
"VLLM_TRACE_FUNCTION"
,
"0"
)):
enable_trace_function_call_for_thread
()
tmp_dir
=
tempfile
.
gettempdir
()
filename
=
(
f
"VLLM_TRACE_FUNCTION_for_process_
{
os
.
getpid
()
}
"
f
"_thread_
{
threading
.
get_ident
()
}
_"
f
"at_
{
datetime
.
datetime
.
now
()
}
.log"
).
replace
(
" "
,
"_"
)
log_path
=
os
.
path
.
join
(
tmp_dir
,
"vllm"
,
get_vllm_instance_id
(),
filename
)
os
.
makedirs
(
os
.
path
.
dirname
(
log_path
),
exist_ok
=
True
)
enable_trace_function_call
(
log_path
)
mod
=
importlib
.
import_module
(
self
.
worker_module_name
)
mod
=
importlib
.
import_module
(
self
.
worker_module_name
)
worker_class
=
getattr
(
mod
,
self
.
worker_class_name
)
worker_class
=
getattr
(
mod
,
self
.
worker_class_name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment