Skip to content

feat(solver): Add Configurable Lossy Optimizations for Performance Tuning#16

Merged
TKanX merged 11 commits intomainfrom
feature/15-add-configurable-lossy-optimizations-hydrogen-scf-cutoff-hydrogen-inner-iters
Dec 10, 2025
Merged

feat(solver): Add Configurable Lossy Optimizations for Performance Tuning#16
TKanX merged 11 commits intomainfrom
feature/15-add-configurable-lossy-optimizations-hydrogen-scf-cutoff-hydrogen-inner-iters

Conversation

@TKanX
Copy link
Member

@TKanX TKanX commented Dec 10, 2025

Summary:

Introduces several advanced, configurable "lossy" optimization options to the cheq solver, allowing users to trade numerical exactness for significant performance gains on large-scale systems. These new features, exposed through both the library API (SolverOptions) and the CLI, include a hard cutoff radius for pair interactions, the ability to disable the non-linear hydrogen SCF term, and an experimental hydrogen-focused inner iteration loop. These additions provide sophisticated knobs for performance tuning in computationally demanding scenarios.

Changes:

  • Implemented a Hard Cutoff Radius for Pair Interactions:

    • Added a cutoff_radius option to SolverOptions.
    • When a cutoff is specified, a spatial hashing algorithm (neighbor list) is used to efficiently compute only the J_ij interactions for atom pairs within the given radius, drastically reducing the complexity from O(N²) to O(N).
    • This optimization is "lossy" as it neglects long-range electrostatic interactions but offers substantial speedups for large, non-compact systems.
  • Added Toggle for Non-Linear Hydrogen SCF:

    • Introduced a hydrogen_scf boolean flag in SolverOptions.
    • When set to false, the solver treats hydrogen with a fixed hardness, turning the problem into a single-shot linear solve that converges in one iteration.
    • This provides a significant performance boost for hydrogen-rich systems at the cost of neglecting the charge-dependence of hydrogen's hardness.
  • Introduced an Experimental Hydrogen Inner Iteration Loop:

    • Added a hydrogen_inner_iters option to perform a set number of fast, hydrogen-only charge updates before each full SCF cycle.
    • This experimental feature is designed to accelerate convergence in systems where hydrogen charge fluctuations are the primary driver, by pre-equilibrating them in a cheaper sub-problem.
  • Exposed All New Options in the CLI:

    • All new SolverOptions (--cutoff, --hydrogen-scf, --hydrogen-inner-iters) are now available as command-line arguments.
    • Updated the USAGE.md and README.md to document these advanced options and explain their performance implications.
  • Refactored Solver for Optimization Hooks:

    • The core solve method was refactored to cleanly integrate the new optimization pathways.
    • Logic now branches based on whether hydrogen_scf is enabled and whether a cutoff_radius is provided, ensuring a clear separation between the exact (lossless) and approximate (lossy) calculation modes.

@TKanX TKanX self-assigned this Dec 10, 2025
Copilot AI review requested due to automatic review settings December 10, 2025 04:18
@TKanX TKanX added enhancement ✨ New feature or request performance ⚡ Performance improvements and code optimizations labels Dec 10, 2025
@TKanX TKanX linked an issue Dec 10, 2025 that may be closed by this pull request
14 tasks
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces advanced performance optimization options to the cheq solver, allowing users to trade numerical exactness for computational speed when solving large-scale charge equilibration problems. The changes are well-integrated across the library API, CLI, and documentation.

Key changes:

  • Added three configurable "lossy" optimization features: hard cutoff radius for pair interactions, toggleable hydrogen SCF (self-consistent field), and experimental hydrogen-focused inner iterations
  • Refactored the solver's core solve method to support multiple optimization pathways with clean separation between exact and approximate calculation modes
  • Implemented spatial hashing (neighbor list) for efficient O(N) pair interaction computation when using cutoff radius

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/solver/options.rs Adds three new fields to SolverOptions: hydrogen_scf, cutoff_radius, and hydrogen_inner_iters with appropriate defaults
src/solver/implementation.rs Refactors solver logic to support optimization pathways, extracts run_single_solve helper, adds spatial hashing for cutoff, and includes comprehensive tests for new features
src/lib.rs Minor refactoring to use contains_key instead of get().is_some() for cleaner code
src/bin/modules/cli.rs Exposes all three new solver options as CLI arguments with appropriate documentation
src/bin/modules/app.rs Connects CLI arguments to SolverOptions fields
USAGE.md Documents the new CLI options and updates the argument reference table
README.md Adds mention of lossy optimization knobs to the features list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

TKanX and others added 2 commits December 9, 2025 20:27
…ct lossy simplification

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TKanX TKanX merged commit c972c36 into main Dec 10, 2025
2 checks passed
@TKanX TKanX deleted the feature/15-add-configurable-lossy-optimizations-hydrogen-scf-cutoff-hydrogen-inner-iters branch December 10, 2025 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request performance ⚡ Performance improvements and code optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Configurable Lossy Optimizations (Hydrogen SCF, Cutoff, Hydrogen Inner Iters)

2 participants