Skip to content

Feature: support EXX PW (screened hybrid) NSCF - #8093

Open
Flying-dragon-boxing wants to merge 22 commits into
deepmodeling:developfrom
Flying-dragon-boxing:feature/pw-hybrid-nscf
Open

Flying-dragon-boxing wants to merge 22 commits into
deepmodeling:developfrom
Flying-dragon-boxing:feature/pw-hybrid-nscf

Conversation

@Flying-dragon-boxing

@Flying-dragon-boxing Flying-dragon-boxing commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

PW screened hybrid NSCF solves independent target K points and additional bands from a frozen SCF source. It reuses existing binary wavefunctions and eig_occ.txt, with no changes to their formats or existing IO implementations.

PW HSE shares LCAO's exx_singularity_correction limits default; gygi preserves the historical PW correction. Configuration differences and missing INPUT.info warn and continue. Invalid numerical source data remains an error.

Linked Issue

None.

Changes

  • Separate frozen source and target states in ESolver/PW exchange. Validate dimensions, occupations, spin meshes and Miller mapping.
  • Support CPU/CUDA, nspin=1/2, kpar=bndpar=1. ACE, SOC, unscreened hybrid NSCF, forces and stress remain unsupported. PW EXX runs with symmetry disabled; input symmetry=0 is reset to -1.
  • Update INPUT metadata and generated docs. Workflow tests run manually; only unit tests are registered with CMake/CTest.

Verification

Numerical regressions passed at f7f73560f, using OMP_NUM_THREADS=1:

ctest --test-dir /tmp/abacus-hybrid-nscf-pr-build -V -R '^(MODULE_ESOLVER_pw_hybrid_source|MODULE_IO_read_item_serial)$'
python3 tests/integrate/tools/test_hybrid_nscf.py /tmp/abacus-hybrid-nscf-pr-build/abacus_std_para --mpi-ranks 2 --workdir /tmp/hybrid-audit-cpu-regression
python3 tests/integrate/tools/test_hybrid_nscf.py /tmp/abacus-hybrid-nscf-pr-gpu-build/abacus_pw_gpu --gpu --workdir /tmp/hybrid-audit-gpu-regression

Both CPU/CUDA builds, four source-adapter unit cases, six INPUT cases and both workflow scripts passed. CPU/CUDA double results agree at printed precision; CUDA single differs by at most 1.41e-4 eV in the H fixture. Multi-rank CUDA, ROCm and cross-code convergence were not verified.

The documentation follow-up rebuilt the CPU executable, checked -h calculation, and regenerated both INPUT documents. Explicit and automatic target lists gave identical eigenvalues for input symmetry 0 and -1; the runtime reset warning was confirmed.

Governance

Diff checks pass; governance reports no errors. Global references decrease by four; the remaining added reference passes the existing read directory into ESolver. New header includes declare stream/vector interfaces. No exception requested; PR remains draft.

@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge EXX/lr-TDDFT/RPA/BSE/GW Related to beyond DFT methods labels Oct 8, 2026
@Flying-dragon-boxing Flying-dragon-boxing changed the title feat(pw): support screened hybrid NSCF with shared zero-transfer limits Feature: support EXX PW (screened hybrid) NSCF Oct 8, 2026
@Flying-dragon-boxing

Copy link
Copy Markdown
Collaborator Author

@ABACUS-PR-BOT Review this PR, focus on code quality and user usability.

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

Static review focused on code quality and user usability at c33bda5: two source-input compatibility issues and four non-blocking suggestions below. Independent source inspection and governance/whitespace checks completed; no builds, runtime tests or CI verification were performed.

Comment thread source/source_esolver/pw_hybrid_source.cpp Outdated
Comment thread source/source_esolver/pw_hybrid_nscf.cpp Outdated
Comment thread source/source_pw/module_pwdft/op_pw_exx.cpp
Comment thread docs/advanced/elec_properties/hybrid_nscf.md
const std::string filename = ModuleIO::filename_output(readin_dir, "wf", "pw", iq,
exx_source_points_.ik2iktot, inp.nspin, nks, 2, false, false, -1);
std::ifstream in(filename, std::ios::binary);
const auto metadata = read_exx_source_header(in);

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: Please include filename and the source index when annotating a header/grid validation failure. If one of many wfk files is missing or truncated, these new checks report only a generic EXX source error and exit before the existing reader can name the file, leaving the user to locate it manually. A focused diagnostic follow-up is fine.

Comment thread tests/integrate/tools/test_hybrid_nscf.py Outdated
…e occupations, fix doc suffix

- Treat explicit zero exx_fock_alpha as an omitted Fock term in NSCF
  validation and in SCF/NSCF configuration comparison.
- Reject out-of-range source occupations with a diagnostic naming the
  unsupported smearing, and require smearing_method fixed in the doc.
- Add suffix hybrid to the SCF doc snippet so read_file_dir resolves.
- Cover the explicit-zero Fock input in the workflow regression and the
  smearing diagnostic in the occupation unit test.
Drop tests/integrate/tools/test_hybrid_nscf.py and register two cases in
tests/01_PW following the get_wf/get_pchg precedent: nscf_hse_same commits
the frozen HSE SCF source (binary wavefunctions, eig_occ.txt, charge
restart, INPUT.info) and solves the same mesh with more bands plus an
explicit zero exx_fock_alpha; nscf_hse_path reads that source through a
relative read_file_dir and solves an independent target k-point list.
Bands are compared against committed references; both cases are registered
for CPU and GPU suites. Update the documentation verification section.
Resolve conflicts: accept upstream deletion of docs/parameters.yaml and
docs/advanced/input_files/input-main.md (both are generated in CI from
source annotations since deepmodeling#7976; this branch's documentation edits live in
the source annotations); keep both prepare_exx_nscf members and RT-TDDFT
prepare_init_hamilt in esolver_ks_pw.h; keep both new case registrations
in tests/01_PW/CASES_CPU.txt.
Only the MP smearing family can write occupations outside [0, k-point
weight]; fixed, gauss, mv and fd stay non-negative and are accepted. Say
so in the error message and the hybrid NSCF documentation.
@Flying-dragon-boxing
Flying-dragon-boxing marked this pull request as ready for review October 14, 2026 10:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T11:01:13.631407Z e6b9b9e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6b9b9efd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread source/source_pw/module_pwdft/op_pw_exx.cpp
Comment thread source/source_esolver/pw_hybrid_nscf.cpp
set_source now takes the source basis, k points and occupations by value
handle and keeps them alive itself, instead of storing observer pointers
into ESolver members. prepare_exx_nscf becomes a free function with local
state only, ESolver_KS_PW drops its four exx_source members, and the
staging wavefunction copy is released when the function returns instead
of persisting alongside the operator's own copy for the whole NSCF run.
The precision-converting constructor now rejects operators with an
installed source.

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

EXX/lr-TDDFT/RPA/BSE/GW Related to beyond DFT methods Features Needed The features are indeed needed, and developers should have sophisticated knowledge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants