Skip to content

test(autotest): document and tidy the 02_NAO_Gamma cases - #8441

Open
mohanchen wants to merge 13 commits into
deepmodeling:developfrom
mohanchen:2026-11-28-line1-b
Open

mohanchen wants to merge 13 commits into
deepmodeling:developfrom
mohanchen:2026-11-28-line1-b

Conversation

@mohanchen

Copy link
Copy Markdown
Collaborator

Summary

Cleanup of tests/02_NAO_Gamma, as the first directory in the integration-test
governance effort. Two commits, no change to solver behaviour or reference data.

Changes

Consolidate out_wfc_lcao coverage

Seven cases in this directory set out_wfc_lcao=1, but only scf_out_wf and
012_NO_GO_MD_OW carried a wavefunction reference, and six of the seven were
disabled in CI. The directory now keeps a smaller, asserted set:

  • Removed 010_NO_GO_RE_OW, 011_NO_GO_RE_OW2, 013_NO_GO_MD_OW2: no reference
    files at all, disabled in CI, so they verified nothing.
  • Removed scf_out_wf_spin2: no nspin=2 wavefunction reference exists anywhere in the
    repository and the case was disabled. This leaves nspin=2 out_wfc_lcao uncovered;
    it needs a new case with a generated reference rather than an unasserted one.
  • Renamed 012_NO_GO_MD_OW to md_out_wfc, kept result.ref and
    wf_nao.txt.ref, set out_app_flag 1 explicitly, fixed the README (it said three
    MD steps, md_nstep is 2) and enabled the case in both CASES_CPU.txt and
    CASES_GPU.txt.
  • Dropped the stray test.sum entries from both case lists.

Documentation and registry hygiene

  • Added the missing README for md_out_hk_spin2, md_out_hk_syns, relax_out_hk,
    relax_out_hk_spin2, scf_FeBiTe, scf_out_dh and scf_tzdp_spin2; every case in
    the directory now has a one- or two-line description.
  • Converted scf_pcc0d_water/README.md and scf_pcc2d_water/README.md to plain
    README and shortened the three SCCS descriptions to two lines without dropping the
    notes about force assembly, solvation terms or reference conditions.
  • Fixed two typos (implicit, option) and reflowed the get_pchg README.
  • Recorded why entries are disabled: genelpa requires device==cpu, and the legacy
    DFT+U projection path is not validated on GPU.
  • Removed a duplicate #scf_metagga line from CASES_GPU.txt; scf_metagga stays
    enabled, so behaviour is unchanged.
  • Renamed scf_u_spin2_old to scf_u_spin2_dftu2 (it covers dft_plus_u=2, the legacy
    projection on first-zeta NAOs) and scf_si2_tzdp_neq_spin2_gpu to scf_tzdp_spin2.
    The latter no longer pins device gpu or ks_solver cusolver; the GPU CI already
    rewrites device to gpu for this directory, and scalapack_gvx is available on
    both devices, so the case now runs on CPU and GPU like the rest of 02_NAO_Gamma.
    It is registered in CASES_CPU.txt as well.

Verification

Static checks only; no local ABACUS build was available.

  • All 43 case directories have a README, none longer than two lines.
  • Every entry in CASES_CPU.txt / CASES_GPU.txt resolves to an existing directory
    and appears at most once.
  • No case enabled in CASES_GPU.txt uses genelpa, which would conflict with the
    device gpu rewrite performed by the GPU workflow.
  • No case in the directory pins device any more except scf_upf100 (device cpu),
    which the GPU workflow overwrites; left untouched here.

Risk and follow-up

  • scf_tzdp_spin2 keeps the result.ref generated with cusolver. It now runs with
    scalapack_gvx on CPU as well, so the reference needs one confirmation run
    (bash ../integrate/Autotest.sh -a <abacus> -r '^scf_tzdp_spin2$') and possibly a
    regeneration.
  • scf_upf100 still sets device cpu; it is harmless because CI rewrites it, but it
    is the last device pin in the directory and should be removed in a follow-up.

Part of #

abacus_fixer added 2 commits November 28, 2026 20:38
- Remove 010_NO_GO_RE_OW, 011_NO_GO_RE_OW2 and 013_NO_GO_MD_OW2: they ship
  no reference files and are disabled in CI, so they verify nothing.
- Remove scf_out_wf_spin2: no nspin=2 wavefunction reference exists in the
  repository and the case was disabled in CI.
- Rename 012_NO_GO_MD_OW to md_out_wfc, keeping result.ref and
  wf_nao.txt.ref; set out_app_flag=1 explicitly, correct the README
  (md_nstep=2) and enable the case in CASES_CPU.txt and CASES_GPU.txt.
- Drop the stray test.sum entries from both case lists.
- Add the missing README for seven cases and normalize the two README.md
  files to plain README; every case now has a one- or two-line
  description.
- Shorten the SCCS README files to two lines without dropping the notes
  about force assembly, solvation terms and reference conditions.
