Repository navigation
Conversation
added 9 commits
November 28, 2026 08:40
Step 1 of removing GlobalC::restart (the last GlobalC member): move the EXX restart output off GlobalC::restart onto a new INPUT parameter. - Add out_mat_exx (Boolean) to gate Hexx(R) CSR output; embeds E_exx in the description line of the cell-aware CSR header so no separate Eexx file is written. - write_Hexxs_csr: accept eexx, enable csr_format (cell-aware header) and reduce=true (rank 0 only writes), pass ucell and description_suffix. - read_Hexxs_csr: accept double& eexx and parse it from the description line of the _0.csr file; csrFileReader gains description_/getDescription(). - CsrTextHeader / SparseWriteOptions gain an optional description_suffix field so any CSR writer can append scalar metadata to its header line; all existing aggregate-initialization call sites are updated. - exx_lri_interface write side switches the trigger from GlobalC::restart.info_save.save_H to PARAM.inp.out_mat_exx, drops the rank prefix and the standalone Eexx save_disk call. - Read side (exx_hamilt2rho, op_exx_lcao) keeps GlobalC::restart for now and only adapts to the new function signatures; full migration to init_exx=file is step 2. Verified: incremental build (make -j30) passes; agent_governance_check.py --staged reports only allowed warnings (global-dep net delta -6; docs are generated from source metadata via docs/.gitignore).
…(option B) Make the Hexx(R) CSR write in the final SCF output path (ctrl_scf_lcao) obey the new out_mat_exx switch instead of out_chg, so all HexxR output is controlled solely by out_mat_exx. Also pass the real Eexx energy (pelec->f_en.exx) instead of 0.0, and emit the running-log notice (write_matrix_notice) required by governance rule 16. To keep the exx_iter_finish write site (in exx_lri_interface) free of new global dependencies, thread std::ofstream& ofs_running explicitly through ctrl_iter_lcao -> exx_iter_finish; esolver_ks_lcao feeds GlobalV::ofs_running at the call boundary. Governance: agent_governance_check.py --staged reports one allowed-exception ERROR (net global-dep delta +1): the single GlobalV::ofs_running read added in esolver_ks_lcao.cpp to source the log stream. This is not control flow but an output stream, esolver_ks_lcao already reads GlobalV::ofs_running in 12 places, and the pattern has an accepted precedent in esolver_dfpt_pw.cpp (see the "one GlobalV::ofs_running read added for the dyn-file writer log" comment). PR will need the governance-exception-approved label. Docs (parameters.yaml / input-main.md) are generated from the source Input_Item metadata per docs/.gitignore; verified present via --generate-parameters-yaml. Verified: incremental build (make -j30) passes.
Step 2 of removing GlobalC::restart: migrate the EXX Hexx(R) read side
off GlobalC::restart onto the new INPUT parameter init_exx = file.
- Add init_exx (String, default "none"; "file" reads Hexx(R) + E_exx).
- op_exx_lcao: read HexxR_{is}.csr from read_file_dir instead of
GlobalC::restart.folder; drop the legacy cereal fallback; stop with a
clear error when the CSR file is missing; report the parsed E_exx back
to Exx_LRI_Interface via set_hexx_loaded() instead of writing the
GlobalC::restart.info_load.load_H_finish flag.
- read_Hexxs_csr: E_exx in the CSR description line is now mandatory; a
file written without out_mat_exx aborts with a diagnostic.
- Exx_LRI_Interface: replace load_H_finish/restart_exx global flags and
the separate Eexx disk file with members hexx_loaded_/eexx_loaded_/
restart_exx_; Eexx now comes from the CSR header (divided by
hybrid_alpha as before). XC type selection and the once-per-run guard
use these members.
- Exx_NAO::need_load_hexx(inp) centralizes the "load Hexx from file now?"
decision (including the MD/relax one-shot guard); the three ESolver
call sites (esolver_ks_lcao, lcao_others, esolver_double_xc) use it,
removing their GlobalC::restart reads.
Behavior note: legacy restart_load no longer reloads Hexx (it still reads
the charge density); the affected restart case is migrated in step 3.
Governance: agent_governance_check.py --staged passes with net global-dep
delta -16 (only allowed warnings). Docs are generated from the source
Input_Item metadata; init_exx verified present via --generate-parameters-yaml.
Verified: incremental build (make -j30) passes.
HexxR is fully replicated on every rank, but save_sparse was called with options.reduce = true. That flag not only gates the write to rank 0: it also all-reduces (SUM) the per-R non-zero counts and the matrix rows across ranks. With np >= 2 the written nnz and values were therefore doubled (e.g. 744 non-zeros for a 26x26 matrix), which made csrFileReader fail with "Malformed CSR block" and corrupted the matrix for init_exx = file. Use options.reduce = false and call save_sparse only on DRANK == 0, so the replicated matrix is written once without any MPI aggregation. Verified with a Si2 HSE two-stage run (np = 2): stage A writes nnz <= 676 with the same E_exx; stage B with init_exx = file reads HexxR back and reproduces the first-loop E_exx exactly (-0.8344808984 Ry). Governance: agent_governance_check.py --staged reports one allowed ERROR (net global-dep delta +1) for the GlobalV::DRANK rank gate in write_Hexxs_csr; this mirrors the existing DRANK gate inside save_sparse and is an IO-layer rank check, not control flow.
Remove the legacy restart_save/restart_load parameters, the GlobalC::restart population in input_conv, and the PW RT-TDDFT check for restart_load. Migrate tests/03_NAO_multik/scf_in_restart to the standard init_chg = file mechanism. Docs are generated from Input_Item metadata, so docs/parameters.yaml and docs/input_main.md need no manual edit (allowed exception: documentation sync review).
…aths (step 5) Drop the now-unreachable charge restart load/save code and the legacy k-space Hexx loader whose writer was removed in step 1. The init_exx = file HexxR path is unchanged. No documentation change is needed: this step removes only dead code and does not alter any INPUT parameter or supported behavior (allowed exception: documentation sync review).
Delete the Restart class and its GlobalC namespace now that charge restart uses init_chg = file and EXX restart uses init_exx = file. Drop the corresponding build-list entries and the includes added only for load_exx_flag. No new tests or docs are needed: this step only deletes dead code, and tests/03_NAO_multik/scf_in_restart (migrated in step 4) still passes with the rebuilt binary (allowed exceptions: test evidence and documentation sync review).
Rename the out_mat_exx output from HexxR_{is}.csr to hrs{is}_exx.csr
(1-based spin index) and route it through the shared CSR writer, so it
honours out_freq_ion and out_app_flag like the other out_* files.
- out_mat_exx now accepts an optional precision: 'out_mat_exx 1 <prec>'
(default 16), applied to both the matrix and the embedded E_exx.
- Drop the duplicate, frequency-uncontrolled write in exx_iter_finish;
ctrl_scf_lcao is now the only writer.
- init_exx = file reads hrs{is}_exx.csr and rejects multi-frame files so
an appended ionic-step sequence is never silently read as frame one.
- Add an autotest check comparing hrs1_exx.csr / hrs2_exx.csr in
scf_hse_spin2_gamma.
Governance exceptions: the global-dependency warnings are moves of
existing PARAM/GlobalV uses in op_exx_lcao (net_delta = -3); docs are
generated from Input_Item metadata, which is updated here.
Move the out_mat_exx writer from ctrl_scf_lcao (end of SCF) into exx_iter_finish and gate it with the legacy timing (two_level_step > 0 || istep > 0) && (!separate_loop || iter == 1), so hrs{is}_exx.csr is refreshed during the run as before. out_freq_ion and out_app_flag are still honored.
Update scf_hf_multik to restart from chg.cube + hrs1_exx.csr and refresh result.ref.
Governance exceptions (allowed): global dependency budget net +6 because the writer needs out_mat_exx/out_freq_ion/out_app_flag/global_out_dir inside Exx_LRI_Interface; documentation sync because this only changes the write timing of an existing output, not INPUT semantics.
Keep the deletion of source/source_io/module_restart/restart.cpp: upstream only changed auto to ssize_t, while this branch removes the Restart class and GlobalC::restart.
11 tasks
The optional description_suffix member was declared with a default member initializer, which under the C++11 baseline makes CsrTextHeader a non-aggregate. The four brace-initialized call sites (write_dmr.cpp, hsr_writer.cpp, dhs_sparse_writer.cpp, pos_op_csr.cpp) then fail to compile in CI with "could not convert ... from '<brace-enclosed initializer list>'". Drop the default member initializer so the struct stays an aggregate; every call site already passes an explicit value for the field. Verified with: cmake --build build_max_para_test --target abacus_max_para -j 8 Governance note: the checker reports a test-evidence warning and a docs-sync warning, both marked "Exception allowed: yes". This is a compile-fix for an already covered code path; no behavior or INPUT metadata changes, so no test or documentation update is required.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #8435
Summary
Remove
GlobalC::restart— the last production member of theGlobalCnamespace —and replace the implicit restart singleton with explicit INPUT/OUTPUT:
out_mat_exx 1 [precision]writes the EXX Hamiltonian in real space ashrs{is}_exx.csr(rank-independent CSR,E_exxembedded in the header).init_exx = fileloadshrs{is}_exx.csrfor the first SCF loop;init_chg = file(+read_file_dir) loads the restart charge.Restartclass,namespace GlobalC { GlobalC::restart }, and therestart_save/restart_loadINPUT parameters.Closes # (remove
GlobalC).What changed
EXX restart output
out_mat_exx(Boolean [Integer]): flag plus precision (default 16).hrs1_exx.csr,hrs2_exx.csr, ... (1-based spin) withE_exxon theheader line; this replaces the old
HexxR_{is}.csrplus separateEexxfile.out_freq_ionandout_app_flag(0 = overwrite, 2 = per-step numbering).restart cadence, so a valid restart snapshot exists while the SCF is running.
EXX restart input
init_exx = file: loads the CSR Hexx(R) viaExx_NAO::need_load_hexx;multi-frame (append-mode) files are rejected with a clear error.
init_chg = file(
*-CHARGE-DENSITY.restart, falling back tochg.cube).Removals
restart_save,restart_loadINPUT parameters and theirInput_Itemmetadata.Restartclass,restart.cpp/restart.h,GlobalC::restart.chg_init.cpp,ctrl_iter_lcao.cpp,op_exx_lcao.*).Makefile.Objectsandsource_io/CMakeLists.txtsynchronized.Tests
tests/03_NAO_multik/scf_in_restart: migrated fromrestart_loadtoinit_chg = file(+autotest-CHARGE-DENSITY.restartinput).tests/08_RI/scf_hf_multik: now restarts fromchg.cube+hrs1_exx.csr;result.refregenerated.tests/08_RI/scf_hse_spin2_gamma: compareshrs1_exx.csr/hrs2_exx.csragainst reference files (
CompareEXX1_pass,CompareEXX2_pass).Migration
restart_save 1out_mat_exx 1restart_load 1init_chg file+init_exx file+read_file_dir <dir>Testing
abacus_max_parabuilds cleanly.scf_hse_spin2_gamma: 6/6, includingCompareEXX1_passandCompareEXX2_pass.scf_hf_multik: converges and matches the regeneratedresult.ref.E_exxis reproduced exactly when read back.Notes
init_exx = fileexpects a single-frame file; useout_app_flag = 0or2forrestart files.
out_freq_ion > 0, the final off-cadence ionic step no longer has thelast_ion_stepfallback, because that flag is not threaded intoexx_iter_finish.commit messages.