[TRTLLM-12670][feat] add /start_profile and /stop_profile endpoints to trtllm… - #13872
[TRTLLM-12670][feat] add /start_profile and /stop_profile endpoints to trtllm…#13872JunyiXu-nv wants to merge 2 commits into
Conversation
69b3d68 to
86b3237
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #47712 [ run ] triggered by Bot. Commit: |
0b70c55 to
029a94b
Compare
|
PR_Github #47712 [ run ] completed with state
|
…ints Two follow-up fixes for the CI failures introduced by the profile endpoints PR (NVIDIA#13872): 1. API stability reference: add start_profile / stop_profile entries to tests/unittest/api_stability/references/llm.yaml so TestLLM::test_{signature,docstring,modified_init,...} stops failing with "LLM has different methods: {'start_profile', 'stop_profile'}". 2. Ray WorkerExtension collision: allow a user-supplied WorkerExtension to override BaseWorker.start_profile / stop_profile. These names are explicitly designated extension points (the RLHF WorkerExtension in tensorrt_llm/llmapi/rlhf_utils.py uses torch.cuda.profiler directly), so _inject_worker_extension now copies overridable extension methods into the derived class dict, which makes the extension's impl win regardless of MRO order and keeps the conflict check strict for every other name. Fixes the cascade of "RayGPUWorker died during initialization / Worker class RayGPUWorker already defines 'start_profile'" errors across the Ray test suites (H100, H100_PCIe, B200). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
|
/bot run |
|
PR_Github #48187 [ run ] triggered by Bot. Commit: |
|
PR_Github #48187 [ run ] completed with state
|
The Pre-commit Check on PR NVIDIA#13872 failed with two issue families: * ruff-format (PEP-8 + 80-col yapf-equivalent) reformatted multiline asserts and f-strings in the new test files. * ruff-legacy reported 8 D205 regressions ('1 blank line required between summary line and description') vs the baseline. Some are in docstrings I added (proxy._wait_profile_ack, proxy.start_profile, proxy.stop_profile, test_e2e.test_trtllm_serve_profile_example, 4 docstrings in tests/unittest/executor/test_proxy_profile_sync.py) and a few are pre-existing violations whose line numbers shifted because of my additions (proxy.submit, test_e2e bench tests). Fix all 8 by inserting the required blank line after each docstring summary line and tightening summary lines so they are real sentences (D415 fix on the test_proxy_profile_sync.py module docstring). Also accept the ruff-format reflow on the two test files. Verified locally with: pre-commit run --files <touched files> — all hooks pass (yapf, ruff, ruff-format, ruff-legacy, autoflake, codespell, etc.). Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@users.noreply.github.com>
a07a3da to
41eca47
Compare
…ints Two follow-up fixes for the CI failures introduced by the profile endpoints PR (NVIDIA#13872): 1. API stability reference: add start_profile / stop_profile entries to tests/unittest/api_stability/references/llm.yaml so TestLLM::test_{signature,docstring,modified_init,...} stops failing with "LLM has different methods: {'start_profile', 'stop_profile'}". 2. Ray WorkerExtension collision: allow a user-supplied WorkerExtension to override BaseWorker.start_profile / stop_profile. These names are explicitly designated extension points (the RLHF WorkerExtension in tensorrt_llm/llmapi/rlhf_utils.py uses torch.cuda.profiler directly), so _inject_worker_extension now copies overridable extension methods into the derived class dict, which makes the extension's impl win regardless of MRO order and keeps the conflict check strict for every other name. Fixes the cascade of "RayGPUWorker died during initialization / Worker class RayGPUWorker already defines 'start_profile'" errors across the Ray test suites (H100, H100_PCIe, B200). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
The Pre-commit Check on PR NVIDIA#13872 failed with two issue families: * ruff-format (PEP-8 + 80-col yapf-equivalent) reformatted multiline asserts and f-strings in the new test files. * ruff-legacy reported 8 D205 regressions ('1 blank line required between summary line and description') vs the baseline. Some are in docstrings I added (proxy._wait_profile_ack, proxy.start_profile, proxy.stop_profile, test_e2e.test_trtllm_serve_profile_example, 4 docstrings in tests/unittest/executor/test_proxy_profile_sync.py) and a few are pre-existing violations whose line numbers shifted because of my additions (proxy.submit, test_e2e bench tests). Fix all 8 by inserting the required blank line after each docstring summary line and tightening summary lines so they are real sentences (D415 fix on the test_proxy_profile_sync.py module docstring). Also accept the ruff-format reflow on the two test files. Verified locally with: pre-commit run --files <touched files> — all hooks pass (yapf, ruff, ruff-format, ruff-legacy, autoflake, codespell, etc.). Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #48285 [ run ] triggered by Bot. Commit: |
|
PR_Github #48285 [ run ] completed with state
|
41eca47 to
fcb8426
Compare
…ints Two follow-up fixes for the CI failures introduced by the profile endpoints PR (NVIDIA#13872): 1. API stability reference: add start_profile / stop_profile entries to tests/unittest/api_stability/references/llm.yaml so TestLLM::test_{signature,docstring,modified_init,...} stops failing with "LLM has different methods: {'start_profile', 'stop_profile'}". 2. Ray WorkerExtension collision: allow a user-supplied WorkerExtension to override BaseWorker.start_profile / stop_profile. These names are explicitly designated extension points (the RLHF WorkerExtension in tensorrt_llm/llmapi/rlhf_utils.py uses torch.cuda.profiler directly), so _inject_worker_extension now copies overridable extension methods into the derived class dict, which makes the extension's impl win regardless of MRO order and keeps the conflict check strict for every other name. Fixes the cascade of "RayGPUWorker died during initialization / Worker class RayGPUWorker already defines 'start_profile'" errors across the Ray test suites (H100, H100_PCIe, B200). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
The Pre-commit Check on PR NVIDIA#13872 failed with two issue families: * ruff-format (PEP-8 + 80-col yapf-equivalent) reformatted multiline asserts and f-strings in the new test files. * ruff-legacy reported 8 D205 regressions ('1 blank line required between summary line and description') vs the baseline. Some are in docstrings I added (proxy._wait_profile_ack, proxy.start_profile, proxy.stop_profile, test_e2e.test_trtllm_serve_profile_example, 4 docstrings in tests/unittest/executor/test_proxy_profile_sync.py) and a few are pre-existing violations whose line numbers shifted because of my additions (proxy.submit, test_e2e bench tests). Fix all 8 by inserting the required blank line after each docstring summary line and tightening summary lines so they are real sentences (D415 fix on the test_proxy_profile_sync.py module docstring). Also accept the ruff-format reflow on the two test files. Verified locally with: pre-commit run --files <touched files> — all hooks pass (yapf, ruff, ruff-format, ruff-legacy, autoflake, codespell, etc.). Signed-off-by: Junyi Xu <219237550+JunyiXu-nv@users.noreply.github.com>
The Pre-commit Check on PR NVIDIA#13872 failed with two issue families: * ruff-format (PEP-8 + 80-col yapf-equivalent) reformatted multiline asserts and f-strings in the new test files. * ruff-legacy reported 8 D205 regressions ('1 blank line required between summary line and description') vs the baseline. Some are in docstrings I added (proxy._wait_profile_ack, proxy.start_profile, proxy.stop_profile, test_e2e.test_trtllm_serve_profile_example, 4 docstrings in tests/unittest/executor/test_proxy_profile_sync.py) and a few are pre-existing violations whose line numbers shifted because of my additions (proxy.submit, test_e2e bench tests). Fix all 8 by inserting the required blank line after each docstring summary line and tightening summary lines so they are real sentences (D415 fix on the test_proxy_profile_sync.py module docstring). Also accept the ruff-format reflow on the two test files. Verified locally with: pre-commit run --files <touched files> — all hooks pass (yapf, ruff, ruff-format, ruff-legacy, autoflake, codespell, etc.). Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
1e41133 to
941d851
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #48498 [ run ] triggered by Bot. Commit: |
|
PR_Github #48498 [ run ] completed with state
|
|
PR_Github #69769 [ run ] completed with state |
|
PR_Github #69778 [ run ] completed with state
|
…o trtllm-serve
Expose iteration-scoped runtime profiling over HTTP on the OpenAI-compatible
trtllm-serve endpoint.
- POST /start_profile accepts output_dir, num_steps, start_step, activities
(any of "CPU", "GPU", "CUDA_PROFILER"). With "CUDA_PROFILER" only, the server
skips torch.profiler entirely so it composes with `nsys profile -c
cudaProfilerApi`.
- POST /stop_profile terminates the active window and flushes the trace.
- PyExecutor.start_profile/stop_profile reuse the existing profile_start_iters /
profile_stop_iters / cudaProfilerStart-Stop plumbing so env-var-based
profiling behavior is preserved.
- GenerationExecutor, BaseWorker and GenerationExecutorRpcProxy proxy the calls
into the worker process; non-PyTorch backends fall through to a warning.
- LLM.start_profile / stop_profile added as @set_api_status("prototype").
Rebased onto main; the branch's 15 development commits are collapsed into one
because several predate the tensorrt_llm/executor/ray_gpu_worker.py ->
ray/gpu_worker.py move and could not be replayed onto current main without
hand-porting each intermediate state.
Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
… before applying it `_sync_server_clock` estimates each ctx/gen server's clock offset with the NTP algorithm over a single HTTP round trip, then adds it to every perf-metric timestamp that server reports. That estimate's error is bounded by half the round-trip delay, because an asymmetric round trip is indistinguishable from a real clock offset -- and the handshake runs while the servers are still finishing startup, so a single sample regularly lands on a stalled event loop. On one host the true offset is exactly 0 (everything reads CLOCK_MONOTONIC), so whatever it computes is pure injected error. Across CI, 2394 of 2407 measured offsets are positive: the bias is systematic and lands entirely on the outbound leg, where DNS resolution, connection setup and the server's first-ever request are paid. `test_disaggregated_perf_metrics` asserts a 5 ms tolerance against that offset and has failed 4/4 runs here with 33-69 ms of injected skew, versus a 0.87 ms median across 128 baseline runs on main. - Warm up the connection first so DNS and connect costs stay out of the samples. - Probe up to `_CLOCK_SYNC_PROBES` times and keep the least-delayed round trip (NTP's clock filter), stopping early once a sample is conclusive so a healthy server still costs one probe. - Discard the offset when even the best delay exceeds `_CLOCK_SYNC_MAX_DELAY_SECONDS`: past that the estimate is worth less than the zero it would replace, since co-located servers share CLOCK_MONOTONIC and NTP-synced hosts agree to well under a millisecond. - Bound the cost: a dedicated per-request timeout instead of inheriting `_req_timeout_secs`, a wall-clock budget for the probe loop, and no retries against a server that errors -- servers are prepared sequentially, so an unresponsive one must not stall the queue behind it. Adds CPU-only unit tests driving the handshake against a stub endpoint with an injectable one-sided stall. Signed-off-by: JunyiXu-nv <219237550+JunyiXu-nv@users.noreply.github.com>
Fix verified; one real regression found and fixedThe lazy ack channel worksPipeline #57074, node
The HMAC count is the load-bearing number: delays move with machine load, but the queue count is deterministic, so it confirms the lazy path is actually taken rather than the run getting lucky. All three profile suites pass on the rewired ack channel — The regressionThe pipeline still failed, on something unrelated to the handshake: This PR wraps forward+sample in I took that over making Checked the rest of the blast radius rather than assuming: ten test files construct Head is now |
|
/bot run |
|
PR_Github #69798 [ run ] triggered by Bot. Commit: |
|
PR_Github #69798 [ run ] completed with state
|
Everything this PR touches is green; the one failure is unrelated flakePipeline #57090 came back That is a C++ ctest. This PR changes no C++ —
Everything this PR does touch passed, on
The executor stage went 1062 passed / 4 failed → 1066 passed, which is exactly the four Re-running CI for the flaky C++ test. |
|
/bot run |
|
PR_Github #69830 [ run ] triggered by Bot. Commit: |
|
PR_Github #69830 [ run ] completed with state
|
|
/bot run |
Second run: different unrelated failure, and almost no coveragePipeline #57123 failed on one test, and it is not the same one as last time: CI's own analysis concluded "PR likely to blame?: No", but I checked rather than taking that on faith, and the honest picture is more nuanced than for the previous flake:
Worth flagging: this run produced almost no coverage. 268 artifacts against 4632 in #57090, and zero The run that actually exercised this PR is still #57090: handshake 1.23/1.47 ms, HMAC keys 6, disagg test passed first attempt, executor unit tests 1066/1066 on both architectures, and all three profile suites green (12/17/12). Its only failure was the Re-running. |
|
/bot run |
|
PR_Github #69859 [ run ] triggered by Bot. Commit: |
|
PR_Github #69860 [ run ] triggered by Bot. Commit: |
|
PR_Github #69859 [ run ] completed with state |
|
PR_Github #69860 [ run ] completed with state
|
|
/bot run |
Three runs, three different unrelated failures
Run 3 is the one worth spelling out, because CI rated it "Confidence: Medium — the PR does touch disaggregated serving". The failure is Runs 2 and 3 also carry no evidence either way about this PR: fail-fast aborted them before the single-GPU stages ran, so neither produced a single Run #57090 remains the only complete exercise of this PR, and everything it touches passed:
Re-running once more. |
|
/bot run |
|
PR_Github #69881 [ run ] triggered by Bot. Commit: |
|
PR_Github #69883 [ run ] triggered by Bot. Commit: |
|
PR_Github/13872-c29f879 #69881 was force-killed by a newer pipeline run. |
|
PR_Github #69883 [ run ] completed with state
|
|
/bot run |
Pausing re-runs: the RDMA/UCX fabric is unhealthy cluster-wideFour runs, four different failures, none of them this PR — and the last two are the same class:
Runs 3 and 4 are both UCX/RDMA transport failures on DGX H100 multi-GPU disagg stages, so I checked whether that is specific to this PR. It is not.
This PR accounts for 5 of those 40. Re-running will not converge until the fabric is healthy, so I have stopped re-triggering rather than keep burning CI. Runs 2-4 also carry no evidence about this PR either way: fail-fast aborted them before the single-GPU stages ran — 117-268 artifacts against 4632, and zero Run #57090 remains the only complete exercise of this PR, and everything it touches passed:
Suggest waiting for the RDMA issue to clear before re-running. |
|
PR_Github #69910 [ run ] triggered by Bot. Commit: |
|
PR_Github #69910 [ run ] completed with state
|
…-serve
Expose iteration-scoped runtime profiling over HTTP on the OpenAI-compatible trtllm-serve endpoint, mirroring SGLang's developer-profiling interface.
nsys profile -c cudaProfilerApi.Dev Engineer Review
POST /start_profileandPOST /stop_profiletotrtllm-serve.PyExecutor.CPU,GPU, andCUDA_PROFILER.#49393succeeded, but multiple main pipelines failed.QA Engineer Review
Added tests cover:
test_trtllm_serve_profile_example.The endpoint smoke test,
test_profile_endpoints.py, andtest_proxy_profile_sync.pyare listed intests/integration/test_lists/test-db/l0_a10.yml.Verdict: sufficient.
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.