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
3755c145
Unverified
Commit
3755c145
authored
Nov 06, 2025
by
Aditya Tewari
Committed by
GitHub
Nov 06, 2025
Browse files
[CPU] Enable torch profiling (#28130)
Signed-off-by:
Aditya Tewari
<
aditya.tewari@arm.com
>
parent
201dc98a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
vllm/v1/worker/cpu_worker.py
vllm/v1/worker/cpu_worker.py
+36
-0
No files found.
vllm/v1/worker/cpu_worker.py
View file @
3755c145
...
...
@@ -37,6 +37,28 @@ class CPUWorker(Worker):
self
.
parallel_config
.
disable_custom_all_reduce
=
True
if
envs
.
VLLM_TORCH_PROFILER_DIR
:
torch_profiler_trace_dir
=
envs
.
VLLM_TORCH_PROFILER_DIR
worker_name
=
f
"
{
vllm_config
.
instance_id
}
-rank-
{
self
.
rank
}
"
logger
.
info
(
"Profiling enabled. Traces will be saved to: %s"
,
torch_profiler_trace_dir
,
)
self
.
profiler
=
torch
.
profiler
.
profile
(
activities
=
[
torch
.
profiler
.
ProfilerActivity
.
CPU
,
],
record_shapes
=
envs
.
VLLM_TORCH_PROFILER_RECORD_SHAPES
,
profile_memory
=
envs
.
VLLM_TORCH_PROFILER_WITH_PROFILE_MEMORY
,
with_stack
=
envs
.
VLLM_TORCH_PROFILER_WITH_STACK
,
with_flops
=
envs
.
VLLM_TORCH_PROFILER_WITH_FLOPS
,
on_trace_ready
=
torch
.
profiler
.
tensorboard_trace_handler
(
torch_profiler_trace_dir
,
worker_name
=
worker_name
,
use_gzip
=
False
),
)
else
:
self
.
profiler
=
None
def
init_device
(
self
):
# Setup OpenMP threads affinity.
omp_cpuids
=
envs
.
VLLM_CPU_OMP_THREADS_BIND
...
...
@@ -166,3 +188,17 @@ class CPUWorker(Worker):
[(
x
.
id
,
x
.
physical_core
)
for
x
in
logical_cpu_list
],
)
return
","
.
join
([
str
(
x
.
id
)
for
x
in
logical_cpu_list
])
def
profile
(
self
,
is_start
:
bool
=
True
):
if
self
.
profiler
is
None
:
raise
RuntimeError
(
"Profiler is not enabled."
)
if
is_start
:
self
.
profiler
.
start
()
else
:
self
.
profiler
.
stop
()
if
self
.
local_rank
==
0
:
logger
.
info
(
self
.
profiler
.
key_averages
().
table
(
sort_by
=
"self_cpu_time_total"
,
row_limit
=
50
)
)
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