Skip to content

Commit

Permalink
Perf: print summary on rank 0 (#4434)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Adjusted the summary printing functionality to ensure it only executes
from the main process in distributed settings, preventing duplicate
outputs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
caic99 authored Nov 27, 2024
1 parent 4a45fe5 commit 4b92b6d
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions deepmd/pt/utils/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,21 @@ def print_summary(
name: str,
prob: list[float],
) -> None:
print_summary(
name,
len(self.systems),
[ss.system for ss in self.systems],
[ss._natoms for ss in self.systems],
self.batch_sizes,
[
ss._data_system.get_sys_numb_batch(self.batch_sizes[ii])
for ii, ss in enumerate(self.systems)
],
prob,
[ss._data_system.pbc for ss in self.systems],
)
rank = dist.get_rank() if dist.is_initialized() else 0
if rank == 0:
print_summary(
name,
len(self.systems),
[ss.system for ss in self.systems],
[ss._natoms for ss in self.systems],
self.batch_sizes,
[
ss._data_system.get_sys_numb_batch(self.batch_sizes[ii])
for ii, ss in enumerate(self.systems)
],
prob,
[ss._data_system.pbc for ss in self.systems],
)


_sentinel = object()
Expand Down

0 comments on commit 4b92b6d

Please sign in to comment.