- Fix two typos (implicit, option) and reflow the get_pchg README.
- Record why cases are disabled: genelpa requires device==cpu, and the
  legacy DFT+U projection is not validated on GPU.
- Rename scf_u_spin2_old to scf_u_spin2_dftu2 and scf_si2_tzdp_neq_spin2_gpu
  to scf_tzdp_spin2. The latter no longer pins device or cusolver, so it
  runs on both CPU and GPU like the rest of the directory, and it is now
  registered in CASES_CPU.txt as well.
- Drop the duplicate #scf_metagga entry from CASES_GPU.txt; scf_metagga
  stays enabled.
@mohanchen mohanchen added Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests Solve before 3.11 labels Nov 28, 2026
abacus_fixer added 2 commits November 28, 2026 22:16
Band coefficients written by out_wfc_lcao are not unique: bands that share
an eigenvalue may be mixed by any unitary matrix, and the mixing chosen by
the eigensolver depends on the solver library and on the MPI process grid.
The element-wise comparison in props_cube.sh therefore rejected physically
identical runs, e.g. md_out_wfc at 4 ranks (CPU CI) and at 2 ranks (GPU CI),
where the eigenvalues agree to machine precision but the coefficients of the
degenerate bands differ by up to 1.4.

Add compare_wfc_nao.py, which compares rotation-invariant quantities for the
gamma-only path: band energies, occupations, and the projector
sum_b f_b c_b(i)c_b(j) of every degenerate group (the unweighted projector is
used when the occupations inside a group differ). The multi-k path keeps the
existing magnitude-based comparison because its *_mod.txt.ref references use
a different layout.

Verified: md_out_wfc passes at 1, 2 and 4 ranks (previously only at 4); a
unitary rotation inside a degenerate group changes the projector by 2e-16,
a 0.05 coefficient change by 9.7e-2; a perturbed reference is still reported
as a failure end-to-end.
…on GPU

The reference files of md_out_wfc predate deepmodeling#6821, which set nbands 6,
ecutwfc 10 and md_nstep 2; the case was disabled in CI, so nobody noticed.
The reference expected 8 bands and an etot of -183.664 eV, the current input
produces 6 bands and -196.625 eV.

Regenerate result.ref and wf_nao.txt.ref with the current input, and register
the case in CASES_GPU.txt now that the wave-function comparison is invariant
under degenerate-band rotations. Also restore the alphabetical order of the
scf_* entries in that list.

@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.

The Gamma wavefunction oracle has three paths that can accept invalid output, and the case rename leaves a stale Slurm entry; the inline comments give the source evidence and suggested corrections.

Non-blocking: the description still says there are no reference changes and lists only static checks, but this head adds the comparator and replaces both MD references. Please update it with the executable/revision, commands and rank/device settings for the runs reported in the later commits. Those reported runs and the refreshed numerical values were not independently validated here.

Static review only; no builds or runtime tests were run.

if not frame["eig"]:
raise ValueError("%s: band energy before a band header"
% path)
frame["eig"][-1] = float(text.split()[0])

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.

[P2] Reject non-finite wavefunction data

A NaN calculated band energy passes the later abs(...) > tol check, while NaN projector differences never update worst, so invalid output can return success. The previous CompareFile.py explicitly rejected non-finite values. Please validate every energy, occupation and coefficient with a finite-value check and retain negative fixtures for this failure path.

weighted = (max(occs) - min(occs)) <= EQUAL_OCC_TOL
block = [[0.0] * norb for _ in range(norb)]
for band in group:
weight = frame["occ"][band] if weighted else 1.0

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.

[P2] Keep assertions for unoccupied wavefunctions

Occupation weighting makes every zero-occupation group produce a zero matrix regardless of its coefficients. In scf_out_wf, bands 2-4 have zero occupation, so replacing their coefficient vectors with zeros would still pass; the previous comparison rejected that corruption. Please compare an occupation-independent subspace invariant for every group and add a negative fixture for an altered empty-band wavefunction.

gamma_only 1
ks_solver cusolver
device gpu
ks_solver scalapack_gvx

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.

[P2] Update the Slurm consumer of this renamed case

.ci/slurm/config.ini still selects scf_si2_tzdp_neq_spin2_gpu for case.008. Its worker copies that directory directly, so the rename breaks staging. Please update the configured name and use autotest_gpu (or an explicit equivalent GPU setting): the current autotest runner does not rewrite device, and this shared INPUT no longer pins it to GPU.

frame = frames[-1]
if text.endswith("(number of orbitals)"):
frame["norb"] = int(text.split()[0])
elif text.endswith("(band)"):

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.

[P2] Validate the serialized band identifiers

This branch ignores the numeric identifier, so repeated or zero-based (band) labels compare equal when the remaining records match. read_wfc_nao.cpp requires each label to equal its 1-based position and rejects such files. Please validate the identifier sequence and add a negative fixture, so the output regression cannot pass a file its consumer refuses to read.

