Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
8c04f0f2
Unverified
Commit
8c04f0f2
authored
Mar 28, 2025
by
fzyzcjy
Committed by
GitHub
Mar 27, 2025
Browse files
Support with_stack and record_shapes in profiler (#4740)
Co-authored-by:
Lianmin Zheng
<
lianminzheng@gmail.com
>
parent
265e7564
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
python/sglang/srt/managers/io_struct.py
python/sglang/srt/managers/io_struct.py
+2
-0
python/sglang/srt/managers/scheduler.py
python/sglang/srt/managers/scheduler.py
+9
-2
No files found.
python/sglang/srt/managers/io_struct.py
View file @
8c04f0f2
...
@@ -675,6 +675,8 @@ class ProfileReq:
...
@@ -675,6 +675,8 @@ class ProfileReq:
output_dir
:
Optional
[
str
]
=
None
output_dir
:
Optional
[
str
]
=
None
num_steps
:
Optional
[
int
]
=
None
num_steps
:
Optional
[
int
]
=
None
activities
:
Optional
[
List
[
str
]]
=
None
activities
:
Optional
[
List
[
str
]]
=
None
with_stack
:
Optional
[
bool
]
=
None
record_shapes
:
Optional
[
bool
]
=
None
@
dataclass
@
dataclass
...
...
python/sglang/srt/managers/scheduler.py
View file @
8c04f0f2
...
@@ -1807,7 +1807,11 @@ class Scheduler(
...
@@ -1807,7 +1807,11 @@ class Scheduler(
def
profile
(
self
,
recv_req
:
ProfileReq
):
def
profile
(
self
,
recv_req
:
ProfileReq
):
if
recv_req
.
type
==
ProfileReqType
.
START_PROFILE
:
if
recv_req
.
type
==
ProfileReqType
.
START_PROFILE
:
return
self
.
start_profile
(
return
self
.
start_profile
(
recv_req
.
output_dir
,
recv_req
.
num_steps
,
recv_req
.
activities
recv_req
.
output_dir
,
recv_req
.
num_steps
,
recv_req
.
activities
,
recv_req
.
with_stack
,
recv_req
.
record_shapes
,
)
)
else
:
else
:
return
self
.
stop_profile
()
return
self
.
stop_profile
()
...
@@ -1817,6 +1821,8 @@ class Scheduler(
...
@@ -1817,6 +1821,8 @@ class Scheduler(
output_dir
:
Optional
[
str
],
output_dir
:
Optional
[
str
],
num_steps
:
Optional
[
int
],
num_steps
:
Optional
[
int
],
activities
:
Optional
[
List
[
str
]],
activities
:
Optional
[
List
[
str
]],
with_stack
:
Optional
[
bool
],
record_shapes
:
Optional
[
bool
],
)
->
None
:
)
->
None
:
if
self
.
profiler_activities
:
if
self
.
profiler_activities
:
return
ProfileReqOutput
(
return
ProfileReqOutput
(
...
@@ -1847,7 +1853,8 @@ class Scheduler(
...
@@ -1847,7 +1853,8 @@ class Scheduler(
if
torchprof_activities
:
if
torchprof_activities
:
self
.
torch_profiler
=
torch
.
profiler
.
profile
(
self
.
torch_profiler
=
torch
.
profiler
.
profile
(
activities
=
torchprof_activities
,
activities
=
torchprof_activities
,
with_stack
=
True
,
with_stack
=
with_stack
if
with_stack
is
not
None
else
True
,
record_shapes
=
record_shapes
if
record_shapes
is
not
None
else
False
,
)
)
self
.
torch_profiler
.
start
()
self
.
torch_profiler
.
start
()
...
...
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