Repository navigation
refactor(input): replace fixed-value resets with shared requirements - #8495
Open
Stardust0831 wants to merge 14 commits into
Open
Stardust0831 wants to merge 14 commits into
Stardust0831 wants to merge 14 commits into
Conversation
Stardust0831
marked this pull request as draft
December 3, 2026 00:17
Stardust0831
marked this pull request as ready for review
December 3, 2026 00:21
4 tasks
Stardust0831
force-pushed
the
feat/input-choice-requirements
branch
2 times, most recently
from
December 4, 2026 10:33
d0ac9bf to
9470bf5
Compare
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.
This PR reorganizes existing fixed-value INPUT resets into shared requirements. For example,
calculation=mdusescal_force=truewhen omitted; an explicitcal_force=falsenow reports a conflict instead of being overwritten.Linked Issue
Background: #7719
What's changed?
Register requirements on the parameter that directly controls them, using either an option list or a condition:
item.add_choice_requirement({"md", "relax", "cell-relax"}, "cal_force==true"); item.add_requirement("of_wt_rho0!=0", "of_hold_rho0==true");==, including those joined byand) supply the required values for omitted parameters, replacing their ordinary defaults. Sets, ranges, andorrequirements only validate.is_explicitdistinguishes user input, including0andfalse, from generated defaults. The migrated rules preserve explicit values and reject conflicts through the existing diagnostics and manual links.md_restart, withcalculation==mdas its scope.This replaces 16 complete reset callbacks and fixed assignments in three mixed callbacks. Other reset policies remain outside this migration. Existing Autotest inputs omit 41 conflicting declarations across 35 cases; requirements supply the same values as the former resets, with reference results unchanged.
calculationmd,relaxcal_force==truecalculationcell-relaxcal_force==true and cal_stress==truecalculationget_wfcal_force==false and init_chg==atomic and chg_extrap==atomic and out_proj_band==false and bx==1 and by==1 and bz==1 and basis_type!=pwcalculationget_pchgcal_force==false and init_chg==atomic and chg_extrap==atomic and out_proj_band==false and basis_type!=pwcalculationget_scal_force==falsecalculationnscfscf_nmax==1esolver_typetddftexx_separate_loop==falseesolver_typeesolver_type in [lj, dp] and calculation==mdcal_stress==truesymmetry-1,0exx_symmetry_realspace==falsebasis_typepw,lcao_in_pwbx==1 and by==1 and bz==1dft_functionalhf,pbe0rdmft_power_alpha==1dft_functionalmullerrdmft_power_alpha==0.5md_typemd_type in [msst, npt] and calculation==mdcal_stress==truemd_tfirstmd_tfirst<0 and calculation==mdinit_vel==truemd_restartmd_restart==true and calculation==mdinit_vel==truemd_pmodeisomd_pcouple==xyzof_kineticof_kinetic!=wtof_read_kernel==falseof_wt_rho0of_wt_rho0!=0of_hold_rho0==trueof_full_pwfalseof_full_pw_dim==0deepks_out_unittesttruedeepks_out_labels==1 and deepks_scf==truebse_mem_savetruebse_continue==0 and bse_ri_hartree==trueqo_switchtrueout_wfc_lcao==1exx_singularity_correctionexx_singularity_correction==limits and basis_type==pwexx_gamma_extra==falseFor
get_wfandget_pchg,basis_type!=pwis an existing requirement retained alongside the migrated rules. The unchangedgen_besselrequirement is omitted here.Unit Tests and/or Case Tests for my changes
After merging current
develop(67d6746c4), atfda234a00:618031a96): 31 complete INPUT files passed four-rank reader checks, and the 185-read requirement regression passed. Four fixtures need unavailable local FFTW-single/DeePKS features and await CI.Execution order and remaining reset policies
Rules run in registration order, immediately after the controlling parameter's remaining reset callback. This supplies
scf_nmaxbefore the output-frequency default consumes it, and resolves symmetry, basis aliases, and EXX automatic options before selecting their requirements. Each controller selects its rules from one snapshot; there is no dependency sorting or repeated solving. New rules validate effective values after normalization. Existing validation-onlydomain.add_requirementrules still check both original requests and effective values.Existing trigger scopes are retained: for example, the RDMFT-alpha rule still follows the functional even if
rdmftis false, and isotropic pressure coupling still followsmd_pmodewithout an extra MD-only gate. Previously overwritten explicit conflicts in those scopes now fail.Remaining reset callbacks retain their existing behavior and are not covered by this explicit-value guarantee. They include contextual/formula defaults, automatic markers, aliases, internal-state calculations, vector elements/lengths, OFDFT presets, symmetry overrides, and the method-plus-format
init_wfc. DFT+U's vector-triggered disabling, PW gamma-only conversion with KPT generation, and the unused historicalmd_prec_levelreset are also retained.Two successful shared INPUT fixtures now explicitly satisfy the migrated constraints (
md_pcouple=xyz,of_hold_rho0=1); separate tests cover the formerly overwritten conflicts.Verification details and exact commands
Fixture verification at
618031a96: the initial upstream CPU/GPU failures were explicitscf_nmaxconflicts in five NSCF cases andbx/by/bzconflicts inget_wf_spin2. All six errors reproduced with the original INPUT files and disappeared after omitting those fields. The same audit covered enabled later test groups, including MD velocity and TDDFT force declarations. Omittingcal_force=0preserves the existing Autotest force-collection selection; changing it to1would add a reference quantity.The four-rank fixture sweep initially accepted 27/35 files. Four SNAP inputs then passed with their existing model paths available in the scratch layout, giving 31 accepted files with four shutdown markers each. Two single-precision TDDFT and two DeePKS inputs stop at unavailable local build features; their numerical checks await CI. No reference, collector, C++ source, or workflow was changed in this follow-up.
The local fixture harness invokes
/tmp/npt8425-cpu/bin/mpiexec -n 4 build-req-mpi/source/source_io/unittests/MODULE_IO_input_error_mpi <absolute-INPUT-path>in isolated scratch directories withOMP_NUM_THREADS=1. These are input-reader checks, not full numerical reruns.The serial suites include 37 context/target rows exercised through 185 reads: omitted values, explicit matching/conflicting values, both keyword orders, unchanged conflicting values, and explicit provenance. Full-reader regressions cover
scf_nmax → out_freq_elec, the Wannier basis alias, explicitchg_extrap=default, resolved symmetry, EXX correction selection, inactive requirements, and existing noncollinear conflicts.MPI cases check collective error exit and broadcasting of defaults for force, conditional stress, pressure coupling, and fixed OFDFT density. Six existing positive DFT+U cases are excluded because they require GENELPA and this build disables ELPA.
Documentation tests cover overlapping option groups, full-set grouping independent of registration order, duplicate removal, and preservation of compound conditions and nested alternatives. MyST parsed representative option, numerical-condition, and nested-alternative tables with their expected rows and valid links.
Reused GCC Debug builds with LCAO, OpenMP, Libxc, and JSON disabled; the MPI build uses MPICH and disables ELPA. Reader-level DeePKS tests exercise parsing/defaults without invoking the unavailable numerical backend. No full main executable, numerical integration, GPU/LCAO/ELPA-enabled calculation, or full Sphinx/PDF build was run; main-program
abacus --version,-h, and--check-inputtherefore remain unverified.The following build and test commands passed:
Documentation and source checks passed:
/tmp/abacus-input-default-stages-docenv-20261201/bin/python -m unittest discover -s docs -p test_generate_input_main.py -v LD_LIBRARY_PATH=/tmp/npt8425-cpu/lib build-req/source/source_io/abacus_input_yaml > /tmp/abacus-req-owner-parameters.yaml /tmp/abacus-input-default-stages-docenv-20261201/bin/python docs/generate_input_main.py /tmp/abacus-req-owner-parameters.yaml --output /tmp/abacus-req-table-input-main.md /tmp/abacus-input-default-stages-docenv-20261201/bin/python /tmp/abacus-check-req-table-render.py g++ -std=c++11 -Isource -fsyntax-only source/source_io/module_parameter/input_domain.cpp python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text --event-path /tmp/abacus-choice-pr-event.json git diff --check upstream/develop HEADFormatting-scope audit passed:
Whole-file formatting check retains baseline failures in the two files noted below:
Development checklist and governance notes
Reminder
AGENTS.md, agent governance, and CMake guidelines.Governance Notes
unittests/test_input_domain.cppwith its existing CMake target updated; it has no Makefile or pyabacus source-list entry.cmake-format --checkstill fails onsource/source_io/unittests/CMakeLists.txtandsource/source_io/unittests/test_read_input.cmake. Comparing exact formatter edits at the original base (6273e2568) and current version confirms that all remaining discrepancies already exist at the base. Those files are unchanged between that base and current upstream. The module-parameter CMake file passes. Unrelated formatting is excluded; no formatter configuration or CI rule is changed.