Skip to content

[None][feat] Add the HALO-R planner and relay copy for per-layer dynamic EPLB - #20887

Merged
itamar-rauch merged 97 commits into
NVIDIA:mainfrom
itamar-rauch:halo-r-relay
Dec 3, 2026
Merged

itamar-rauch merged 97 commits into
NVIDIA:mainfrom
itamar-rauch:halo-r-relay

Conversation

@itamar-rauch

@itamar-rauch itamar-rauch commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

HALO-R is a second replica planner for per-layer dynamic EPLB (moe_config.load_balancer.mode: per_layer_dynamic, MEGAMOE_CUTEDSL). It sits next to HALO-Q, which is already on main.

  • Planner: in every forward pass and every MoE layer, it plans from that layer's current routing. Using the routed-token counts that every rank exchanges, it moves the tokens of each overloaded rank's hottest experts to ranks with room below the balanced load.
  • Copy: it replicates those experts into the receivers' helper slots with a unicast NVLink relay.
  • Selection: planner: halo_r selects it; planner: halo_q stays the default. HALO-Q's code moved partly into helpers it now shares with HALO-R; see "Changes to HALO-Q" below.

What this PR adds on top of HALO-Q:

  • One fused kernel on the auxiliary SMs. haloRFusedKernel (moeRebalanceHaloR.cu) runs on auxiliary_sms CTAs (2–16) on the copy stream. It holds the count exchange, the planner (moeRebalanceHaloRPlanner.h), the route mapping and the relay copy (moeRebalanceRelay.cuh), and it publishes READY at its end.
    • It reuses HALO-Q's count exchange, ordinal and route passes, its plan layout and its scheduler-group contract (generations, the route hold, the deferred route wait, the lease, the spin bound).
    • The shared expert's fused FC12 kernel runs on the main stream on the remaining SMs at the same time.
  • Pipelined relay copy. Each issuer warp's loads run ahead of its stores through a ring of shared-memory slots, and a slot is refilled as soon as the stores of its previous slice have read it. Slices are 32 KiB.
  • Resident-first skip-copy. With helper_slot_mode: per_layer_resident (the default), every rank keeps the same per-layer table of the expert each helper slot holds.
    • The relay skips a receiver whose slot already holds its expert.
    • An expert that a receiver keeps stays in its slot.
  • Both helper modes: per_layer_resident, and shared_banks, where all layers alternate between two banks and copy every helper every pass.
  • Helper sets without multicast objects. HALO-R's relay never stores through multicast, so its helper sets are allocated without multicast objects. This makes per-layer helper slots work at EP32: on DeepSeek-V4-Pro at EP32, binding the per-layer helper sets to multicast objects fails at startup with CUDA_ERROR_OUT_OF_MEMORY while most HBM is free. HALO-Q's helper sets are unchanged and keep their multicast objects, so HALO-Q still needs shared banks there.
  • Breakable prefill CUDA graphs. prefill_cuda_graph_backend: breakable captures the MoE layers, the HALO-R kernel included. Every layer call hands the device constant values, so replays need no host bookkeeping and eager calls and replays can be mixed:
    • READY is always 1, and each launch drains the previous READY row;
    • the route wait resets its counter after it passes.
    • HALO-R's route wait on MAIN is a stream memory operation on a counter that the HALO-R kernel raises on the copy stream. CUDA does not see that dependency. So the kernel records a launch completion event, which nominally triggers once every CTA has begun, and the route wait waits for that event first. In a captured graph this becomes an edge from the kernel's launch completion port to the wait, so no valid schedule of the graph can run the wait ahead of the kernel's launch. The relay can still overlap MAIN's work after the route release. The trigger is best effort: if CUDA defers it to the kernel's end, the wait comes later but stays correct. test_halo_r_relay.py checks the captured edge (graphs_route_wait_edge) and replays the graph in an adversarial serial order (graphs_serialized).
  • Reload reset. When the backend's weights are rebound, the residency table is cleared on every rank, and ranks that reset different layers stop with an error. MegaMoE-CuteDSL refuses hot weight reload today, so this is a safeguard for when it supports one.
  • Fail-closed traps. A HALO-R launch that cannot plan or route (a timeout waiting for a peer, an invalid route, a bad status word) stops the process with a CUDA error before any routes or helper weights it computed are used.
  • Config and docs.
    • planner: halo_q | halo_r, with HALO-R's limits checked on the config: at most 4 helper slots per rank, an even EP size from 2 to 32, at least 4 experts per rank, and auxiliary_sms from 2 to 16. HALO-R's auxiliary_sms defaults to 16, and HALO-Q's stays 4. Why 16 is both the default and the cap: see "Auxiliary SMs" under Performance.
    • The serve config schemas and the docs (examples/wide_ep/ep_load_balancer/README.md, MOE_DEVELOPER_GUIDE.md) are updated.

