Skip to content

perf(estate): reduce GPU density and NCGGA data movement (by OutisLi and dyzheng) - #8463

Open
Flying-dragon-boxing wants to merge 10 commits into
deepmodeling:developfrom
Flying-dragon-boxing:split/pr8306-density-xc-gpu
Open

Flying-dragon-boxing wants to merge 10 commits into
deepmodeling:developfrom
Flying-dragon-boxing:split/pr8306-density-xc-gpu

Conversation

@Flying-dragon-boxing

Copy link
Copy Markdown
Collaborator

Summary

Split from #8306 as an independent density/FFT/XC GPU optimization.

  • Skip exact zero-weight bands before their FFT and density work.
  • Add device-side density/Hartree helpers and reduce host/device transfers.
  • Add CUDA support for the NCGGA spin-format path and allocate the Meta workspace lazily.
  • Preserve CPU and unsupported-precision fallbacks.

No INPUT parameter or input-file behavior is changed.

Performance

Measured against the same pre-synchronization baseline on dual RTX 4090 GPUs:

  • Si16: 1.076x end-to-end SCF speedup.
  • Original Fe16 DeltaSpin case: 492.27 s -> 466.54 s (1.055x). A slower third candidate run was retained as an outlier rather than silently removed.
  • Fe32: 3565.34 s -> 3490.71 s (1.021x).
  • NCGGA GPU smoke case: 6.252 s -> 6.159 s (1.015x).
  • The largest SCF energy difference across the tested cases was about 1.15e-8 eV.

The branch was subsequently merged with upstream/develop at 5064965; performance was not re-measured after that synchronization.

Verification

  • CUDA 12.6, RTX 4090: cmake --build build -j 16 passed at f3b089c.
  • git diff --check upstream/develop...HEAD: passed.
  • python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text: no blocking findings.
  • MODULE_HAMILT_XCTest_NCGGA_RADIAL could not be generated in this build because ENABLE_LIBXC=OFF; the complete CUDA executable build passed. ROCm was not built or tested.

Review notes

  • Zero-weight skipping applies only to exact zeros; negative smearing weights still contribute.
  • Global dependency references decrease (net -2); the spin count now comes from the Charge object where available.
  • New header dependencies declare the device helpers and NCGGA radial operations used by the implementation.

dyzheng and others added 2 commits November 25, 2026 15:30
Split from deepmodeling#8306. Add sparse FFT plans, device density transforms, Hartree and NCGGA-SF kernels. Derive XC device selection from PW_Basis and preserve existing ElecState interfaces so this branch is independent.
…sity-xc-gpu

# Conflicts:
#	source/source_estate/elecstate_pw.cpp
#	source/source_pw/module_pwdft/op_pw_meta.cpp
#	source/source_pw/module_pwdft/op_pw_meta.h
@mohanchen mohanchen added GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes labels Dec 2, 2026
@Flying-dragon-boxing Flying-dragon-boxing changed the title perf(estate): reduce GPU density and NCGGA data movement perf(estate): reduce GPU density and NCGGA data movement (by OutisLi and dyzheng) Dec 2, 2026
@Flying-dragon-boxing
Flying-dragon-boxing marked this pull request as ready for review December 2, 2026 05:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-02T06:03:32.168435Z
We couldn’t complete this review. Comment @codex review to try again.
770145c 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.

@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 built-in NCGGA allocation check reads an indeterminate status, and ROCm initializes an unused full-grid density FFT. Please correct these paths; the inline notes also cover focused GPU tests and documentation/interface cleanup.

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

}
Complex* scratch = nullptr;
base_device::memory::resize_memory_op<Complex, base_device::DEVICE_GPU>()(scratch, scratch_size);
auto* grid = basis.fft3d_bundle.template get_auxr_3d_data<Real>();

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.

avoid using 'auto'

base_device::memory::set_memory_op<Complex, base_device::DEVICE_GPU>()(grid, 0, basis.nxyz);
set_3d_fft_box_op<Real, base_device::DEVICE_GPU>()(basis.npw, basis.ig2ixyz_gpu, scratch, grid);
basis.fft3d_bundle.fft3D_backward(grid, grid);
auto* result = reinterpret_cast<Output*>(scratch);

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.

avoid using 'auto'

out);
if (add)
{
auto* grid = this->fft_bundle.get_auxr_3d_data<float>();

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.

avoid using 'auto'

out);
if (add)
{
auto* grid = this->fft_bundle.get_auxr_3d_data<double>();

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.

avoid using 'auto'

out);
if (add)
{
auto* grid = this->fft_bundle.get_auxr_3d_data<FPTYPE>();

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.

avoid using 'auto'

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

GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants