Skip to content

Conversation

@roccomoretti
Copy link
Contributor

@roccomoretti roccomoretti commented Nov 10, 2025

What does this PR do?

Depending on precise install conditions, mpi4py may be installed without MPI being present, which can cause an ImportError. ("cannot import name 'MPI' from 'mpi4py'").

Catch that case in the detect() function of the MPI plugin, and treat it as if mpi4py is not installed.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • [n/a] Did you make sure to update the documentation with your changes? (if necessary)
  • [n/a] Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21353.org.readthedocs.build/en/21353/

Depending on precise install, mpi4py may be installed without `MPI`  being present. Catch that case in the detect() function,
and treat it as if mpi4py is not installed.
@github-actions github-actions bot added the fabric lightning.fabric.Fabric label Nov 10, 2025
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87%. Comparing base (c76cec6) to head (c432e9f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21353   +/-   ##
=======================================
- Coverage      87%      87%   -0%     
=======================================
  Files         269      269           
  Lines       23796    23799    +3     
=======================================
+ Hits        20617    20618    +1     
- Misses       3179     3181    +2     

@justusschock
Copy link
Member

@roccomoretti , thanks for this PR. Could you please add a section to the Changelog?

@roccomoretti
Copy link
Contributor Author

@justusschock Where is the Changelog? There doesn't seem to be a changelog.md or the like in the root directory, nor is there any link or mention of the changelog in the contributor guidelines.

@justusschock
Copy link
Member

@roccomoretti apologies for being less clear. I'll also update the contributor guidelines. For fabric (where you updated things) it's here: https://github.com/Lightning-AI/pytorch-lightning/blob/master/src/lightning/fabric/CHANGELOG.md

@deependujha
Copy link
Collaborator

Hi @roccomoretti, I believe it makes sense to add a brief comment on why this try-except block is required here, for future reference.

@deependujha deependujha merged commit 8ac4843 into Lightning-AI:master Nov 19, 2025
124 of 125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fabric lightning.fabric.Fabric

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants