Skip to content

refactor: omtimize subspace diag freq in bpcg#7435

Open
Missing-Hex wants to merge 1 commit into
deepmodeling:developfrom
Missing-Hex:refactor/freq
Open

refactor: omtimize subspace diag freq in bpcg#7435
Missing-Hex wants to merge 1 commit into
deepmodeling:developfrom
Missing-Hex:refactor/freq

Conversation

@Missing-Hex
Copy link
Copy Markdown

Summary

Optimize BPCG subspace diagonalization frequency with dynamic scaling based on problem size (n_band × n_basis), replacing the fixed frequency (nline = 4).

Problem

Current implementation calls calc_hsub_with_block every fixed nline = 4 CG iterations:

  • Small systems: Unnecessary overhead (O(n_band³) cost dominates)
  • Large systems: Insufficient orthogonality maintenance, slower convergence

Solution

New function compute_optimal_freq() with thresholds:

Problem Size Frequency
≥ 10,000,000 2
≥ 2,000,000 3
≥ 500,000 4 (baseline)
≥ 100,000 5
≥ 10,000 6
< 10,000 nline

Code Change

// bpcg_kernel_op.h
int compute_optimal_freq(const int n_band, const int n_basis, const int nline);

// diago_bpcg.cpp - before CG loop
this->optimal_freq = compute_optimal_freq(this->n_band, this->n_basis, this->nline);

// CG loop
if (current_scf_iter == 1 && ntry % this->optimal_freq == 0) {
    this->calc_hsub_with_block(...);
}

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants