Skip to content

refactor(ao): remove Parallel_Orbitals implicit upcast - #8290

Merged
mohanchen merged 41 commits into
deepmodeling:developfrom
kirk0830:pr/04-composition-guard
Nov 5, 2026
Merged

mohanchen merged 41 commits into
deepmodeling:developfrom
kirk0830:pr/04-composition-guard

Conversation

@kirk0830

@kirk0830 kirk0830 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the transitional implicit conversion from Parallel_Orbitals to const Parallel_2D&.
  • Migrate remaining const-passing call sites to explicit para_2d() access.
  • Stop test fixtures from writing distribution/descriptor fields directly; use set_serial, set, and read-only getters instead.
  • Add a composition regression guard covering getter equivalence, derived-state consistency, and value semantics in serial and MPI builds.

Behavior

No INPUT, output-format, numerical, or public workflow behavior changes. Documentation is not required because this is an internal ownership/interface cleanup.

Verification

Run with abacus-dev/1.0, GNU 11.4.0, and OMP_NUM_THREADS=1:

cmake --build build -j 8
ctest --test-dir build -R "^MODULE_AO_parallel_orbitals|^MODULE_LCAO_hcontainer|^MODULE_IO_hs_dense_io|^MODULE_IO_hsr_writer|^MODULE_IO_write_dmr|^MODULE_LCAO_deltaspin_spin_constrain|^MODULE_HSOLVER_LCAO" --output-on-failure
python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
git diff --check upstream/develop...HEAD
  • Full CPU+MPI+LCAO+BUILD_TESTING build: [100%].
  • Focused serial/MPI tests: 100% tests passed, 0 tests failed out of 17.
  • Governance: 0 blocking findings; one local PR-body documentation warning.
  • Diff check: clean.
  • CI will cover optional CUDA/LibRI/MLALGO configurations unavailable in this local build.

Auto-merge is intentionally disabled; merge remains a manual decision.

kirk0830 and others added 30 commits October 28, 2026 06:34
Purely additive: no call site changes, inheritance still in place.
para_2d() (const + non-const) returns *this while Parallel_Orbitals derives
from Parallel_2D, giving the two escape hatches a const getter cannot serve
(LR_Util::setup_2d_division mutation, test-side descriptor writes).
get_blacs_ctxt() completes the inherited getter family, which covers the
other seven public data members.
…bitals, migrate module_operator_lcao call sites
… (getter-equiv, derived-layer sync, value-semantics static_assert, MPI+serial dual coverage)
…d-inheritance

# Conflicts:
#	source/source_esolver/esolver_ks_lcao_tddft.cpp
#	source/source_hamilt/module_gint/gint_dvlocal.cpp
…tion-guard

# Conflicts:
#	source/source_basis/module_ao/test/CMakeLists.txt
#	source/source_basis/module_ao/test/parallel_orbitals_test.cpp
#	source/source_io/module_hs/unittests/CMakeLists.txt
#	source/source_io/test/CMakeLists.txt
#	source/source_lcao/module_dftu/unittests/CMakeLists.txt
#	source/source_lcao/module_rt/test/CMakeLists.txt
Resolve the single conflict in output_mulliken.cpp by keeping the upstream
extraction of collect_MW_nspin4 (deepmodeling#8250, which also corrects the noncollinear
M_y sign) instead of the pre-extraction inline loop carried on this branch,
then migrate the helper's accessor calls to the explicit para_2d() distribution
now that Parallel_Orbitals no longer inherits Parallel_2D.
…cessor

The noncollinear Mulliken test added by deepmodeling#8250 sets up a serial layout on a
Parallel_Orbitals and sizes its ComplexMatrix from the distribution's row and
column counts. `set_serial`, `nrow` and `ncol` belong to Parallel_2D, which
Parallel_Orbitals no longer inherits, so route both uses through para_2d().
Without this the test target does not compile on top of current develop.
Replace the PR#TBD placeholders with the actual condition for deleting para_2d()
and the implicit `operator const Parallel_2D&`, and record that the eventual
accessor name carries no get_ prefix, which is the convention this repository
follows. Comment text only.
…s test

Repository rule 11 requires one test TU per exercised source file: the new
test_parallel_orbitals_composition.cpp did not match any source file, while
parallel_orbitals_test.cpp already exercises ../parallel_orbitals.cpp. Move
its four guard cases, the two fixture helpers, and the compile-time
static_asserts into the existing file, and delete the extra source, its
MODULE_AO_parallel_orbitals_composition_test target plus _para MPI
registration, and its runner script.

No assertion was changed, weakened, or dropped: every static_assert and every
EXPECT_/ASSERT_ line from the deleted file appears verbatim in the merged
file (verified with a line-by-line set difference). The merged binary still
runs 5 gtest cases (TestParaO.Divide2D + the 4 composition cases) and passes
both the serial and the mpirun 2/3/4-rank ctest registrations.
Route optional LCAO backends through the explicit Parallel_Orbitals distribution. This covers CUDA, DeePKS, LibRI/EXX, BSE, RDMFT, RPA, cuBLASMp, and the PEXSI test fixture without changing the composition seam.
…tion-guard

# Conflicts:
#	source/source_basis/module_ao/parallel_orbitals.h
#	source/source_hsolver/unittests/test_diago_pexsi.cpp
…n-guard

# Conflicts:
#	source/source_basis/module_ao/parallel_orbitals.h
#	source/source_basis/module_ao/test/parallel_orbitals_test.cpp
#	source/source_hamilt/module_hcontainer/test/test_hcontainer.cpp
#	source/source_hamilt/module_hcontainer/test/test_hcontainer_complex.cpp
#	source/source_hamilt/module_hcontainer/test/test_hcontainer_output.cpp
#	source/source_hsolver/unittests/test_diago_pexsi.cpp
#	source/source_io/module_ctrl/ctrl_scf_lcao.cpp
#	source/source_io/module_dm/test/test_write_dmr.cpp
#	source/source_io/module_hs/unittests/csr_test_helpers.h
#	source/source_io/module_hs/unittests/test_hsr_writer.cpp
#	source/source_io/unittests/test_write_wfc_nao.cpp
#	source/source_lcao/module_bse/bse_util.cpp
#	source/source_lcao/module_deltaspin/test/spin_constrain_test.cpp
@kirk0830
kirk0830 requested a review from AsTonyshment November 4, 2026 13:19

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One non-blocking suggestion for the new move test. Static review only; no builds or tests were run.

@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Nov 5, 2026
@mohanchen
mohanchen merged commit d697a20 into deepmodeling:develop Nov 5, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants