Skip to content

[None][perf] executor: avoid deepcopy of prompt_token_ids on enqueue#14889

Merged
lancelly merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:perf/avoid-prompt-token-deepcopy
Jun 3, 2026
Merged

[None][perf] executor: avoid deepcopy of prompt_token_ids on enqueue#14889
lancelly merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:perf/avoid-prompt-token-deepcopy

Conversation

@lancelly

@lancelly lancelly commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

What

_enqueue_request deep-copied request.prompt_token_ids on every request. It's a flat list of token ids (immutable ints), so a shallow list(...) gives the same isolation far more cheaply — nothing downstream mutates the list in place (the prompt-adapter path rebuilds a new list; tllm.Request copies input_token_ids into its own C++ buffer). Also drops the now-unused import copy.

`_enqueue_request` deep-copied `request.prompt_token_ids` on every request.
The value is a flat list of token ids (immutable ints), so a shallow
`list(...)` gives the same isolation far more cheaply -- nothing downstream
mutates the list in place (the prompt-adapter path rebuilds a new list, and
`tllm.Request` copies `input_token_ids` into its own C++ buffer).

For long prompts this matters: `copy.deepcopy` of a large id list runs in
Python holding the GIL on the enqueue path, stalling the executor loop.
On a DeepSeek-V4 disaggregated run (~40k input tokens, c160) replacing it
with `list(...)` collapsed the generation-worker per-iter tail
(host_step_time p99 ~127ms -> ~63ms, p95 ~78ms -> ~50ms; p50 unchanged) and
improved per-request output speed (SSE p25 +~13%) and throughput (+~9%).

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
@lancelly
lancelly marked this pull request as ready for review June 3, 2026 06:08
@lancelly
lancelly requested a review from a team as a code owner June 3, 2026 06:08
@lancelly
lancelly requested review from zhenhuaw-me and removed request for a team June 3, 2026 06:08
@lancelly

lancelly commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51772 [ run ] triggered by Bot. Commit: d4cfecc Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51772 [ run ] completed with state SUCCESS. Commit: d4cfecc
/LLM/main/L0_MergeRequest_PR pipeline #41139 completed with status: 'SUCCESS'

CI Report

Link to invocation

@lancelly
lancelly merged commit 86a26fe into NVIDIA:feat/deepseek_v4 Jun 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants