Skip to content

Commit 828d0d0

Browse files
[profiler] add record_shapes env flag SGLANG_PROFILE_RECORD_SHAPES
for profiler Signed-off-by: zejunchen-zejun <zejun.chen@amd.com>
1 parent 764d07e commit 828d0d0

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

docs/references/environment_variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ SGLang supports various environment variables that can be used to configure its
9494
| --- | --- | --- |
9595
| `SGLANG_TORCH_PROFILER_DIR` | Directory for PyTorch profiler output | `/tmp` |
9696
| `SGLANG_PROFILE_WITH_STACK` | Set `with_stack` option (bool) for PyTorch profiler (capture stack trace) | `true` |
97+
| `SGLANG_PROFILE_RECORD_SHAPES` | Set `record_shapes` option (bool) for PyTorch profiler (capture shapes) | `true` |
9798

9899
## Storage & Caching
99100

evaluation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
```
109109
export SGLANG_TORCH_PROFILER_DIR=./
110110
export SGLANG_PROFILE_WITH_STACK=1
111+
export SGLANG_PROFILE_RECORD_SHAPES=1
111112
<launch the server>
112113
<launch the client with the additional --profile argument>
113114
```

python/sglang/srt/environ.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class Envs:
117117
SGLANG_TEST_RETRACT = EnvBool(False)
118118
SGLANG_SET_CPU_AFFINITY = EnvBool(False)
119119
SGLANG_PROFILE_WITH_STACK = EnvBool(True)
120+
SGLANG_PROFILE_RECORD_SHAPES = EnvBool(True)
120121
SGLANG_RECORD_STEP_TIME = EnvBool(False)
121122
SGLANG_GC_LOG = EnvBool(False)
122123
SGLANG_FORCE_SHUTDOWN = EnvBool(False)

python/sglang/srt/managers/tokenizer_communicator_mixin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ async def start_profile(
310310
self.auto_create_handle_loop()
311311
env_with_stack: bool = get_bool_env_var("SGLANG_PROFILE_WITH_STACK", "true")
312312
with_stack = False if with_stack is False or env_with_stack is False else True
313+
env_record_shapes: bool = get_bool_env_var("SGLANG_PROFILE_RECORD_SHAPES", "true")
314+
record_shapes = False if record_shapes is False or env_record_shapes is False else True
313315
req = ProfileReq(
314316
type=ProfileReqType.START_PROFILE,
315317
output_dir=output_dir,

0 commit comments

Comments
 (0)