@@ -0,0 +1 @@
test H(R)/S(R) output in append mode during MD, gamma-only and nspin=2

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.

Non-blocking: these four out_hk cases set out_mat_hs, which writes H(k)/S(k) at Gamma. H(R)/S(R) uses the separate out_hsr/out_mat_hs2 path. Please correct the matrix labels here and in md_out_hk_syns, relax_out_hk and relax_out_hk_spin2 so the descriptions identify their actual coverage.

@@ -0,0 +1 @@
Vacuum PCC 0D regression with assume_isolated pcc_0d; checks total energy, forces and E_pcc

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.

Non-blocking: the deleted PCC READMEs recorded references generated with two MPI ranks and one OpenMP thread; the shortened SCCS README also loses its reference-rank note. Please retain this historical provenance in a short second line or a shared note, so future numerical comparisons can identify the reference conditions.

abacus_fixer added 9 commits November 29, 2026 15:01
…ma GPU CI

- Drop the explicit 'ks_solver genelpa' from scf_FeBiTe/INPUT so the
  device-dependent default selects genelpa on CPU and cusolver on GPU,
  matching the other LCAO GPU cases.
- Add a per-case threshold of 1e-6 eV for scf_FeBiTe: the cusolver and
  genelpa total energies differ by 2e-7 eV on a -22413 eV reference.
- Enable scf_FeBiTe and scf_u_spin2_dftu2 in CASES_GPU.txt, in the same
  order as CASES_CPU.txt.
- Record the real blockers for the remaining CPU-only cases: pcc_0d and
  pcc_2d require device==cpu, and SCCS requires CPU KS-DFT.
- Move scf_out_dh in CASES_GPU.txt to the same position as CASES_CPU.txt.
- Write scf_FeBiTe/threshold as 0.000001, matching the other per-case
  threshold files.
- Drop the explicit 'device cpu' from scf_upf100/INPUT and rely on the
  default plus the GPU CI injection, like the other cases.

Verified on build_max_gpu_test/abacus_max_gpu: scf_FeBiTe and scf_upf100
pass on GPU, and scf_upf100 passes on CPU with the default device.
- Enable scf_u_ramp, scf_symm_prec, scf_deltaspin2, scf_deltaspin4 and
  scf_gga_grad2_spin4 in CASES_GPU.txt, keeping the CASES_CPU order.
- Drop the explicit 'ks_solver genelpa' from scf_u_ramp and scf_symm_prec
  so the device-dependent default selects genelpa on CPU and cusolver on
  GPU; drop the explicit 'device cpu' from scf_deltaspin4.
- Fix inaccurate READMEs (wrong nspin, k mesh, pseudopotential), complete
  the out_chg/out_pot, DOS and restart descriptions, and correct typos.
- Condense the five long regression READMEs to three lines each and add
  the four missing READMEs.
- Remove the unreferenced 99_SCF_DPSIN example directory.

Verified with build_max_gpu_test/abacus_max_gpu: the full 70-case
CASES_GPU.txt passes (715 property checks); the two genelpa cases also
pass on CPU with -n 4.
Drop the explicit cusolver/device gpu so the case follows the default
solver for each device, list it in both CASES_CPU.txt and CASES_GPU.txt,
and update the Slurm GPU matrix case name and its unit test.

Verified with build_max_gpu_test/abacus_max_gpu on CPU (-n 4) and GPU (-n 2).
The check needs external wannier90.x/postw90.x, so keep the fixture and
the add_test() registration next to check_wannier_spn.py instead of the
03_NAO_multik Autotest suite. The script now resolves the fixture
relative to itself, and source/CMakeLists.txt registers the interface
directory under BUILD_TESTING.
Rename scf_in_dmr_Si_spin2_hasbug to scf_in_dmr_Si_spin2, add the two
DMR restart inputs and the regenerated reference, and enable the case in
both CASES_CPU.txt and CASES_GPU.txt.

Verified with build_max_gpu_test/abacus_max_gpu: CPU (-n 4) and GPU (-n 2)
both pass; the total energies differ by 3.4e-13 eV.
out_dmr now selects the DM(R) output format: 0 off, 1 csr text, 2 npz. The optional second value remains the text precision for format 1. out_dm_npz is kept as a deprecated alias mapped to out_dmr 2, with out_dmr taking precedence when both are set. Update the ctrl_scf_lcao output branches, INPUT docs, unit tests, validation scripts and the npz autotest to use out_dmr 2.
Return -1 when the binary dimension cannot be read so the compiler no longer warns about the ignored std::fread result.
out_dmr format 2 now writes dmrs{spin}_nao.npz with a one-based spin index, matching the basename of the csr files written by format 1. out_app_flag=2 inserts the one-based g{step} suffix; because npz cannot append frames, out_app_flag=1 keeps a fixed name and overwrites it. Update the ESolver_DM2rho reader, the validation script and the INPUT documentation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes Solve before 3.11 Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants