Skip to content

[TRTLLM-13628][test] Optimize MoE comm test execution - #15662

Merged
QiJune merged 1 commit into
NVIDIA:mainfrom
sunnyqgg:trtllm-moe-0725
Jul 6, 2026
Merged

[TRTLLM-13628][test] Optimize MoE comm test execution#15662
QiJune merged 1 commit into
NVIDIA:mainfrom
sunnyqgg:trtllm-moe-0725

Conversation

@sunnyqgg

@sunnyqgg sunnyqgg commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Optimize MoE communication unit test execution by grouping same-backend workloads while keeping backend coverage explicit.
  • Reduce host-side verification overhead by pipelining worker execution and reusing compatible communication objects inside each worker.
  • Fix the MoE comm combine reference to ignore padded receive rows and handle NVFP4 scale underflow in the low-precision reference path.

Changes

  • tests/unittest/_torch/modules/moe/test_moe_comm.py: restructure MoE communication test case generation and grouped execution.
  • tests/unittest/_torch/modules/moe/test_moe_comm.py: add valid receive-row filtering for combine reference accumulation.
  • tests/unittest/_torch/modules/moe/test_moe_comm.py: make low-precision combine reference precomputed on worker GPUs and guard NVFP4 scale underflow.

Test plan

  • pre-commit run --files tests/unittest/_torch/modules/moe/test_moe_comm.py
  • NCCL_NVLS_ENABLE=0 python3 -u -m pytest -q -s tests/unittest/_torch/modules/moe/test_moe_comm.py::TestMoEComm::test_moe_comm[NVLinkTwoSided_ep4_n18] --tb=short --disable-warnings --durations=0 passes: 1 passed in 48.72s pytest time.
  • NCCL_NVLS_ENABLE=0 python3 -u -m pytest -q -s tests/unittest/_torch/modules/moe/test_moe_comm.py::TestMoEComm::test_moe_comm --tb=short --disable-warnings --durations=0 passes: 8 passed in 351.73s pytest time.

@sunnyqgg

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@sunnyqgg sunnyqgg changed the title [None][test] Optimize MoE comm test execution [TRTLLM-13628][test] Optimize MoE comm test execution Jun 26, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56061 [ run ] triggered by Bot. Commit: f7ebf1b Link to invocation

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This test module now groups MoE communication configs, caches worker communication objects, carries tensor-decoded routing data through dispatch verification, and rewrites combine-reference calculations with vectorized masking and low-precision simulation.

Changes

MoE communication test harness

Layer / File(s) Summary
Shared helpers and routing codec
tests/unittest/_torch/modules/moe/test_moe_comm.py
CommTestGroup and PendingWorkerResults are added, source-info encoding/decoding uses tensor views, simple_moe becomes vectorized, and support checks are cached.
Worker comm reuse
tests/unittest/_torch/modules/moe/test_moe_comm.py
Worker comm objects are cached by reuse key, low-precision reference outputs are precomputed, and worker failures clear cached comm state.
Dispatch verification and combine refs
tests/unittest/_torch/modules/moe/test_moe_comm.py
Dispatch verification reads worker-provided decoded routing tensors, and combine-reference paths use guarded NVFP4 math with masked index_add_ accumulation.
Grouped parameter generation
tests/unittest/_torch/modules/moe/test_moe_comm.py
Static feasibility filtering and grouped pytest parameters are added for boundary, non-divisible-EP, and post-quant test cases.
Group-aware test runner
tests/unittest/_torch/modules/moe/test_moe_comm.py
Test methods now take CommTestGroup, and the runner batches submission and verification across configs in each group.

Sequence Diagram(s)

sequenceDiagram
  participant TestMoEComm
  participant run_group as _run_full_test_group
  participant mpi_pool_executor
  participant get_comm as _get_worker_comm
  participant prepare_ref as _prepare_moe_output_for_combine_reference
  participant verify_results as _verify_full_test_results
  TestMoEComm->>run_group: run CommTestGroup
  run_group->>mpi_pool_executor: submit worker futures for grouped configs
  mpi_pool_executor->>get_comm: execute worker pipeline with cached comm
  get_comm->>prepare_ref: prepare low-precision reference payload
  run_group->>verify_results: verify drained worker results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 95.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is specific, concise, and matches the main change: optimizing MoE communication test execution.
Description check ✅ Passed The description covers Summary, Changes, and Test plan, but it omits the template's PR Checklist section.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/_torch/modules/moe/test_moe_comm.py`:
- Line 1682: The loop in the boundary case iteration uses an unused variable
that triggers Ruff B007. Update the tuple unpacking in the test loop to either
rename case_id to _case_id or remove it from the boundary_cases payload, keeping
the logic in test_moe_comm unchanged.
- Around line 1808-1814: The helper `_drain_pending_results` is swallowing all
exceptions from `Future.result()` without any visibility, which hides drained
worker failures. Update this loop to avoid silent broad exception handling:
either catch the specific exception types you expect from worker futures or, if
broad catching is required, log the exception with a clear rationale before
continuing. Keep the behavior of draining pending work, but make failures
observable for diagnosis.
- Around line 1827-1838: The low-precision combine tolerance branch in
test_moe_comm.py is too broad because the current else after config.comm_type ==
COMM_NVLINK_ONE_SIDED also captures DeepEPLL cases. Tighten the branching around
verify_combine_results so the NVFP4 atol logic only applies to the
NVLinkTwoSided path, and keep DeepEPLL handled by its own explicit tolerance
path within the same low_precision combine test flow. Use the existing
config.comm_type checks and the verify_combine_results call site to preserve
backend-specific coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 846e6a61-04dd-4615-9530-52bd09190158

📥 Commits

Reviewing files that changed from the base of the PR and between 86bb1f4 and f7ebf1b.

📒 Files selected for processing (1)
  • tests/unittest/_torch/modules/moe/test_moe_comm.py

Comment thread tests/unittest/_torch/modules/moe/test_moe_comm.py
Comment thread tests/unittest/_torch/modules/moe/test_moe_comm.py
Comment thread tests/unittest/_torch/modules/moe/test_moe_comm.py
@sunnyqgg
sunnyqgg requested a review from xxi-nv June 26, 2026 09:57
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@sunnyqgg

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56285 [ run ] triggered by Bot. Commit: f7ebf1b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56285 [ run ] completed with state SUCCESS. Commit: f7ebf1b
/LLM/main/L0_MergeRequest_PR pipeline #45138 completed with status: 'SUCCESS'

CI Report

Link to invocation

@xxi-nv xxi-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.

Thanks for the great optimization and please help to address the comments from codderabbitai.

Comment thread tests/unittest/_torch/modules/moe/test_moe_comm.py
Signed-off-by: qgai <qgai@nvidia.com>
@sunnyqgg

sunnyqgg commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57303 [ run ] triggered by Bot. Commit: 5df5134 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57303 [ run ] completed with state FAILURE. Commit: 5df5134
/LLM/main/L0_MergeRequest_PR pipeline #46062 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

@xxi-nv

xxi-nv commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57680 [ run ] triggered by Bot. Commit: 5df5134 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57680 [ run ] completed with state SUCCESS. Commit: 5df5134
/LLM/main/L0_MergeRequest_PR pipeline #46400 completed with status: 'SUCCESS'

CI Report

Link to invocation

@QiJune
QiJune merged commit f5a1f54 into NVIDIA:main Jul 6, 2026
7 checks passed
BrianLi23 pushed a commit to BrianLi23/TensorRT-LLM that referenced this pull request Jul 9, 2026
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.

4 participants