Skip to content

[None][perf] reduce rank-0 GIL contention in disaggregated generation - #15133

Merged
Tabrizian merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:perf/gen-rank0-gil-host-overhead
Jun 9, 2026
Merged

[None][perf] reduce rank-0 GIL contention in disaggregated generation#15133
Tabrizian merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:perf/gen-rank0-gil-host-overhead

Conversation

@lancelly

@lancelly lancelly commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What

Reduce per-iteration GIL contention on the disaggregated generation rank-0
process. At high concurrency rank 0 runs the executor loop, the request ingress,
and the attention-DP request broadcast on a single GIL, so host work on rank 0
paces the iteration. Two redundant, hot GIL costs on the executor-loop thread are
removed:

  1. safe_broadcast (_torch/distributed/communicator.py) — the root rank
    rebuilt its return value by pickle.loads-ing its own just-serialized bytes,
    a full deep copy of the broadcast payload (which carries the new requests'
    token ids) on every iteration. Return the original object instead. Also drops a
    now-dead size check that compared a length against itself.

  2. DefaultADPRouter._balance_requests_across_ranks
    (_torch/pyexecutor/scheduler/adp_router.py)
    input_token_ids is a C++
    getter that copies the whole token list on every access, and it was read twice
    per request per iteration (the descending-token sort key and the heap loop).
    Read it once per request.

Both run on the rank-0 executor-loop thread on every iteration at scale.

Impact

Measured on DeepSeek-V4-Pro 7P1D disaggregated (7×CTX-DEP4 + 1×GEN-DEP8, GB300),
concurrency 2880, py-spy on the rank-0 generation worker:

  • GEN host_step_time p50: 123.5 ms → ~105 ms (−15%)
  • GEN device_step_time p50: 123 ms → ~99 ms (−19%) — under the overlap
    scheduler the device step was being dragged up to the host step, i.e. the
    generation step was host-bound; relieving the host work surfaces the true
    device time
  • per-request output speed (SSE) p25: +~6%

No functional change.

Test

  • Router change is order-equivalent to the original (same descending-token sort).
  • safe_broadcast root return is value-identical: non-root ranks still
    reconstruct the same object from the broadcast bytes; the root already holds it.

@lancelly
lancelly force-pushed the perf/gen-rank0-gil-host-overhead branch from 7c6425a to 3bd22b9 Compare June 9, 2026 02:35
At high concurrency the disaggregated generation rank-0 process runs the
executor loop, the request ingress, and the attention-DP request broadcast on a
single GIL, so per-iteration host work on rank 0 paces the iteration. Two hot,
redundant GIL costs on the executor-loop thread are removed:

- safe_broadcast: the root rank rebuilt its return value by unpickling its own
  just-serialized bytes; return the original object instead. (Also drops the
  now-dead size check, which compared a length against itself.)
- DefaultADPRouter._balance_requests_across_ranks: input_token_ids is a C++
  getter that copies the whole token list on every access, and it was read in
  both the descending-token sort key and the heap loop; read it once per
  request.

No functional change.

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
@lancelly
lancelly force-pushed the perf/gen-rank0-gil-host-overhead branch from 3bd22b9 to 0279247 Compare June 9, 2026 03:03
@lancelly
lancelly marked this pull request as ready for review June 9, 2026 05:49
@lancelly
lancelly requested review from a team as code owners June 9, 2026 05:50
@lancelly
lancelly requested review from achartier, mikeiovine and yizhang-nv and removed request for a team June 9, 2026 05:50
@lancelly

lancelly commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52976 [ run ] triggered by Bot. Commit: 0279247 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52976 [ run ] completed with state SUCCESS. Commit: 0279247
/LLM/main/L0_MergeRequest_PR pipeline #42210 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@lancelly

lancelly commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53053 [ run ] triggered by Bot. Commit: 0279247 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53053 [ run ] completed with state SUCCESS. Commit: 0279247
/LLM/main/L0_MergeRequest_PR pipeline #42267 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Tabrizian
Tabrizian merged commit 2862ef6 into NVIDIA:feat/deepseek_v4 Jun 9, 2026
7 checks passed
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 26, 2026
…NVIDIA#15133)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Shixiaowei02 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 29, 2026
…NVIDIA#15133)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lancelly added a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 29, 2026
…NVIDIA#15133)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Signed-off-by: Liao Lanyu <108499334+lancelly@users.noreply.github.com>
Shixiaowei02 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 30, 2026
…NVIDIA#15133)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Signed-off-by: Liao Lanyu <108499334+lancelly@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants