deepmodeling / deepmodeling/tbplas

[Code scan] Avoid re-reducing accumulated Lindhard q-point output inside MPI loops

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
19
Forks
6
PR merge metrics
No merged PRs in 30d

Description

This issue comes from a Codex global scan of deepmodeling/tbplas at commit 4d3652b3dba8eb930e4869a6d41074f62d703692.

Severity: High

`calc_dyn_pol_regular()` and `calc_dyn_pol_arbitrary()` allocate one `dyn_pol` array for all q-points, then call `self.all_reduce(dyn_pol)` inside each q-point loop. With MPI and more than one q-point, rows computed in earlier iterations have already been globally reduced on every rank. Reducing the whole accumulated array again in later iterations scales those earlier q-point rows by the MPI size repeatedly.

Code references:
https://github.com/deepmodeling/tbplas/blob/4d3652b3dba8eb930e4869a6d41074f62d703692/tbplas/diagonal/lindhard.py#L383-L412
https://github.com/deepmodeling/tbplas/blob/4d3652b3dba8eb930e4869a6d41074f62d703692/tbplas/diagonal/lindhard.py#L472-L501

Suggested fix: reduce only the current q-point slice, or keep a local output buffer through the loop and call `all_reduce` once after all q-points are filled.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read tbplas/diagonal/lindhard.py at calc_dyn_pol_regular() lines 383-412 and calc_dyn_pol_arbitrary() lines 472-501. Trace how dyn_pol is allocated and how all_reduce is called during the q-point loops. Done means MPI runs with multiple q-points no longer re-reduce rows computed in earlier iterations, while all q-point output remains correctly accumulated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, hpc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.