fix(pt): select device before loading torch ops#5612
Conversation
Preselect the CUDA/HIP device from the rank-local GPU before PyTorch CUDA queries or torch custom-op loading can create a default-device context. This avoids each MPI rank leaving an unused context on GPU 0 in multi-GPU LAMMPS runs. Fixes deepmodeling#4171 Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5) Signed-off-by: njzjz-bot (driven by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5))[bot] <48687836+njzjz-bot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughA new inline helper ChangesGPU Preselection Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5612 +/- ##
==========================================
- Coverage 81.98% 81.98% -0.01%
==========================================
Files 959 959
Lines 105430 105423 -7
Branches 4071 4069 -2
==========================================
- Hits 86442 86426 -16
- Misses 17518 17528 +10
+ Partials 1470 1469 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Need a real test on a machine with multiple GPUs. |
Summary
DeepPotPT,DeepSpinPT,DeepTensorPT,DeepPotPTExpt,DeepSpinPTExpt) to call this helper beforedeepmd::load_op_library().Verification
git diff --check HEAD~1..HEADpreselect_torch_deviceprecedesdeepmd::load_op_library()in all touched PT init paths.Fixes #4171
Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
Summary by CodeRabbit