serveutil 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. serveutil-0.1.0/LICENSE +201 -0
  2. serveutil-0.1.0/MANIFEST.in +5 -0
  3. serveutil-0.1.0/NOTICE +10 -0
  4. serveutil-0.1.0/PKG-INFO +44 -0
  5. serveutil-0.1.0/README.md +86 -0
  6. serveutil-0.1.0/README.zh-CN.md +85 -0
  7. serveutil-0.1.0/assets/engines.svg +1 -0
  8. serveutil-0.1.0/assets/h20-decode.png +0 -0
  9. serveutil-0.1.0/assets/icon.png +0 -0
  10. serveutil-0.1.0/assets/mark.png +0 -0
  11. serveutil-0.1.0/assets/trace-preview.png +0 -0
  12. serveutil-0.1.0/assets/wordmark.png +0 -0
  13. serveutil-0.1.0/docs/capture.md +67 -0
  14. serveutil-0.1.0/docs/downloads.md +30 -0
  15. serveutil-0.1.0/docs/en/capture.md +45 -0
  16. serveutil-0.1.0/docs/en/downloads.md +30 -0
  17. serveutil-0.1.0/docs/en/metrics.md +27 -0
  18. serveutil-0.1.0/docs/en/recipes/bandwidth.md +15 -0
  19. serveutil-0.1.0/docs/en/recipes/decode.md +15 -0
  20. serveutil-0.1.0/docs/en/recipes/pd.md +15 -0
  21. serveutil-0.1.0/docs/en/start.md +39 -0
  22. serveutil-0.1.0/docs/en/tools.md +13 -0
  23. serveutil-0.1.0/docs/en/torch-profiler.md +53 -0
  24. serveutil-0.1.0/docs/en/validation.md +48 -0
  25. serveutil-0.1.0/docs/en/viewer.md +29 -0
  26. serveutil-0.1.0/docs/metrics.md +38 -0
  27. serveutil-0.1.0/docs/recipes/bandwidth.md +15 -0
  28. serveutil-0.1.0/docs/recipes/decode.md +15 -0
  29. serveutil-0.1.0/docs/recipes/pd.md +15 -0
  30. serveutil-0.1.0/docs/start.md +39 -0
  31. serveutil-0.1.0/docs/tools.md +13 -0
  32. serveutil-0.1.0/docs/torch-profiler.md +91 -0
  33. serveutil-0.1.0/docs/validation.md +86 -0
  34. serveutil-0.1.0/docs/viewer.md +31 -0
  35. serveutil-0.1.0/examples/decode.perfetto.json +55 -0
  36. serveutil-0.1.0/examples/decode.synthetic.json +584 -0
  37. serveutil-0.1.0/examples/distributed-topology.json +18 -0
  38. serveutil-0.1.0/examples/h20-allreduce.html +4066 -0
  39. serveutil-0.1.0/examples/h20-decode.html +4066 -0
  40. serveutil-0.1.0/examples/index.html +4066 -0
  41. serveutil-0.1.0/examples/link.json +19 -0
  42. serveutil-0.1.0/examples/native-example.html +4066 -0
  43. serveutil-0.1.0/examples/pd-topology.json +21 -0
  44. serveutil-0.1.0/examples/rdma-link.json +31 -0
  45. serveutil-0.1.0/examples/sglang-erdma.report.json +1 -0
  46. serveutil-0.1.0/examples/sglang-pd.report.json +1 -0
  47. serveutil-0.1.0/packaging/PYPI.md +19 -0
  48. serveutil-0.1.0/packaging/vendor_perfetto.py +69 -0
  49. serveutil-0.1.0/pyproject.toml +37 -0
  50. serveutil-0.1.0/serveutil/__init__.py +13 -0
  51. serveutil-0.1.0/serveutil/__main__.py +4 -0
  52. serveutil-0.1.0/serveutil/analysis.py +233 -0
  53. serveutil-0.1.0/serveutil/bundle.py +74 -0
  54. serveutil-0.1.0/serveutil/calibration.py +490 -0
  55. serveutil-0.1.0/serveutil/cli.py +208 -0
  56. serveutil-0.1.0/serveutil/collectives.py +337 -0
  57. serveutil-0.1.0/serveutil/desktop.py +104 -0
  58. serveutil-0.1.0/serveutil/engines.py +385 -0
  59. serveutil-0.1.0/serveutil/integrations.py +115 -0
  60. serveutil-0.1.0/serveutil/link.py +258 -0
  61. serveutil-0.1.0/serveutil/native_view.py +80 -0
  62. serveutil-0.1.0/serveutil/originals.py +86 -0
  63. serveutil-0.1.0/serveutil/overview.py +176 -0
  64. serveutil-0.1.0/serveutil/perfetto.py +188 -0
  65. serveutil-0.1.0/serveutil/pm.py +242 -0
  66. serveutil-0.1.0/serveutil/raw_trace.py +339 -0
  67. serveutil-0.1.0/serveutil/rdma.py +139 -0
  68. serveutil-0.1.0/serveutil/recording.py +529 -0
  69. serveutil-0.1.0/serveutil/reference.py +292 -0
  70. serveutil-0.1.0/serveutil/relationships.py +74 -0
  71. serveutil-0.1.0/serveutil/report.py +798 -0
  72. serveutil-0.1.0/serveutil/telemetry.py +563 -0
  73. serveutil-0.1.0/serveutil/transfers.py +397 -0
  74. serveutil-0.1.0/serveutil/ui/app.js +1843 -0
  75. serveutil-0.1.0/serveutil/ui/icon.png +0 -0
  76. serveutil-0.1.0/serveutil/ui/import-worker.js +1391 -0
  77. serveutil-0.1.0/serveutil/ui/index.html +16 -0
  78. serveutil-0.1.0/serveutil/ui/language.js +110 -0
  79. serveutil-0.1.0/serveutil/ui/raw.js +324 -0
  80. serveutil-0.1.0/serveutil/ui/streamparser-LICENSE.txt +21 -0
  81. serveutil-0.1.0/serveutil/ui/style.css +360 -0
  82. serveutil-0.1.0/serveutil/vendor/Perfetto-LICENSE.txt +285 -0
  83. serveutil-0.1.0/serveutil/vendor/perfetto-ui.zip +0 -0
  84. serveutil-0.1.0/serveutil/worker.py +135 -0
  85. serveutil-0.1.0/serveutil/workload.py +125 -0
  86. serveutil-0.1.0/serveutil.egg-info/PKG-INFO +44 -0
  87. serveutil-0.1.0/serveutil.egg-info/SOURCES.txt +103 -0
  88. serveutil-0.1.0/serveutil.egg-info/dependency_links.txt +1 -0
  89. serveutil-0.1.0/serveutil.egg-info/entry_points.txt +5 -0
  90. serveutil-0.1.0/serveutil.egg-info/requires.txt +19 -0
  91. serveutil-0.1.0/serveutil.egg-info/top_level.txt +1 -0
  92. serveutil-0.1.0/setup.cfg +4 -0
  93. serveutil-0.1.0/tests/test_capture.py +216 -0
  94. serveutil-0.1.0/tests/test_collectives.py +311 -0
  95. serveutil-0.1.0/tests/test_copy.py +70 -0
  96. serveutil-0.1.0/tests/test_engine_lifecycle.py +158 -0
  97. serveutil-0.1.0/tests/test_link.py +92 -0
  98. serveutil-0.1.0/tests/test_measurement.py +133 -0
  99. serveutil-0.1.0/tests/test_native_profiler.py +368 -0
  100. serveutil-0.1.0/tests/test_overview.py +58 -0
  101. serveutil-0.1.0/tests/test_perfetto_assets.py +33 -0
  102. serveutil-0.1.0/tests/test_portable.py +111 -0
  103. serveutil-0.1.0/tests/test_raw_trace.py +253 -0
  104. serveutil-0.1.0/tests/test_relationships.py +115 -0
  105. serveutil-0.1.0/tests/test_transfers.py +196 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include README.md README.zh-CN.md
2
+ include packaging/PYPI.md packaging/vendor_perfetto.py
3
+ recursive-include assets *.png *.svg
4
+ recursive-include docs *.md
5
+ recursive-include examples *.html *.json
serveutil-0.1.0/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ ServeUtil
2
+ Copyright 2026 ServeUtil contributors
3
+
4
+ The browser trace importer includes @streamparser/json, copyright Juanjo Diaz,
5
+ under the MIT License. See serveutil/ui/streamparser-LICENSE.txt.
6
+
7
+ The full trace workspace redistributes the unmodified Perfetto UI build
8
+ v59.1-491832c0d from https://ui.perfetto.dev/, including its Trace Processor
9
+ WebAssembly engines. The upstream distribution and license terms are in
10
+ serveutil/vendor/. packaging/vendor_perfetto.py verifies the upstream assets.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: serveutil
3
+ Version: 0.1.0
4
+ Summary: Readable compute and bandwidth timelines for LLM serving
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Documentation, https://haoyangping0324.github.io/ServeUtil/
7
+ Project-URL: Source, https://github.com/HaoyangPing0324/ServeUtil
8
+ Project-URL: Issues, https://github.com/HaoyangPing0324/ServeUtil/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Requires-Dist: ijson<4,>=3.2
14
+ Requires-Dist: prometheus-client<1,>=0.17
15
+ Requires-Dist: nvidia-ml-py>=12.550.52
16
+ Provides-Extra: gpu
17
+ Provides-Extra: desktop
18
+ Requires-Dist: pywebview<7,>=6; extra == "desktop"
19
+ Requires-Dist: pywebview[qt]<7,>=6; sys_platform == "linux" and extra == "desktop"
20
+ Provides-Extra: llmperfscope
21
+ Requires-Dist: llmperfscope<1,>=0.2; extra == "llmperfscope"
22
+ Provides-Extra: pm
23
+ Requires-Dist: cupti-python<14,>=13.4; sys_platform == "linux" and extra == "pm"
24
+ Dynamic: license-file
25
+
26
+ # ServeUtil
27
+
28
+ Profile PyTorch, vLLM and SGLang inference with GPU and network counters. Inspect Prefill and Decode by rank, select an interval for directional bandwidth and compare it with a measured hardware reference.
29
+
30
+ ```bash
31
+ pip install serveutil
32
+ serveutil view rank0.pt.trace.json.gz
33
+ ```
34
+
35
+ Create a shareable report with `serveutil report TRACE -o report.html`. Model capture uses the PyTorch installation in your serving environment. With a running vLLM server configured to write profiler traces to a shared directory:
36
+
37
+ ```bash
38
+ serveutil capture --engine vllm --url http://localhost:8000 \
39
+ --trace-dir /profiles --seconds 5 --generate "Explain prefill and decode."
40
+ ```
41
+
42
+ Use `--engine sglang` and the SGLang service URL for SGLang. Add `--calibrate` on idle test devices to measure a local reference. For independent HBM read/write sampling on compatible Linux devices install `serveutil[pm]`.
43
+
44
+ [Documentation](https://haoyangping0324.github.io/ServeUtil/) · [简体中文](https://haoyangping0324.github.io/ServeUtil/zh/) · [Desktop downloads](https://haoyangping0324.github.io/ServeUtil/downloads.html)
@@ -0,0 +1,86 @@
1
+ <p align="center"><img src="assets/wordmark.png" width="360" alt="ServeUtil"></p>
2
+ <h1 align="center">Compute and bandwidth profiling for LLM inference</h1>
3
+ <p align="center"><strong><a href="https://haoyangping0324.github.io/ServeUtil/">Documentation</a> &nbsp;|&nbsp; <a href="https://haoyangping0324.github.io/ServeUtil/viewer.html">Trace viewer</a> &nbsp;|&nbsp; <a href="https://haoyangping0324.github.io/ServeUtil/downloads.html">Downloads</a> &nbsp;|&nbsp; <a href="README.zh-CN.md">简体中文</a></strong></p>
4
+ <p align="center">
5
+ <a href="https://github.com/HaoyangPing0324/ServeUtil/actions/workflows/desktop.yml"><img alt="Desktop and web CI" src="https://github.com/HaoyangPing0324/ServeUtil/actions/workflows/desktop.yml/badge.svg"></a>
6
+ <a href="#installation"><img alt="Python 3.10+" src="https://img.shields.io/badge/Python-3.10%2B-3776AB"></a>
7
+ <a href="LICENSE"><img alt="Apache 2.0" src="https://img.shields.io/badge/license-Apache--2.0-337b57"></a>
8
+ <a href="https://haoyangping0324.github.io/ServeUtil/capture.html"><img alt="PyTorch · vLLM · SGLang" src="assets/engines.svg"></a>
9
+ </p>
10
+
11
+ ServeUtil combines PyTorch, vLLM and SGLang traces with GPU and network counters. Select a Decode interval to see which ranks were computing, which were waiting on communication and how the measured bandwidth compares with a reference from the same hardware.
12
+
13
+ <img src="assets/h20-decode.png" width="100%" alt="Qwen3 Decode on H20 with GPU gaps, HBM read and write rates, Tensor activity and BF16 GEMM throughput">
14
+
15
+ ## What ServeUtil adds
16
+
17
+ | Starting point | What you can inspect |
18
+ |---|---|
19
+ | PyTorch operators, kernels and copies | Device-level HBM reads and writes, PCIe and NVLink traffic, network and RDMA port throughput, and SM and Tensor pipeline activity where supported. The original trace is preserved. |
20
+ | An absolute rate such as 58 MB/s | Compare with a microbenchmark on the same device, port and direction. Dense GEMMs with recorded shapes and one correlated kernel can also show effective TFLOP/s. |
21
+ | A deeply nested, multi-rank timeline | Start with Prefill and Decode. Focus on a node, rank, operator depth or leaf. Follow matched Send/Recv operations or inspect KV handoffs between Prefill and Decode. Open Full Perfetto for original events, flows and SQL. |
22
+ | A slow interval | Jump to repeated GPU gaps, communication without overlapping compute, sustained bandwidth pressure or comparable steps with different rank durations. Each marker gives its evidence. |
23
+
24
+ On two H20 hosts, the sending port averaged 58.5 MB/s over a 3.05-second SGLang TP2 window, about 0.51% of its directional eRDMA reference. Of 4,469 complete AllReduce operations, 3,956 carried only 2 KiB. The message sizes and time between operations help explain the low window average. [Hardware validation and model results](docs/en/validation.md)
25
+
26
+ ## Installation
27
+
28
+ Install ServeUtil from PyPI with Python 3.10 or later.
29
+
30
+ ```bash
31
+ pip install serveutil
32
+ serveutil --help
33
+ ```
34
+
35
+ The base package includes the CLI, the offline-capable web viewer and NVIDIA NVML bindings. Viewing existing traces works on a CPU-only computer. Model capture uses the PyTorch installation in your inference environment. For independent directional HBM sampling on compatible Linux systems, install `pip install "serveutil[pm]"` and enable GPU counter access. For the desktop window, install `pip install "serveutil[desktop]"` or download a platform build. [Install and download](https://haoyangping0324.github.io/ServeUtil/downloads.html)
36
+
37
+ ## Open a trace
38
+
39
+ ```bash
40
+ serveutil view rank0.pt.trace.json.gz
41
+ serveutil report rank0.pt.trace.json.gz -o report.html
42
+ ```
43
+
44
+ The first command opens the viewer. The second creates a shareable HTML report. Import a capture folder to recover rank metadata, hardware samples and clock calibration. [Viewer guide](docs/en/viewer.md)
45
+
46
+ ## Profile your own PyTorch code
47
+
48
+ ```python
49
+ import torch
50
+ import serveutil
51
+
52
+ device = "cuda" if torch.cuda.is_available() else "cpu"
53
+ projection = torch.nn.Linear(256, 256, bias=False).to(device).eval()
54
+ x = torch.ones(32, 256, device=device)
55
+
56
+ with torch.inference_mode(), serveutil.profile("runs", record_shapes=True) as prof:
57
+ with torch.profiler.record_function("Projection"):
58
+ projection(x)
59
+ prof.step()
60
+
61
+ print(prof.serveutil_directory / "report.html")
62
+ ```
63
+
64
+ The returned object is a native PyTorch profiler. The first CUDA run calibrates the selected device by default and later runs reuse the cache. Integrations using an existing schedule, TensorBoard callback or asynchronous writer can use `instrument` or `observe`. [PyTorch integration](docs/en/torch-profiler.md)
65
+
66
+ ## Capture a running service
67
+
68
+ Enable the framework's PyTorch profiler when starting the service. For vLLM add `--profiler-config '{"profiler":"torch","torch_profiler_dir":"/profiles"}'`. For SGLang set `SGLANG_TORCH_PROFILER_DIR=/profiles`. The collector needs access to the worker's trace directory. Run the command for your engine:
69
+
70
+ ```bash
71
+ serveutil capture --engine vllm --url http://localhost:8000 \
72
+ --trace-dir /profiles --seconds 5 --generate "Explain prefill and decode."
73
+
74
+ serveutil capture --engine sglang --url http://localhost:30000 \
75
+ --trace-dir /profiles --seconds 5 --generate "Explain prefill and decode."
76
+ ```
77
+
78
+ ServeUtil warms up the service, generates requests, starts and stops profiling in its workers, samples hardware and prints the report path. Omit `--generate` to capture existing traffic. Add `--calibrate` on idle test devices or pass an existing reference with `--calibration calibration.json`. Use a topology file for multi-node and disaggregated serving. [Deployment guide](docs/en/capture.md) · [Multi-node topology](examples/distributed-topology.json) · [PD topology](examples/pd-topology.json)
79
+
80
+ ## Guides and examples
81
+
82
+ - Explore two measured reports. [Qwen3 Decode](https://haoyangping0324.github.io/ServeUtil/h20-decode.html) · [SGLang AllReduce](https://haoyangping0324.github.io/ServeUtil/h20-allreduce.html)
83
+ - Check each metric's units, denominator and scope. [Metrics](docs/en/metrics.md)
84
+ - Reuse nccl-tests, nvbandwidth, perftest, HTA, TraceLens or llmperfscope. [Tools and integrations](docs/en/tools.md)
85
+
86
+ ServeUtil is licensed under Apache 2.0. Bundled dependencies retain their upstream notices. [License](LICENSE) · [Third-party notices](NOTICE)
@@ -0,0 +1,85 @@
1
+ <p align="center"><img src="assets/wordmark.png" width="360" alt="ServeUtil"></p>
2
+ <h1 align="center">面向大模型推理的计算与带宽分析</h1>
3
+ <p align="center"><strong><a href="https://haoyangping0324.github.io/ServeUtil/zh/">项目文档</a> &nbsp;|&nbsp; <a href="https://haoyangping0324.github.io/ServeUtil/viewer.html?lang=zh">网页版查看器</a> &nbsp;|&nbsp; <a href="https://haoyangping0324.github.io/ServeUtil/zh/downloads.html">客户端下载</a> &nbsp;|&nbsp; <a href="README.md">English</a></strong></p>
4
+ <p align="center">
5
+ <a href="https://github.com/HaoyangPing0324/ServeUtil/actions/workflows/desktop.yml"><img alt="Desktop and web CI" src="https://github.com/HaoyangPing0324/ServeUtil/actions/workflows/desktop.yml/badge.svg"></a>
6
+ <a href="#安装"><img alt="Python 3.10+" src="https://img.shields.io/badge/Python-3.10%2B-3776AB"></a>
7
+ <a href="LICENSE"><img alt="Apache 2.0" src="https://img.shields.io/badge/license-Apache--2.0-337b57"></a>
8
+ <a href="https://haoyangping0324.github.io/ServeUtil/zh/capture.html"><img alt="PyTorch · vLLM · SGLang" src="assets/engines.svg"></a>
9
+ </p>
10
+
11
+ ServeUtil 面向 PyTorch、vLLM 和 SGLang。打开一次 Decode,先看各个 rank 在什么时候计算、通信或等待,再选中一段 AllReduce,查看消息大小、两端带宽,以及这段传输达到了本机实测参考值的百分之几。
12
+
13
+ <img src="assets/h20-decode.png" width="100%" alt="Qwen3 在 H20 上的一次 Decode,时间轴下方展示 HBM 读写、Tensor 活跃度和 BF16 GEMM 算力,橙色标记指出 GPU 空档">
14
+
15
+ ## 在 torch.profiler 和 Perfetto 上增加了什么
16
+
17
+ | 你手上的数据或问题 | ServeUtil 提供的扩展 |
18
+ |---|---|
19
+ | `torch.profiler` 录到了算子、CUDA kernel 和拷贝,这段时间硬件实际有多忙? | 保留原始 trace,在同一时间轴附加设备级采样。按可用后端显示 HBM 读写、PCIe 与 NVLink 收发、节点网口与 RDMA 端口带宽,以及 SM、Tensor 和精度流水线活跃度。 |
20
+ | 看到 58 MB/s,怎样判断它有多高? | 用同一设备、方向和测量口径的微测结果作为分母。选区卡片同时给出绝对量、利用率和参考负载。有输入形状且能唯一关联到 kernel 的 dense GEMM 还可显示有效 TFLOP/s。 |
21
+ | Perfetto 中有许多嵌套的算子和并行轨道,该从哪里看? | 默认从 Prefill、Decode 和资源使用看全局,再按节点、rank、算子层级或叶子展开。通信视图可沿配对的 Send/Recv 查看对端,也能查看 PD 分离的 KV 交接证据。 |
22
+ | 哪些区间值得细看? | 标记重复 GPU 空档、缺少计算重叠的通信、持续带宽压力和可比较的 rank 耗时差异。点击标记查看触发依据。需要原始事件、flow 或 SQL 时,在同一份报告切到 **Full Perfetto**。 |
23
+
24
+ 例如,两台 H20 上的 SGLang TP2 在一次单并发推理的 3.05 秒选区内平均发送约 58.5 MB/s,约为同向 eRDMA 端口实测基线的 0.51%。同一选区 4,469 次完整 AllReduce 中有 3,956 次载荷仅 2 KiB。把消息大小、计算间隔和端口读数放在一起,才能解释这个百分比。[模型与两端计数器实测](docs/validation.md)
25
+
26
+ ## 安装
27
+
28
+ 使用 Python 3.10 或更高版本,从 PyPI 安装 ServeUtil。
29
+
30
+ ```bash
31
+ pip install serveutil
32
+ serveutil --help
33
+ ```
34
+
35
+ 基础安装包含命令行、浏览器查看器和 NVIDIA NVML 绑定。打开已有 trace 可以使用普通电脑。采集模型时使用推理环境已有的 PyTorch 或模型服务。Linux 上需要通过 CUPTI 独立测量分方向 HBM 读写时,安装 `pip install "serveutil[pm]"`,并确保驱动和设备允许读取性能计数器。原生桌面窗口可用 `pip install "serveutil[desktop]"` 安装。[指标来源与支持条件](docs/metrics.md)
36
+
37
+ ## 第一次使用
38
+
39
+ **已经有 trace** 时,一条命令即可本地打开。也可以把多个 rank 的文件拖入窗口,或导入整个采集目录。需要一份可分享的离线报告时执行第二行。
40
+
41
+ ```bash
42
+ serveutil view rank0.pt.trace.json.gz
43
+ serveutil report rank0.pt.trace.json.gz -o report.html
44
+ ```
45
+
46
+ **自己的 PyTorch 程序**可以把待测代码放入 `serveutil.profile`。下面的例子可独立运行,CPU 和 CUDA 环境均可使用。将线性层替换成自己的模型即可采集实际推理。
47
+
48
+ ```python
49
+ import torch
50
+ import serveutil
51
+
52
+ device = "cuda" if torch.cuda.is_available() else "cpu"
53
+ projection = torch.nn.Linear(256, 256, bias=False).to(device).eval()
54
+ x = torch.ones(32, 256, device=device)
55
+
56
+ with torch.inference_mode(), serveutil.profile("runs", record_shapes=True) as prof:
57
+ with torch.profiler.record_function("Projection"):
58
+ projection(x)
59
+ prof.step()
60
+
61
+ print(prof.serveutil_directory / "report.html")
62
+ ```
63
+
64
+ `prof` 就是原生 `torch.profiler.profile` 对象。默认在首次 CUDA 采集前标定所选设备,后续复用缓存。已有原生 schedule、TensorBoard 回调或异步导出的项目还可用 `instrument` 或 `observe` 接入。[PyTorch 集成示例](docs/torch-profiler.md)
65
+
66
+ **已经运行的 vLLM 或 SGLang 服务**需要先启用框架的 PyTorch profiler。以单 GPU 为例,vLLM 启动时增加 `--profiler-config '{"profiler":"torch","torch_profiler_dir":"/profiles"}'`。SGLang 启动前设置 `SGLANG_TORCH_PROFILER_DIR=/profiles`。服务和采集端都要能访问对应的 trace 目录。随后选择与服务对应的一条命令。
67
+
68
+ ```bash
69
+ serveutil capture --engine vllm --url http://localhost:8000 \
70
+ --trace-dir /profiles --seconds 5 --generate "Explain prefill and decode."
71
+
72
+ serveutil capture --engine sglang --url http://localhost:30000 \
73
+ --trace-dir /profiles --seconds 5 --generate "Explain prefill and decode."
74
+ ```
75
+
76
+ 命令会预热并发出请求,通知模型 worker 启停原生 profiler,同时采集硬件指标,最后打印 `report.html` 路径。已有业务流量时省略 `--generate`。空闲测试设备可用 `--calibrate` 获取基线,或用 `--calibration calibration.json` 复用已有结果。多节点或 PD 分离只需先写一次拓扑文件,之后每次仍用一条采集命令。[服务采集指南](docs/capture.md) · [多节点拓扑](examples/distributed-topology.json) · [PD 拓扑](examples/pd-topology.json)
77
+
78
+ ## 样例与进一步使用
79
+
80
+ - 下载并用浏览器打开两份实测节选,看看如何从一次 Decode 定位 GPU 空档,或从两个 rank 的集合通信查到消息大小和参考带宽。[Qwen3 Decode](examples/h20-decode.html) · [SGLang 双卡 AllReduce](examples/h20-allreduce.html)
81
+ - 了解节点与 rank 筛选、原始名称、算子深度、通信配对、完整 Perfetto 和数据导出。[查看器指南](docs/viewer.md)
82
+ - 核对利用率分母、短窗口采样精度、真实双机结果与 profiling 开销。[指标定义](docs/metrics.md) · [实测记录](docs/validation.md)
83
+ - 使用 nvbandwidth、nccl-tests、RDMA perftest 做标定,或接入 HTA、TraceLens 和 llmperfscope。[已有工具与对应入口](docs/tools.md)
84
+
85
+ ServeUtil 采用 Apache License 2.0,随包分发的组件保留上游许可。[许可证](LICENSE) · [第三方声明](NOTICE)
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="204" height="20" role="img" aria-label="engines: PyTorch | vLLM | SGLang"><title>engines: PyTorch | vLLM | SGLang</title><filter id="blur"><feGaussianBlur stdDeviation="16"/></filter><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="204" height="20" rx="3"/></clipPath><g clip-path="url(#r)"><rect width="53" height="20" fill="#555"/><rect x="53" width="151" height="20" fill="#14695c"/><rect width="204" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><g transform="scale(.1)"><g aria-hidden="true" fill="#010101"><text x="275" y="150" fill-opacity=".8" filter="url(#blur)" textLength="430">engines</text><text x="275" y="150" fill-opacity=".3" textLength="430">engines</text></g><text x="275" y="140" textLength="430">engines</text></g><g transform="scale(.1)"><g aria-hidden="true" fill="#010101"><text x="1275" y="150" fill-opacity=".8" filter="url(#blur)" textLength="1410">PyTorch | vLLM | SGLang</text><text x="1275" y="150" fill-opacity=".3" textLength="1410">PyTorch | vLLM | SGLang</text></g><text x="1275" y="140" textLength="1410">PyTorch | vLLM | SGLang</text></g></g></svg>
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,67 @@
1
+ # 部署与采集
2
+
3
+ 模型服务须启用其原生 PyTorch profiler。将 GPU 可见范围、worker、采样器和 trace 输出目录配置在同一部署中。ServeUtil 可在已有流量上录制,也可用 `--generate` 自动预热并持续发出真实请求。设置 `--max-tokens` 和 `--concurrency` 控制该负载。
4
+
5
+ ## 单节点
6
+
7
+ vLLM 的 PyTorch profiler 启动配置示例为 `--profiler-config '{"profiler":"torch","torch_profiler_dir":"/profiles"}'`。SGLang 可设置 `SGLANG_TORCH_PROFILER_DIR=/profiles`;不同版本的管理接口可能需要 `SGLANG_ADMIN_API_KEY`。按实际部署版本核对启动参数。运行 ServeUtil 的进程须能读取 worker 写出的文件,容器内外的目录可通过挂载对应。[vLLM profiling](https://docs.vllm.ai/en/latest/contributing/profiling/) · [SGLang profiling](https://docs.sglang.io/docs/developer_guide/benchmark_and_profiling)
8
+
9
+ ```bash
10
+ serveutil capture --engine vllm --url http://localhost:8000 \
11
+ --trace-dir /profiles --ranks 2 --seconds 5 --generate "Explain how a GPU works."
12
+ ```
13
+
14
+ SGLang 使用 `--engine sglang`,需要指定服务端目录时加 `--server-trace-dir /profiles`。首次在空闲测试设备上获取本机基线可加 `--calibrate`,也可用 `--calibration path/to/calibration.json` 复用先前的结果。设备选择支持 NVML 物理编号或 GPU UUID,如 `--devices 0,1`。单独使用 `serveutil calibrate --devices 0,1` 时,数字指 CUDA 可见序号。
15
+
16
+ ## 多节点与 PD 分离
17
+
18
+ ```bash
19
+ serveutil capture --engine sglang --topology deployment.json \
20
+ --seconds 5 --generate "Explain the difference between prefill and decode."
21
+ ```
22
+
23
+ 普通分布式引擎使用一个控制端点,分别从每台 worker 主机收集文件。PD 分离把生成请求送到 router,直接在 Prefill 和 Decode 端点开始和停止录制。[多节点配置样例](../examples/distributed-topology.json) · [PD 配置样例](../examples/pd-topology.json)
24
+
25
+ - `targets` 列出实际提供 profiling API 的服务。每个条目可有 `url`、`role`、`output_dir`(SGLang 进程看到的路径)、`key_env` 和请求超时 `timeout`。凭据从指定环境变量读取。SGLang 默认录制算子与 GPU 事件,需要 Python 调用栈时可在对应 target 添加 `"with_stack": true`;完整调用栈会增加导出时间与文件体积。
26
+ - `client_url` 是生成请求的基础 URL。生成器自动读取模型名,也可以通过 `--model` 指定,尤其适用于未提供模型枚举的 PD router。
27
+ - `nodes` 列出采集器进程。每个节点安装同一版本的 ServeUtil。`command` 是启动 `python -m serveutil.worker` 的参数数组,支持本机、SSH 和容器命令。标准输出用作数据通道。每个 rank 的 trace 由一个节点负责,共享目录应按实际写入范围配置。
28
+ - 每个节点的 `roots` 填写角色、worker 可见的 trace 目录和预期 rank 数。`workdir` 存放节点临时样本和选用的标定缓存。`devices` 可以限制采样设备。`device_map` 可明确将 Kineto 本地设备号映射到 GPU UUID,用于多 GPU 的算力基线查找。
29
+ - 同节点各 worker 使用独立的 CUDA 设备编号时,可用 `rank_device_maps` 按角色和 rank 覆盖节点映射。例如 `{"worker":{"0":{"0":"GPU-…"},"1":{"0":"GPU-…"}}}` 将两个进程各自的 CUDA 0 对应到实际设备。选中 rank 后,查看器按映射筛选 GPU 曲线,并保留节点级网络曲线。
30
+ - 节点可配置 `calibrate: true` 或 `calibration_file`。拓扑的 `links` 数组可加入基线测量配置。独立标定入口是 `serveutil calibrate --link link.json -o network-reference.json`。[网络配置样例](../examples/link.json)
31
+ - SGLang 请求级 KV 关联可在拓扑中加 `transfers` 指向 OpenTelemetry 采集文件或描述文件,路径相对于拓扑 JSON。vLLM 在配置了角色的 PD 端点上读取可用的 NixlConnector 指标。
32
+
33
+ ### 标定两台机器之间的 RDMA 带宽
34
+
35
+ 在两个端点安装支持目标内存类型的 perftest,把样例中的测试地址和 `rdma_port` 替换为实际地址和 HCA 端口(例如 `ibstat` 列出的设备及端口号)。运行 `serveutil calibrate --link examples/rdma-link.json -o network-reference.json` 会得到有效载荷 GB/s,以及两端有可用计数器时的端口 GB/s。[RDMA WRITE 配置样例](../examples/rdma-link.json)
36
+
37
+ 默认两端使用主存。在源端增加 `"cuda_device": 0` 可测 GPU 到远端主存;两端都指定 CUDA 序号可测试 GPU 到 GPU,具体取决于两端的 GPUDirect RDMA 支持。若可执行文件不在 PATH,可在对应端点设置 `perftest` 为支持 CUDA 的 `ib_write_bw` 绝对路径。
38
+
39
+ ## 采集包
40
+
41
+ 命令返回本轮的 `report.html`。原始 trace、压缩硬件样本、配置结果、节点时钟和可用性在同一目录。可用 `serveutil report CAPTURE -o report.html` 重建页面,或用 `serveutil export CAPTURE -o overview.json` 输出供 Perfetto 打开的多轨概览。设备权限或接口不足的原因见页面底部的采集详情。使用内置请求生成器时,采集器在导出前等在途请求结束。若部分端点导出失败,采集包记录错误,并用已回收的有效 trace 生成可诊断的报告。
42
+
43
+ 浏览器与桌面查看器可直接打开 ServeUtil HTML、report JSON 和 PyTorch JSON/gzip。直接打开原始 trace 时以已有事件及 counter 绘图;离线 report 命令另行执行关联和优化机会分析。安装 `.[llmperfscope]` 后,还可用 report 命令读取 llmperfscope 的 run 目录,复用其阶段和原始设备采样。[llmperfscope 格式](https://github.com/developer0hye/llmperfscope/blob/main/docs/run-json.md)
44
+
45
+ ## NCCL 集合通信与基线
46
+
47
+ 点击通信 kernel 可查看本 rank 的进程组、序号、消息字节和算法带宽。一个操作包含多个 kernel 时,按第一个开始到最后一个结束的时间计算,并在第一个 kernel 展示速率。AllGather 取完整输出大小,ReduceScatter 取完整输入大小。支持的集合操作同时显示按 nccl-tests 公式折算的总线带宽,send/recv 显示本 rank 方向及 trace 记录的对端。[NCCL 带宽定义](https://github.com/NVIDIA/nccl-tests/blob/master/doc/PERFORMANCE.md)
48
+
49
+ 要对照实测基线,在节点的 `calibration_file` 中提供相同传输配置下的 nccl-tests 标定结果。节点的 `collective_groups` 按 `roots[].role` 和 Kineto 的 `Process Group Name` 指定 GPU UUID,顺序与该组的 rank 顺序一致。以下是角色 `worker`、进程组 `3` 的节点配置片段。请将示意 UUID 替换为实际值。
50
+
51
+ ```json
52
+ {
53
+ "collective_groups": {
54
+ "worker": {
55
+ "3": {
56
+ "devices": ["GPU-uuid-of-first-rank", "GPU-uuid-of-second-rank"],
57
+ "operations": {
58
+ "all_reduce": {"placement": "in_place", "reduction": "sum"},
59
+ "all_gather": {"placement": "out_of_place"}
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ ServeUtil 优先使用 trace 中能验证的规约类型和缓冲区布局,再使用配置补全缺失项。节点、角色、进程组、设备顺序、操作、消息大小、数据类型与布局均有对应记录时,页面显示本 rank 算法带宽相对 nccl-tests 基线的百分比。规约操作还要匹配规约类型,有根操作还要匹配 `root_rank`。trace 和基线都记录了 NCCL 版本时,还会检查版本一致性。该百分比可以超过 100%,受 kernel 内等待和测试条件影响。
@@ -0,0 +1,30 @@
1
+ # 安装与下载
2
+
3
+ ## 网页版查看器
4
+
5
+ 点击导航栏的「打开查看器」,拖入 trace 或选择整个采集文件夹。文件在浏览器本地处理。也可以直接打开教程中的真实样例。
6
+
7
+ ## 桌面客户端
8
+
9
+ 按操作系统和架构下载下方的构建产物,完整解压。Windows 打开 **ServeUtil.exe**,macOS 打开 **ServeUtil.app**,Linux 运行解压目录内的 **ServeUtil**。桌面窗口可离线读取 JSON、gzip、ServeUtil 报告和原生 Perfetto trace。
10
+
11
+ ## Python 命令行与模型采集
12
+
13
+ 使用 Python 3.10 或更高版本。已发布版本在 PyPI 上的安装方式为:
14
+
15
+ ```bash
16
+ pip install serveutil
17
+ serveutil --help
18
+ ```
19
+
20
+ 如需使用 GitHub 仓库的最新源码,运行以下命令。
21
+
22
+ ```bash
23
+ python -m pip install "serveutil @ git+https://github.com/HaoyangPing0324/ServeUtil.git"
24
+ ```
25
+
26
+ 录制时使用模型现有的 PyTorch 环境。兼容 Linux 设备需要独立 CUPTI HBM 采样时安装 `serveutil[pm]`。从 Python 环境启动桌面窗口时安装 `serveutil[desktop]`。[第一次采集](start.md)
27
+
28
+ ## 版本记录
29
+
30
+ [GitHub Releases](https://github.com/HaoyangPing0324/ServeUtil/releases)列出带标签的版本及桌面附件。网站还提供对应代码版本已通过验证的构建。反馈问题时可附下载旁标明的提交版本。
@@ -0,0 +1,45 @@
1
+ # Capture a model server
2
+
3
+ Start the service with its PyTorch profiler enabled. The worker writes operator and device traces. ServeUtil controls the recording window, samples hardware, collects each worker's files and builds one report.
4
+
5
+ ## Single node
6
+
7
+ For vLLM, add `--profiler-config '{"profiler":"torch","torch_profiler_dir":"/profiles"}'` to the serve command. For SGLang set `SGLANG_TORCH_PROFILER_DIR=/profiles` before launch. Mount the same directory into the collector if the server runs in a container. Some SGLang deployments require `SGLANG_ADMIN_API_KEY`. Verify launch flags for your installed version. [vLLM profiling](https://docs.vllm.ai/en/latest/contributing/profiling/) · [SGLang profiling](https://docs.sglang.io/docs/developer_guide/benchmark_and_profiling)
8
+
9
+ ```bash
10
+ serveutil capture --engine vllm --url http://localhost:8000 \
11
+ --trace-dir /profiles --ranks 2 --seconds 5 --generate "Explain how a GPU works."
12
+ ```
13
+
14
+ Set `--ranks` to the expected worker count. For SGLang use `--engine sglang` and its service URL. If the worker sees a different output path, pass `--server-trace-dir`. The optional generator warms up and sends streaming requests. Adjust `--concurrency` and `--max-tokens` or omit `--generate` to observe existing traffic.
15
+
16
+ ## Calibrate resources
17
+
18
+ Use `--calibrate` on idle test GPUs or pass `--calibration calibration.json` to reuse a prior run. The capture option `--devices` accepts NVML physical indices or GPU UUIDs. Numeric indices in standalone `serveutil calibrate --devices 0,1` refer to CUDA-visible devices. Use UUIDs where mappings differ.
19
+
20
+ ## Multi-node and disaggregated serving
21
+
22
+ Start with the [distributed topology](../../examples/distributed-topology.json) or [PD topology](../../examples/pd-topology.json). Substitute your hosts, paths and role names. Install the same ServeUtil version on each collector node.
23
+
24
+ ```bash
25
+ serveutil capture --engine sglang --topology deployment.json \
26
+ --seconds 5 --generate "Explain the difference between prefill and decode."
27
+ ```
28
+
29
+ | Topology field | How to fill it |
30
+ |---|---|
31
+ | `client_url` | Generation endpoint, usually the router for PD. Pass `--model` if the router cannot enumerate models. |
32
+ | `targets` | Each profiling endpoint's URL, role, worker-visible `output_dir`, optional `key_env` and `timeout`. SGLang accepts `with_stack` when Python stacks are needed. |
33
+ | `nodes[].command` | Argument array launching `python -m serveutil.worker` locally, through SSH or inside a container. SSH can collect files while model data travels over the actual serving network. |
34
+ | `roots`, `workdir` | Give each worker trace exactly one owning collector. Set the role, directory, rank count and writable working directory. |
35
+ | `devices`, `device_map`, `rank_device_maps` | Map visible CUDA ordinals to physical UUIDs. Per-rank mappings distinguish workers that each see a local GPU 0. |
36
+ | `calibrate`, `calibration_file`, `links` | Acquire or load node references and describe links for directional baselines. |
37
+ | `transfers` | SGLang request spans or their collection description. Paths are relative to the topology file. vLLM uses configured NIXL endpoint counters for PD. |
38
+
39
+ For network calibration, edit the addresses, device, port and buffer type in the [RDMA link example](../../examples/rdma-link.json). Install compatible perftest binaries on both hosts and run `serveutil calibrate --link link.json -o network-reference.json`. Both endpoints default to host memory. Specify CUDA devices at both ends for a GPU-to-GPU reference when GPUDirect is available. For TCP use the [TCP link example](../../examples/link.json).
40
+
41
+ ## Collectives and outputs
42
+
43
+ To compare against nccl-tests, supply a matching calibration file. Set `collective_groups` by role and Kineto process-group name when group layout is missing. Specify ordered GPU UUIDs and the operation. The report matches message size, layout, operation, root or reduction where applicable, and NCCL version when recorded.
44
+
45
+ The command prints `report.html`. Keep the capture directory for original traces, calibration, samples and clock metadata. Rebuild with `serveutil report CAPTURE -o report.html`. Failed collection records which endpoints or metrics were unavailable.