Design choices:

  • Why a unicast relay. Receivers split each replicated expert into slices. Each pulls its share from the owner and writes it to every receiver with ordinary NVLink loads and stores. Copy bandwidth then grows with the issuing CTAs and receivers, and the helper weights need no multicast stores.
  • Why READY. MegaMoE must not read a helper slot before its bytes have landed on every receiver. After a fence, the relay publishes one READY cell per rank. MegaMoE waits for it only before its first helper-slot tile, so token dispatch and resident-expert tiles start without waiting for the copy.
  • Why one fused kernel. Planning and copying in one launch per layer needs no host round trip and no second launch. A device-side route counter releases the routes to the main stream as soon as every CTA has mapped them, so the shared expert and MegaMoE's dispatch overlap the copy.

Changes to HALO-Q

HALO-R shares code with HALO-Q, so this PR edits HALO-Q's sources too. HALO-Q plans and copies as before; its behaviour changes on one error path, marked below.

  • Kernel.
    • HALO-Q's completion chain (last-CTA election and counter rearm), its READY publish and its fused-launch setup (kernel load and stack limit, shared-memory and occupancy sizing, the remote memory-sync domain) moved into moeRebalanceCompletion.cuh and moeRebalanceFusedLaunch.h, which moeRebalanceTma.cu now calls.
    • Its selected-route pass in moeRebalanceHaloQKernel.cuh is now a template, materializeCompactedSelectedRoutes, which HALO-Q and HALO-R instantiate with their own slot mapping. HALO-Q's mapping, HaloQSelectedRouteSlot, has camelCase members (groupBegins, groupSizes, owners, helperSlots, localSlots) and is built with designated initializers.
    • The TMA copy's await_slice waits through mbarrierWaitParityVolatile in cudaAsyncOps.cuh, the same volatile try_wait.parity poll with the same 32 ns backoff, which HALO-R's relay also uses.
  • Ops. moeRebalanceOpChecks.h holds the checks both planners' ops share. moeRebalanceHaloQOp.cpp takes its tensor and int32 checks from it, and moeRebalanceTmaOp.cpp its CUDA-result check and checkedInt. So the TMA op's int32 range error now reads "does not fit in int32" instead of "is outside the int32 range".
  • Lease (behaviour change). HALO-Q's copy endpoint, HierarchicalSamiWeightBroadcast, takes its lease bookkeeping from LiveBankLease (sami/lease.py), which HALO-R shares. A failed consumer cuStreamWaitEvent in release_generation_after now aborts HALO-Q's handoff for good (lease.py:104-108): every later call on that endpoint raises, and it cannot launch again. Before, the call only raised.
  • Python.
    • PER_LAYER_DYNAMIC_PLANNERS in per_layer_dynamic_eplb/registry.py maps each planner value to its group builder, held as a direct reference, and its capabilities. halo_q maps to build_rebalance_slot_scheduler_group. The manager and the layers read it; llm_args.py imports it lazily.
    • RebalanceSlotSchedulerGroup documents the hooks another planner may override. It builds its copy endpoint in _bind_copy_endpoint. _check_owner keeps the checks both planners share (closed group, device, MAIN) and hands a stream other than the bound MAIN to the _bind_main_stream hook. HALO-Q's version keeps binding MAIN once for life. It also declares forget_helper_residency, which the layer calls when a backend binds again (every standard load binds each layer twice); HALO-Q's is a no-op, and HALO-R's resets its helper residency.
    • HALO-Q's errors and timeout logs name the planner, and the startup info log names the planner and the helper-slot mode.
    • The auxiliary_sms field now accepts 1 to 16; a per-planner check keeps HALO-Q at 1 to 8 (default 4) and words its own rejection.
  • CI. jenkins/L0_MergeRequest.groovy adds three multi-GPU related paths: cpp/tensorrt_llm/thop/moe/loadBalance/ (both planners' ops), cpp/tensorrt_llm/kernels/cudaAsyncOps.cuh (now used by HALO-Q's and HALO-R's copies) and tests/unittest/_torch/moe/halo_r_reference.py (the reference test_halo_r_cases checks plans against). test_halo_q_cases runs HALO-Q's multi-GPU path on GB200 (see Test Coverage).
  • Run on this head: on one GB200 node with 4 GPUs, the build, the planner gtest moeRebalanceHaloRTest (15 of 15 pass), the four test_halo_r_cases and test_halo_q_cases entries of l0_gb200_multi_gpus.yml (21 + 1 pre-merge, 2 + 2 post-merge; 26 of 26 pass, none skipped) and the PR's CPU tests in eight files (433 of 433 pass). test_halo_r_traps: all three trap kinds pass, each in new ranks as single-node CI runs it. After the last change (forget_helper_residency declared on the base scheduler group), the final head ran again on one 4-GPU GB200 node: the three HALO-Q cases, the 21 pre-merge HALO-R cases and the four CPU files that cover the change all pass (130 of 130, none skipped).

Related PR. #21373 (HALO-Q performance, open) edits 8 of this PR's files: moeRebalanceHaloQKernel.cuh, moeRebalanceTma.cu, moeRebalanceTmaOp.cpp, cpp/tests/unit_tests/kernels/CMakeLists.txt, per_layer_dynamic_eplb/arena.py, sami/arena.py, sami/hierarchical.py and l0_gb200_multi_gpus.yml. That includes the HALO-Q code this PR moves into shared helpers, and #21373 adds its own per-set peer-chunk mapping next to this PR's peer_helper_bases. #20887 merges first; #21373 rebases onto it, as agreed with its author.

Performance on GB200

HALO-R against HALO-Q on DeepSeek-V4-Pro NVFP4 (61 layers) on MEGAMOE_CUTEDSL, with live routing on GSM8K prompts (high expert imbalance) and 4 helper slots per rank. Both planners ran an earlier revision of this PR with the current 2 × 3 × 32 KiB relay. The later review commits share helpers, rename code and reword messages; they were not re-measured.

Caveats:

  • Graphs against eager. HALO-R ran under breakable prefill CUDA graphs, at its defaults (auxiliary_sms 16, per_layer_resident). HALO-Q ran eager, because per-layer dynamic EPLB rejects prefill CUDA graphs with planner: halo_q, at its default auxiliary_sms of 4.
  • HALO-Q on shared banks at 32 GPUs. Its per_layer_resident default fails at startup there (multicast bind OOM, see "Helper sets without multicast objects"), so it ran shared_banks.
  • HALO-R is slower at 8 GPUs with 8K tokens per rank: 1.0206 with HALO-Q's copy free, 0.9878 with it charged.
  • No end-to-end numbers. The metric is GPU time per MoE layer; it does not count the host time that graphs save.
  • Runs. Both planners ran in one job per GPU count, on the same prompts. Each launch served 2K, then 8K tokens per rank, with max_num_tokens 8192. The 32-GPU runs had NCCL NVLS off.

Metric. Per-layer MoE GPU time on the last GPU to finish: from the router end, or the shared expert's FC12 start if earlier, to MegaMoE's reduce end, with host-wait gaps removed; the median over 12 forwards × 61 layers. Ratios are HALO-R ÷ HALO-Q, paired per layer and forward, with a bootstrap 95 % CI. Below 1, HALO-R is faster.

  • Copy free: HALO-Q's copy is charged only where it delays MegaMoE. In eager mode it can finish in host gaps.
  • Copy charged: all of HALO-Q's copy time after the router is added. This is an upper bound on HALO-Q without host gaps.
  • HALO-R's copy ended before MegaMoE's reduce on every rank, so it reads the same in both columns.
GPUs (EP) Tokens/rank HALO-Q helper mode µs per layer, HALO-R (graphs) / HALO-Q (eager) HALO-R ÷ HALO-Q, copy free HALO-R ÷ HALO-Q, copy charged
8 2K per_layer_resident 797.8 / 877.1 0.9395 [0.9064, 0.9565] 0.7447 [0.7126, 0.7640]
8 8K per_layer_resident 2462.4 / 2409.2 1.0206 [1.0157, 1.0263] 0.9878 [0.9707, 0.9992]
32 2K shared_banks 916.4 / 1216.3 0.7597 [0.7335, 0.7925] 0.5517 [0.5356, 0.5691]
32 8K shared_banks 2577.6 / 3161.4 0.8116 [0.7556, 0.8584] 0.7842 [0.7289, 0.8252]

At 32 GPUs, other comparisons (copy free, 2K / 8K):

At 8 GPUs, main's HALO-Q and this PR's HALO-Q are within 0.5 % of each other.

Auxiliary SMs. HALO-R's relay copies on the auxiliary SMs, one CTA each, and every auxiliary SM is one that the routed-input quantization and the fused shared-expert FC12 kernel leave free. HALO-R under graphs, per-layer time ÷ its time at 16 SMs:

GPUs (EP) Tokens/rank Helper mode 4 SMs 8 SMs 12 SMs
32 2K per_layer_resident 1.6204 [1.5799, 1.6549] 1.1751 [1.1550, 1.1909] 1.0558 [1.0424, 1.0661]
32 8K per_layer_resident 1.1505 [1.1266, 1.1799] 1.0208 [1.0101, 1.0381] 0.9983 [0.9949, 1.0007]
32 2K shared_banks 1.6497 [1.6200, 1.6793] — —
32 8K shared_banks 1.1825 [1.1623, 1.2047] — —
8 2K per_layer_resident 1.2190 [1.1979, 1.2396] — —
8 8K per_layer_resident 0.9903 [0.9874, 0.9931] — —
  • At 32 GPUs every step up to 16 SMs helps at 2K. At 8K, 12 and 16 tie.
  • A repeat of the 16-SM run in the same job gave 1.0001 at 2K and 1.0003 at 8K, so the differences above exceed the launch-to-launch spread.
  • Where copies are few (8 GPUs, 8K), 16 SMs cost 1 %.
  • Why the config stops at 16. The kernel itself takes 2 to 128 CTAs, capped by the SM count (kHaloRMaxCtas, moeRebalanceHaloR.h). The config admits 2 to 16. The relay should take as few SMs as possible, so that it does not impair the shared-expert computation running in parallel. 16 is the largest count we measured and nothing above it was tested, so the cap stays at 16 until a sweep above it.

Limitations / not in this PR:

  • Decode CUDA graphs: not supported. Per-layer dynamic EPLB keeps decode eager; only breakable prefill graphs are supported.
  • MTP: not covered. The DeepSeek-V4-Pro NVFP4 checkpoint's MTP experts are MXFP4, which MEGAMOE_CUTEDSL does not serve.
  • More than 32 GPUs: not supported. The HALO-R planner runs as one warp with one lane per EP rank and keeps rank sets in 32-bit masks (kMaxRanks = 32 in moeRebalanceHaloRPlanner.h), and moeRebalanceHaloR.cu asserts that this equals HALO-Q's own kMaxEp = 32. Lifting it needs a planner spread over more warps, with its per-rank state and rank masks widened, and HALO-Q's shared count-exchange and route passes widened with it.

Test Coverage

  • CPU unit tests (no GPU):
    • tests/unittest/_torch/moe/test_halo_r_planner.py covers the planner reference against worked examples and random routings, geometry validation, planner selection, and the rebind reset.
    • tests/unittest/_torch/moe/test_halo_r_contracts.py covers HALO-R's contract with HALO-Q's scheduler group, the kernel's trap and READY ordering, peer helper mappings, and residency reset ordering.
    • tests/unittest/_torch/moe/test_dynamic_eplb_contracts.py covers HALO-Q's endpoint as a LiveBankLease, including the abort after a failed consumer wait.
    • tests/unittest/llmapi/test_llm_args.py checks the config rejections and each planner's auxiliary_sms default on the config itself. test_trtllm_serve_config_schemas.py covers the serve schemas. usage/test_llmapi_config_capture.py checks that the telemetry manifest captures planner.
    • These files are marked cpu_only; l0_cpu.yml runs unittest/_torch/moe with -m cpu_only pre-merge, so they gate merges.
  • C++: cpp/tests/unit_tests/kernels/moe/moeRebalanceHaloRTest.cpp (gtest, registered with add_tllm_gtest) covers the planner and relay helpers.
  • Multi-GPU: tests/unittest/_torch/moe/multi_gpu/test_halo_r_relay.py.
    • test_halo_r_cases checks every launch's routes and every received helper row byte for byte against a host reference plan. Its cases cover:
      • reference plans on 4 and 16 auxiliary SMs and on a production-size bundle;
      • four helper slots per rank at 16 auxiliary SMs with per_layer_resident, HALO-R's defaults;
      • balanced and empty routing;
      • residency (repeats, random sequences, alternating layers, reload, stable slots) and shared banks;
      • READY gating under an SM hog;
      • breakable-graph capture and replay mixed with eager calls.
    • graphs_route_wait_edge, graphs_serialized (multi-GPU, EP8 across 2 nodes): pass. Without the launch completion edge, the edge check fails and the serialized replay deadlocks.
    • test_halo_q_cases runs the reference and two residency cases (reference, resident_sequence, resident_layers) with planner: halo_q. It checks each launch against the helper experts HALO-Q reports: every route goes to its owner's home slot or to a helper slot that holds its expert, every helper row holds its expert byte for byte, and READY and the status words are set.
    • test_halo_r_breakable_graph.py runs a small MoE model, two MegaMoE CuteDSL layers with planner: halo_r at its defaults, through BreakableCUDAGraphRunner as the decoder engine drives it: eager forwards checked against the NVFP4 reference and the helper-slot weights, warm-up and capture of two token buckets, replays with fresh inputs around an eager call, and a capture that fails inside the second layer's MoE call, after which that layer refuses to launch and the load balancer still shuts down.
    • test_halo_r_traps faults on purpose: a bad status word, a READY drain timeout, a grid rendezvous timeout. A trap leaves the ranks it ran on with a sticky CUDA error, so each kind needs new ranks: the test's MPIPoolExecutor starts new ones for every case, and under trtllm-llmapi-launch only the first trap kind of a pytest process runs and the others skip.
    • CI (l0_gb200_multi_gpus.yml):
      • pre-merge: test_halo_r_cases without its two repeat cases (21 cases: -k "not [graphs_single] and not [gate_under_hog]"), and test_halo_q_cases[halo_q_reference], each with TIMEOUT 10;
      • post-merge: the two repeat cases, graphs_single (one captured layer; three run pre-merge) and gate_under_hog (the eager hog at 4 CTAs; 16 CTAs run pre-merge), and the other two HALO-Q cases, each with TIMEOUT 10;
      • post-merge with ISOLATION: test_halo_r_traps (TIMEOUT 10), because it faults every GPU of the node. It runs only when named by node id, as there, or with HALO_R_TEST_TRAPS=1.
      • post-merge with ISOLATION: test_halo_r_breakable_graph.py (TIMEOUT 10, from its measured duration), so that its own exit timer, the last resort if it hangs, can end only its own process;
      • No test id in the list contains another, since jenkins/L0_Test.groovy files tests under isolation lines by substring.
  • Run on this head: on one GB200 node with 4 GPUs, the build, the planner gtest moeRebalanceHaloRTest (15 of 15 pass), the four test_halo_r_cases and test_halo_q_cases entries of l0_gb200_multi_gpus.yml (21 + 1 pre-merge, 2 + 2 post-merge; 26 of 26 pass, none skipped) and the PR's CPU tests in eight files (433 of 433 pass). test_halo_r_traps: all three trap kinds pass, each in new ranks as single-node CI runs it; under trtllm-llmapi-launch the first kind passes and the other two skip. Run as single-node CI runs them (one pytest process per entry, new ranks for every case), the five HALO-R and HALO-Q entries take 39.0 s to 337.6 s each (the 21 pre-merge HALO-R cases are the longest), which sizes their TIMEOUT at 10. After the last change (forget_helper_residency declared on the base scheduler group), the final head ran again on one 4-GPU GB200 node: the three HALO-Q cases, the 21 pre-merge HALO-R cases and the four CPU files that cover the change all pass (130 of 130, none skipped). test_halo_r_breakable_graph.py, run as single-node CI runs it on a GB200 node with 4 GPUs: 1 passed, none skipped, 47 s for the pytest process (23 s for the test itself); on the same node, under two negative controls (the abort of a layer whose capture failed removed; replays run eagerly) it fails with the expected assertion on all four ranks. The merge of main changes no file of this PR except where main also changed it (19 files; four hand-resolved conflicts, each keeping both sides).
  • Run beyond CI, on GB200:
    • Correctness at 4, 8 and 32 GPUs: the multi-GPU file's cases at EP4 (one node), and at EP8 and EP32 across nodes (reference, residency, shared banks and graphs). The traps ran at EP4 (all three kinds) and at EP8 (the status word).
    • Real-model output coherence on DeepSeek-V4-Pro (61 layers, natural routing). Each run is compared with a stock HALO-Q control, and on the same server with a deliberately broken-routing negative control that must produce garbled output:
      • at EP8: per-layer and shared helper slots, eager and breakable prefill graphs;
      • at EP32: per-layer helper slots, and shared banks with eager and breakable graphs.
    • Bitwise equivalence of the fused kernel's routes and helper rows with the original separate scheduler and relay kernels, at 2, 4 and 8 auxiliary SMs, at EP8 and EP32.
    • The pipelined relay copy ran the multi-GPU file's cases and all three traps at EP4, served DeepSeek-V4-Pro at EP32 with per-layer helper slots, and ran the performance runs above. The other runs above used the earlier copy loop.

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • 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.

Dev Engineer Review

HALO-R adds a second planner for per-layer dynamic EPLB. The planner option defaults to halo_q. Setting halo_r selects the new planner and its relay-copy path. The change adds planner logic, a fused CUDA kernel, relay work mapping, Torch operators, and helper-residency handling.

Configuration validation and schemas define HALO-R limits: even EP size from 2 to 32, at most 4 helper slots per rank, at least 4 home experts per rank, and auxiliary_sms from 2 to 16 (default 16). HALO-Q keeps auxiliary_sms at most 8 (default 4). Breakable prefill CUDA graphs are allowed only for HALO-R. Decode CUDA graphs remain disabled.

Risk areas for review:

  • Stream ordering and route waits in captured graphs.
  • Collective reuse authority and release state in the shared lease code.
  • Helper-residency reset on same-backend rebinding.
  • Failure propagation. Native setup failures are shared across EP ranks. Kernel timeouts and status errors trap before routes or READY are published.
  • Helper multicast is disabled for HALO-R. Arena code now accepts planes without multicast aliases, so verify that multicast destinations appear only when every plane has an alias.
  • The shared planner.py and hierarchical.py refactors affect HALO-Q. Confirm HALO-Q behavior is unchanged.
  • The moeRebalanceHaloQKernel.cuh refactor moves selected-route materialization behind a callback. Confirm the HALO-Q mapping and failure status location are preserved.

No completed build, test, or CI results were supplied for the current head.

QA Engineer Review

Test files changed:

  • Added: tests/unittest/_torch/moe/test_halo_r_planner.py, tests/unittest/_torch/moe/test_halo_r_contracts.py, tests/unittest/_torch/moe/halo_r_reference.py (reference support module), tests/unittest/_torch/moe/multi_gpu/test_halo_r_relay.py, cpp/tests/unit_tests/kernels/moe/moeRebalanceHaloRTest.cpp.
  • Modified: tests/unittest/_torch/moe/test_per_layer_dynamic_eplb.py, tests/unittest/_torch/moe/test_dynamic_eplb_contracts.py, tests/unittest/llmapi/test_llm_args.py, tests/unittest/llmapi/test_trtllm_serve_config_schemas.py, tests/unittest/usage/test_llmapi_config_capture.py, cpp/tests/unit_tests/kernels/CMakeLists.txt, tests/integration/test_lists/test-db/l0_gb200_multi_gpus.yml.
  • Removed: none.

Test functions and selectors:

  • test_halo_r(monkeypatch, case) in test_halo_r_relay.py. Covers relay copies, scheduler outputs, residency, graph replay and capture failures, stream ordering, and weight reloads. Selector test_halo_r is listed in l0_gb200_multi_gpus.yml pre-merge with a 45-minute timeout.
  • test_halo_r_traps(monkeypatch, request, kind) in test_halo_r_relay.py. Opt-in trap cases inject status, READY, or grid-rendezvous failures. Selector test_halo_r_traps is listed in the post-merge section of l0_gb200_multi_gpus.yml with a 45-minute timeout and isolation. Its node-level behavior is documented as intentionally faulting every GPU on the node.
  • CPU contract and planner tests cover planner balancing, helper limits, route conservation, geometry, residency, native-op schemas, and HALO-Q versus HALO-R differences.
  • Host C++ gtest moeRebalanceHaloRTest covers planner output, route slots, and relay work assignment.
  • LLM-args and schema tests cover planner defaults, auxiliary_sms limits per planner, CUDA-graph compatibility, and runtime-to-schema default consistency.

Coverage verdict: sufficient for the listed GB200 multi-GPU selectors and the added CPU and host tests. Test-run results are not available in the supplied evidence. No manual-QA list entry (qa/) was found.

Per-File QA Perspective

Build and C++ kernel sources

  • cpp/tensorrt_llm/kernels/moe/loadBalance/dynamicEplb/CMakeLists.txt: Builds HALO-R sources for SM100, SM103, or SM107 with CUDA 13.1 or newer. Otherwise, selects placeholder sources. Verify both paths.
  • moeRebalanceHaloR.cu: Adds the fused HALO-R kernel and launch code. Verify status handling, relay completion, route-counter updates, and READY publication under failure.
  • moeRebalanceHaloR.h: Adds public status, counter, parameter, and launch declarations. Verify callers respect parameter bounds.
  • moeRebalanceHaloRPlanner.h: Adds planner, plan layout, helper assignment, and route-slot selection. Verify determinism, helper limits, and error statuses against the reference planner.
  • moeRebalancePlaceholder.cpp: Adds HALO-R stubs for unsupported builds. Verify that calls fail with the intended error (exception for query and prepare functions, cudaErrorNotSupported for launch).
  • moeRebalanceRelay.cuh: Adds relay copy with bulk, 16-byte, 4-byte, and byte fallback paths. Verify coverage and completion across destinations, planes, and alignments.
  • moeRebalanceRelayWork.h: Adds relay destination, slice, plane, and item mapping. Covered by the host C++ test.
  • moeRebalanceCompletion.cuh: Adds shared last-CTA, counter rearm, and READY publish helpers. Verify fence and ordering behavior for both HALO-Q and HALO-R.
  • moeRebalanceFusedLaunch.h: Adds shared kernel load, occupancy sizing, and remote-sync-domain helpers. Verify that errors propagate and that a device with fewer than two sync domains returns zero.
  • moeRebalanceTma.cu: Switches TMA fused path to the shared completion and launch helpers. Verify HALO-Q TMA behavior is unchanged, including the cold stream synchronization in helper-residency initialization.
  • moeRebalanceHaloQKernel.cuh: Extracts selected-route materialization with a callback. Verify HALO-Q slot mapping and unmapped-status recording are preserved.
  • cudaAsyncOps.cuh: Adds mbarrier_arrive_expect_tx_no_state, a no-op below SM 9.0. Verify the no-op path on older architectures.

Torch bindings

  • cpp/tensorrt_llm/thop/moe/loadBalance/moeRebalanceHaloROp.cpp: Adds HALO-R state and operators for create, handle, submit, wait, join, counters, and destroy. Verify tensor validation, stream synchronization, and poisoned-state failure after CUDA errors.
  • moeRebalanceOpChecks.h: Adds shared tensor, CUDA result, and int range checks. Verify checks reject non-CUDA, wrong-dtype, noncontiguous, and undersized tensors.
  • moeRebalanceHaloQOp.cpp: Uses shared checks in place of local helpers. Verify HALO-Q validation messages still identify the routes device.
  • moeRebalanceTmaOp.cpp: Uses the shared checkCudaResult. Behavior should be unchanged.

Build and CI scripts

  • jenkins/L0_MergeRequest.groovy: Treats cpp/tensorrt_llm/thop/moe/loadBalance/ as multi-GPU-related for changed-file detection. Verify that changes in this directory trigger the intended multi-GPU jobs.

Python runtime

  • tensorrt_llm/_torch/moe/fused_moe/per_layer_dynamic_eplb/halo_r_planner.py: Adds geometry validation, relay endpoint, and HALO-R scheduler group. Verify collective reuse authority, route waits, stream joins, and residency reset.
  • per_layer_dynamic_eplb/layer.py: Selects the scheduler from the planner spec and resets helper residency on same-backend rebinding. Verify that HALO-Q rebinding is not affected.
  • per_layer_dynamic_eplb/manager.py: Adds planner validation (default halo_q), planner representation, and passes helper_multicast to arena providers. Verify unsupported planner values are rejected.
  • per_layer_dynamic_eplb/arena.py: Adds helper_multicast mode, peer helper mapping, and READY initialization for base or hierarchical arenas. Verify both modes.
  • per_layer_dynamic_eplb/planner.py: Parameterizes spin-bound planner name, adds _bind_copy_endpoint, and adds a generic builder. Verify HALO-Q routing and generation behavior is unchanged.
  • per_layer_dynamic_eplb/__init__.py: Documentation-only change in the package docstring.
  • tensorrt_llm/_torch/moe/kernels/megamoe_scheduler/sami/lease.py: Adds LiveBankLease, event_handle, and generation release rules. Verify that a failed consumer wait aborts the handoff.
  • megamoe_scheduler/sami/hierarchical.py: HierarchicalSamiWeightBroadcast now inherits LiveBankLease. Verify that removed reuse-authority methods have no remaining callers.
  • megamoe_scheduler/sami/arena.py: LivePlaneView.mc_view is optional. Verify that bind works without MC aliases and that multicast destinations are created only when every plane has an alias.
  • tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py: Registers fake implementations for HALO-R submit, wait, and join. Verify signatures match the native operators.
  • tensorrt_llm/_torch/models/modeling_deepseekv4.py: Comment-only change. It clarifies that the fused shared-expert path is unavailable during decode CUDA-graph use.

Configuration and schemas

  • tensorrt_llm/llmapi/llm_args.py: Adds planner (default halo_q, values halo_q and halo_r). Raises auxiliary_sms upper bound to 16. Adds HALO-R geometry and graph validation. Verify defaults and accepted graph backends.
  • tensorrt_llm/schemas/trtllm-serve-config.schema.json: Adds planner and conditional auxiliary_sms rules. Verify schema acceptance matches runtime.
  • tensorrt_llm/schemas/trtllm-serve-disagg-config.schema.json: Same change as the serve schema, with updated descriptions. Verify consistency with the serve schema.
  • scripts/generate_trtllm_serve_schemas.py: Generates the planner-dependent auxiliary_sms constraints. Verify the generated output matches the checked-in schemas.
  • tensorrt_llm/usage/llm_args_golden_manifest.json: Captures planner as a categorical value. Verify both literals are accepted.

Documentation

  • examples/wide_ep/README.md: Lists planner as a per-layer option. Verify consistency with runtime validation.
  • examples/wide_ep/ep_load_balancer/README.md: Documents HALO-R limits and graph behavior. Verify limits match runtime validation.
  • tensorrt_llm/_torch/moe/fused_moe/MOE_DEVELOPER_GUIDE.md: Documents HALO-R residency, graph ordering, and forget_helper_residency. Verify against implementation.
  • docs/source/features/parallel-strategy.md: Documents that per-layer dynamic EPLB runs without decode CUDA graphs and supports breakable prefill graphs with HALO-R. Documentation only.

Test-list configuration

  • tests/integration/test_lists/test-db/l0_gb200_multi_gpus.yml: Adds test_halo_r (pre-merge, 45-minute timeout) and test_halo_r_traps (post-merge, 45-minute timeout, isolated). Verify the trap case runs only on its intended node.

Test code

  • tests/unittest/_torch/moe/multi_gpu/test_halo_r_relay.py: Multi-GPU relay, scheduler, residency, and trap tests. test_halo_r is listed in CI. Verify skip behavior on unsupported geometry.
  • tests/unittest/_torch/moe/test_halo_r_planner.py: CPU planner and geometry tests. Not listed in the supplied test-list evidence.
  • tests/unittest/_torch/moe/test_halo_r_contracts.py: CPU contract tests with fakes. Not listed in the supplied test-list evidence.
  • tests/unittest/_torch/moe/halo_r_reference.py: Python planner reference used by tests. Test support only.
  • tests/unittest/_torch/moe/test_per_layer_dynamic_eplb.py: Expects planner=halo_q in the manager representation. Not listed.
  • tests/unittest/_torch/moe/test_dynamic_eplb_contracts.py: Tests HierarchicalSamiWeightBroadcast as a LiveBankLease subclass, a consumer-wait failure, and the planner name in the spin bound. Not listed.
  • tests/unittest/llmapi/test_llm_args.py: Covers planner defaults, auxiliary_sms limits, geometry, and CUDA-graph compatibility. Not listed.
  • tests/unittest/llmapi/test_trtllm_serve_config_schemas.py: Schema-to-runtime checks for planner and auxiliary_sms. Not listed.
  • tests/unittest/usage/test_llmapi_config_capture.py: Adds moe_config.load_balancer.planner to expected captured paths. Not listed.
  • cpp/tests/unit_tests/kernels/CMakeLists.txt: Registers moeRebalanceHaloRTest with a 120-second timeout. Verify it runs in the host kernel-test workflow.
  • cpp/tests/unit_tests/kernels/moe/moeRebalanceHaloRTest.cpp: Host unit tests for planner, route slots, and relay work. C++ test, not in Python lists.

_capture sets layers.eager, and four graph cases read it after their
_capture call. _Layers.__init__ now declares the attribute, as it does
starved_copy_stream for the hog cases, so the class names every attribute
the cases use. Clears five missing-attribute diagnostics in the Pyrefly
report on this PR; the tests behave the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
@itamar-rauch

Copy link
Copy Markdown
Collaborator Author

/bot run --add-multi-gpu-test --extra-stage "GB200-4_GPUs-PyTorch-Post-Merge-1,GB200-4_GPUs-PyTorch-Post-Merge-2" --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88368 [ run ] triggered by Bot. Commit: b4858df Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88331 [ run ] completed with state ABORTED. Commit: d64c42a

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88368 [ run ] completed with state SUCCESS. Commit: b4858df
/LLM/main/L0_MergeRequest_PR pipeline #73376 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

Brings the branch up to NVIDIA/TensorRT-LLM main 203e14f. One file conflicted:
- scripts/generate_trtllm_serve_schemas.py: in _serve_schema, both sides added names to the llm_args import; kept both, this branch's HALO-Q/HALO-R auxiliary_sms bounds and main's cold-page option sets, in sorted order.

Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
@itamar-rauch

Copy link
Copy Markdown
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88490 [ reuse-pipeline ] triggered by Bot. Commit: fed67f5 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88490 [ reuse-pipeline ] completed with state SUCCESS. Commit: fed67f5
Reusing PR_Github #88368 for commit fed67f5

Link to invocation

@itamar-rauch
itamar-rauch added this pull request to the merge queue Dec 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 1, 2026
Brings the branch up to NVIDIA/TensorRT-LLM main, which now includes NVIDIA#21373
(HALO-Q' planner). Ten files conflicted; both sides are kept:
- moeRebalanceHaloQKernel.cuh: HALO-Q's slot of a selected route reads the plan
  fields through plan_field_offset.
- moeRebalanceTma.cu: the remote memory-sync domain helper, then main's cluster
  attribute; the helper (moeRebalanceFusedLaunch.h) now takes any launch
  attribute array of at least two entries.
- arena.py: main's pair and team objects, peer helper chunks and per-layer
  helper-set limits apply to pools with helper multicast (HALO-Q); HALO-R's
  pools keep none of them.
- llm_args.py, registry.py, manager.py: breakable prefill CUDA graphs are
  accepted for both planners. HALO-Q joins main's parent MoE graph and needs its
  8192-token bucket under attention DP; HALO-R keeps capturing its layer calls
  in the runner's own segments (uses_parent_moe_graph is False).
- layer.py, planner.py, hierarchical.py, the guide, the README and the tests:
  both sides; the test that HALO-Q rejects breakable prefill graphs is removed.
  The HALO-R tests follow main's _create_sets signature and its shared_banks
  default for helper_slot_mode.

Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
…fill rule in the schema

An unset helper_slot_mode is shared_banks with planner halo_q, the field
default, and per_layer_resident with planner halo_r, which keeps HALO-R's
helper experts resident per layer. validate_planner_auxiliary_sms resolves it,
in the same way it resolves auxiliary_sms. A value the user sets is kept, and
a resolved default stays out of model_fields_set.

The serve schemas mirror this with a halo_r default for helper_slot_mode. They
also apply the 8192-token bucket and attention-DP rule for breakable prefill
only to planners that join the parent MoE graph, as
validate_per_layer_dynamic_eplb_cuda_graph does, so a HALO-R config without
them stays valid. The guide and the HALO-R README section state the
per-planner default; tests cover both planners and an unset planner.

Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
@itamar-rauch

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88623 [ run ] triggered by Bot. Commit: ed2a985 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88623 [ run ] completed with state SUCCESS. Commit: ed2a985
/LLM/main/L0_MergeRequest_PR pipeline #73608 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

@itamar-rauch

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

Brings the branch up to NVIDIA/TensorRT-LLM main 39a2b29. One file
conflicted:
- jenkins/L0_MergeRequest.groovy: in getMultiGpuFileChanged, both sides added a
  path after thop/allreduceOp.cpp; kept both, this branch's
  thop/moe/loadBalance/ and main's thop/phasedFmha, in sorted order.

Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
jenkins/UpdateTestDurations.groovy regenerates this file from CI's measured
times and pushes it to main. Each run drops hand-added entries, and each
made the next merge of main into this branch conflict. Keep main's copy.
Until the HALO-R test-db entries have measured times, pytest-split estimates
each one at the mean known duration; that changes shard balance only, not
which tests run.

Signed-off-by: Itamar Rosenfeld Rauch <irauch@nvidia.com>
@itamar-rauch

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88709 [ run ] triggered by Bot. Commit: e1c1131 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88709 [ run ] completed with state SUCCESS. Commit: e1c1131
/LLM/main/L0_MergeRequest_PR pipeline #73688 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

⚠️ Resource Maintenance — Test Coverage Reduced:

Resource maintenance in LLM/main/L0_Test-x86_64-Single-GPU #11158: AWS-PDX-SLURM-1 is unavailable for maintenance on 2026-12-02 17:00-23:00 UTC; H100_PCIe-PyTorch-Perf-1 was retired from main.
Affected stages:
DGX_B300-PyTorch-1
DGX_B300-PyTorch-2
DGX_B300-PyTorch-3
DGX_B300-PyTorch-4

Resource maintenance in LLM/main/L0_Test-x86_64-Multi-GPU #3344: AWS-PDX-SLURM-1 is unavailable for maintenance on 2026-12-02 17:00-23:00 UTC; H100_PCIe-PyTorch-Perf-1 was retired from main.
Affected stages:
DGX_B300-4_GPUs-PyTorch-1
DGX_B300-2_GPUs-2_Nodes-PyTorch-Disagg-PerfSanity-FUNCTIONAL-ONLY-1

Link to invocation

@itamar-rauch
itamar-rauch added this pull request to the merge queue Dec 2, 2026
Merged via the queue into NVIDIA:main with commit ed9650f Dec 3, 2026
15 checks passed
@itamar-rauch
itamar-rauch deleted the halo-r-relay branch December 3, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agent Code Review: High Risk api-compatible Accepted LLM API contract change that is backwards-compatible ci: full pre-merge approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.