Skip to content

Refactor/Add convergence-rate-based adaptive frequency for BPCG subspace diagonalization#7441

Open
Missing-Hex wants to merge 3 commits into
deepmodeling:developfrom
Missing-Hex:refactor/freq_dynamic
Open

Refactor/Add convergence-rate-based adaptive frequency for BPCG subspace diagonalization#7441
Missing-Hex wants to merge 3 commits into
deepmodeling:developfrom
Missing-Hex:refactor/freq_dynamic

Conversation

@Missing-Hex

Copy link
Copy Markdown

Summary

This PR adds a convergence-rate-based adaptive frequency mechanism to the BPCG diagonalization method. The subspace diagonalization call frequency now dynamically adjusts based on the actual convergence state, building on top of the existing problem-size-based frequency.

Key Idea

Track historical error changes, compute convergence rate every 2 CG steps, and adjust frequency accordingly:

  • Fast convergence → reduce diagonalization (save computation)
  • Slow/stagnant convergence → increase diagonalization (accelerate convergence)

Convergence Rate Definition

conv_rate State Action
< 0.3 Very fast freq + 1
0.3 - 0.6 Fast keep baseline
0.6 - 0.85 Moderate freq - 1
≥ 0.85 Stagnant freq - 2

Two-Level Frequency Control

Level Based On When
Level 1 Problem size (n_band × n_basis) Once at diag() entry
Level 2 Convergence rate (error trend) Every 2 CG steps

Final frequency = baseline_freq ± adaptive_adjustment (clamped to [1, nline])

Code Changes

File Change
bpcg_kernel_op.h/cpp Add compute_convergence_rate() and compute_adaptive_freq()
diago_bpcg.h Add 4 member variables + update_adaptive_freq()
diago_bpcg.cpp Integrate adaptive frequency into CG loop

Benefits

  • Fast convergence: Reduced unnecessary diagonalization overhead
  • Slow convergence: More frequent resets to maintain orthogonality
  • Backward compatible: No interface changes, default behavior unchanged

Example Usage

The adaptive frequency automatically responds to convergence behavior without any user configuration.

@mohanchen mohanchen added project_learning Diago Issues related to diagonalizaiton methods labels Jun 7, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

I notice the functional change regarding the adaptive frequency. However, validation of its actual effects is missing.
Could you clarify whether this update makes the BPCG solver more stable or faster?
Besides, if the original convergence of BPCG was problematic, have we confirmed that the existing BPCG implementation is correct? Are there known bugs in the BPCG code that need to be addresse?

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

Labels

Diago Issues related to diagonalizaiton methods project_learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants