Skip to content

[None][perf] serve: keep the iteration-stats reads off the serving event loop - #21907

Merged
Tabrizian merged 2 commits into
NVIDIA:feat/musespark-open-agentxfrom
Tabrizian:user/itabrizian/musespark-agentx-stats-offloop
Nov 9, 2026
Merged

Tabrizian merged 2 commits into
NVIDIA:feat/musespark-open-agentxfrom
Tabrizian:user/itabrizian/musespark-agentx-stats-offloop

Conversation

@Tabrizian

Copy link
Copy Markdown
Member

Brings the two upstream serving-stats fixes onto feat/musespark-open-agentx, which predates both.

Why this branch needs them. With iteration perf stats enabled, the collector awaited
get_stats_async(timeout=0.5) on the serving event loop. On the IPC proxy that is a synchronous RPC
which waits up to its timeout, so every streaming response stalled up to ~0.5 s per stats cycle and its
tokens reached the client in one burst. Benchmarks on this branch are required to run with
enable_iter_perf_stats: true, so every such point pays it.

Commits

  1. [https://nvbugs/6758245][fix] Cherry-pick #20429: Keep /metrics from blocking the serving event loop (#20698) — applies cleanly; introduces _metrics_stats_executor.
  2. [None][perf] serve: keep the iteration-stats collector off the event loop — the tensorrt_llm/serve/openai_server.py change of [None][perf] Qwen3.5 GB300: upstream the AgentX side-branch optimizations #20815, ported.

On the second commit. #20815 is not cherry-pickable here: the rest of it is Qwen3.5 GB300 kernel
work, it touches 223 files, and a whole-commit pick conflicts in the nanobind bindings. Its
openai_server.py hunk does not apply either, because this branch never took #20815's wakeup-timer
rework — so the change is ported onto the collector form this branch has, reading through the same
metrics executor /metrics uses, which is idle while the collector owns the queue.

Stats content, ordering and the /metrics tee are unchanged; this moves where the read happens.

Draft: not yet CI-run on this branch.

JunyiXu-nv and others added 2 commits November 8, 2026 19:51
…loop

Ports the tensorrt_llm/serve/openai_server.py change of NVIDIA#20815 (5d86481).  Only
that hunk: the rest of NVIDIA#20815 is Qwen3.5 GB300 kernel work, and a whole-commit
cherry-pick conflicts in the nanobind bindings and drags in 223 files.  A straight
apply of the hunk does not fit either -- this branch has not taken NVIDIA#20815's
wakeup-timer rework, so the collector is ported onto the form the branch has.

The collector awaited get_stats_async(timeout=0.5) on the serving event loop; on the
IPC proxy that is a synchronous RPC which waits up to its timeout, so every streaming
response stalled up to ~0.5 s per stats cycle and its tokens reached the client in one
burst.  It now reads through the metrics executor, the same one /metrics uses, which is
idle while this loop owns the queue.

This branch is exposed to it on every point that follows our rule requiring
enable_iter_perf_stats: true.

Applies on top of the cherry-pick of NVIDIA#20698, which introduces _metrics_stats_executor.

Signed-off-by: Iman Tabrizian <[email protected]>
@Tabrizian
Tabrizian marked this pull request as ready for review November 9, 2026 03:52
@Tabrizian
Tabrizian requested a review from a team as a code owner November 9, 2026 03:52
@Tabrizian

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@JunyiXu-nv JunyiXu-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serve part LGTM. The legacy /metrics read is identical to main's, and the collector now reads through the metrics thread the same way main does (minus main's timer wakeup, which this branch doesn't have). The collector task is cancelled before the executor shuts down, and get_stats returns the same dicts the async iterator yielded.

@Tabrizian

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #83341 [ run ] triggered by Bot. Commit: 473dc0f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #83341 [ run ] completed with state SUCCESS. Commit: 473dc0f
/LLM/main/L0_MergeRequest_PR pipeline #68879 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Tabrizian
Tabrizian merged commit ab93b78 into NVIDIA:feat/musespark-open-agentx Nov 9, 2026
Tabrizian added a commit to Tabrizian/TensorRT-LLM that referenced this pull request Nov 10, 2026
…become dispatch levers

Ports the MuseSpark GB300 decode kernel stack onto feat/musespark-open-agentx and
replaces the environment switches it carried with dispatch levers.

EVERY LEVER IS DEFAULT OFF. This is the port; it changes no behaviour until a lever
is knobbed on. Proved rather than asserted: a verifier rebuilds FAST_PATHS,
DEPENDS_ON and both compositions by AST and resolves them with an EMPTY environment
-- the resolved path sets are identical to the base at all ten deployments (44 paths
at TEP8, 54/53 at TEP4), and each lever is then shown to turn on by its own knob.

WHAT IS IN. 18 of the 25 patches in the source set: staged-router-gemm,
moe-expert-balance (2), decode-g1 (parts 1-5), decode-kernel-stack (3),
kernel-stack-2 (parts 1-5), tep8-decode-stack-v2, and context-fmha-v2.

decode-g1/6 is omitted as 100% redundant -- 51daa26 (NVIDIA#21364) is already in the
base and git apply --reverse of its hunk succeeds. The rest are not kernel changes
(http-keep-alive, context-kv-retire-v2, torch-memory-reserve), already upstream
(serving-stats-off-loop, merged as NVIDIA#21907), not free (context-scheduler-aging buys
x +7.9..9.0% with y -1.0..-1.2%), or inapplicable (router-held-placement: the GB300
e2e point is all-agg, so there is no router to configure).

Substantial redundancy was found and dropped rather than re-landed: NVIDIA#21377 and
NVIDIA#21580 had already built the widened TP8 finalize transport and left it pinned at
TP8_MAX_TOKENS = 16, so that layer collapses to a reader that unpins it.

NOT LANDED, reported rather than approximated. kernel-stack-2/4's three gathers.py
hunks need a TP8 kernel table (TP8_WIDE_KERNELS / WIDE_KERNELS_BY_SM_TP) that
appears in the patches only as context -- it is in no patch and no public commit.
decode-kernel-stack/3's eight EARLY_LOADS hunks have no host class, because NVIDIA#21754
moved SwaBlockMultiAttention out of the sm103 tree.

THREE DEFECTS THIS PORT INTRODUCED, each found by running the code after static
checks passed:

  1. weights._ring_buddy_row_cap called max_rows_for with two arguments against a
     one-argument signature, on the unconditional replicated_experts install path.
     Every TP8 deployment would have raised TypeError at load_weights.
  2. moe_prologue declared _wide_direct: bool as a class attribute, shadowing
     projection_gathers' transport object (default None) through the MRO. Every
     8-row decode step raised AttributeError("'bool' object has no attribute
     'is_armed'") at warmup, inside attention_output_into_hop, which is served by
     default at TP8.
  3. pool_into_route called _wide_router_shard with four arguments against five.
     Latent, behind a default-off lever.

THIRD-PARTY LICENSING. multi_instance_context_kernel.py derives from the CUTLASS
CuTe DSL Blackwell FMHA example (v4.8.0) and declares that derivation with the full
BSD-3-Clause notice in-file, matching 51 existing files in this repository and the
sm107 sibling added in 736cfdc. CUTLASS is already attributed in
ATTRIBUTIONS-Python.md and both per-arch CPP files, so no attribution file changes.

MEASURED. With every lever off the branch is indistinguishable from its base on
GB300 TEP8 decode (11.67 vs 11.93 ms at bs3, 12.26 vs 12.28 at bs4), which is a
correctness result -- the port does not disturb the default path -- and says nothing
about what the levers are worth. Non-bitwise levers still need their acceptance,
drift and step-time gates before any of them ships on by default.

Signed-off-by: Iman Tabrizian <[email protected]>
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