Skip to content

[None][fix] Better error message for mismatched MPI world size#11294

Open
jthomson04 wants to merge 2 commits intoNVIDIA:mainfrom
jthomson04:jthomson04/mpi-mismatch-world-size-segfault
Open

[None][fix] Better error message for mismatched MPI world size#11294
jthomson04 wants to merge 2 commits intoNVIDIA:mainfrom
jthomson04:jthomson04/mpi-mismatch-world-size-segfault

Conversation

@jthomson04
Copy link
Collaborator

@jthomson04 jthomson04 commented Feb 4, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced validation for multi-device distributed training configurations. The system now verifies MPI world size requirements upfront and provides clear error messages when the requested configuration exceeds available resources, preventing downstream failures.

If the mpi world size TRTLLM launches into is smaller than the tensor_parallel_size, you get a segfault like this:

  !!!!!!! Segfault encountered !!!!!!!                                                                                                                                                                                                                                                                                                                                  
    File "../ompi/group/group.h", line 405, in ompi_group_get_proc_name                                                                                                                                                                                                                                                                                                 
    File "dpm/dpm.c", line 1268, in ompi_dpm_group_is_dyn                                                                                                                                                                                                                                                                                                               
    File "dpm/dpm.c", line 1299, in ompi_dpm_mark_dyncomm                                                                                                                                                                                                                                                                                                               
    File "communicator/comm.c", line 215, in ompi_comm_set_nb                                                                                                                                                                                                                                                                                                           
    File "communicator/comm.c", line 116, in ompi_comm_set                                                                                                                                                                                                                                                                                                              
    File "communicator/comm.c", line 1205, in ompi_comm_create_group                                                                                                                                                                                                                                                                                                    
    File "/build-result/src/hpcx-v2.25.1-gcc-inbox-ubuntu24.04-cuda13-x86_64/ompi-ad48c462ffb305748641c267af6c1be683fd73ef/ompi/mpi/c/profile/pcomm_create_group.c", line 78, in PMPI_Comm_create_group                                                                                                                                                                 
    File "src/mpi4py.MPI.c", line 111198, in __pyx_pf_6mpi4py_3MPI_4Comm_26Create_group                                                                                                                                                                                                                                                                                 
    File "src/mpi4py.MPI.c", line 111091, in __pyx_pw_6mpi4py_3MPI_4Comm_27Create_group                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in PyObject_Vectorcall                                                                                                                                                                                                                                                                                                                    
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in PyObject_CallOneArg                                                                                                                                                                                                                                                                                                                    
    File "<unknown>", line 0, in _PyObject_GenericGetAttrWithDict                                                                                                                                                                                                                                                                                                       
    File "<unknown>", line 0, in PyObject_GetAttr                                                                                                                                                                                                                                                                                                                       
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in PyObject_Call                                                                                                                                                                                                                                                                                                                          
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in PyObject_Call                                                                                                                                                                                                                                                                                                                          
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in _PyObject_Call_Prepend                                                                                                                                                                                                                                                                                                                 
    File "<unknown>", line 0, in _PyObject_MakeTpCall                                                                                                                                                                                                                                                                                                                   
    File "<unknown>", line 0, in _PyEval_EvalFrameDefault                                                                                                                                                                                                                                                                                                               
    File "<unknown>", line 0, in __clone                                                                                                                                                                                                                                                                                                                                
    File "<unknown>", line 0, in 0xffffffffffffffff                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                        
  /code/tensorrt_llm/.venv-3.12/bin/trtllm-llmapi-launch: line 129:  7806 Segmentation fault      (core dumped) python3 -m tensorrt_llm.llmapi.mgmn_leader_node                                                                                                                                                                                                         
  Rank0 MGMN leader node exit code: 139                                                                                                                                                                                                                                                                                                                                 

This MR checks the MPI world size in advance to provide a clearer error message.

RuntimeError: Mapping requires world_size=2 (tp_size=2 * pp_size=1 * cp_size=1), but MPI world size is only 1.

Description

Test Coverage

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)

  • 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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@jthomson04 jthomson04 requested a review from a team as a code owner February 4, 2026 22:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Added runtime validation in MPIDist initialization to ensure that the MPI world size encompasses the requested mapping.world_size when ENABLE_MULTI_DEVICE is True. Raises RuntimeError if the mapping exceeds available MPI world capacity, preventing creation of invalid sub-communicators.

Changes

Cohort / File(s) Summary
MPI World Size Validation
tensorrt_llm/_torch/distributed/communicator.py
Added precondition check during MPIDist construction to validate that mapping.world_size does not exceed MPI world size in multi-device scenarios. Imported mpi_world_size utility and raises RuntimeError with diagnostic details (tp_size, pp_size, cp_size) if validation fails.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR provides context about the issue with a segfault example and the intended solution, but omits critical required sections including a proper PR title following the template format, detailed description of the solution, and test coverage information. Add a properly formatted PR title following [type] convention, expand the Description section with clear explanation of the fix, and document relevant test cases or explain why no new tests are needed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding better error handling for MPI world size mismatches.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@jthomson04
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #34854 [ run ] triggered by Bot. Commit: 7f6a78a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #34854 [ run ] completed with state SUCCESS. Commit: 7f6a78a
/LLM/main/L0_MergeRequest_PR pipeline #26891 completed with status: 'FAILURE'

⚠️ 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

Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
@jthomson04 jthomson04 force-pushed the jthomson04/mpi-mismatch-world-size-segfault branch from 2108a89 to 472c3f9 Compare February 5, 2026 06:09
@jthomson04
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #34922 [ run ] triggered by Bot. Commit: 472c3f9

@tensorrt-cicd
Copy link
Collaborator

PR_Github #34922 [ run ] completed with state SUCCESS. Commit: 472c3f9
/LLM/main/L0_MergeRequest_PR pipeline #26940 completed with status: 'FAILURE'

⚠️ 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

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.

2 participants