Skip to content

Conversation

Leguark
Copy link
Member

@Leguark Leguark commented Aug 5, 2025

Enhanced Conjugate Gradient Solver with Improved Stability and GPU Support

This PR significantly improves the robustness and performance of our solver system with several key enhancements:

Solver Improvements

  • Completely refactored the ConjugateGradientSolver with enhanced stability features for ill-conditioned matrices
  • Added adaptive tolerance, regularization support, and robust convergence criteria
  • Implemented residual monitoring and restart capability for better convergence
  • Added detailed diagnostics and warnings for numerical issues

GPU Acceleration

  • Added GPU support for PyKeOps solver in the torch backend
  • Properly configured backend tensor handling for GPU operations
  • Fixed device selection logic in solver interface

Caching and Weights Management

  • Added ability to pass initial weights through the interpolation input
  • Implemented weights_x0 in solver input for warm starts
  • Added clear_cache method to WeightCache for better memory management

Numerical Stability

  • Fixed condition number computation and made plotting optional
  • Properly store condition number in kernel options during operations
  • Added safeguards against numerical breakdown in denominator calculations
  • Implemented stagnation detection for ill-conditioned systems

Experimental Features

  • Added Nyström preconditioner implementation (currently disabled by default)
  • Included configurable pivoting strategies for matrix approximation

These changes significantly improve the solver's ability to handle challenging numerical problems while maintaining performance.

Leguark added 14 commits July 23, 2025 11:52
Updated `_compute_conditional_number` to return the computed condition number and made plotting optional with a new `plot` argument. Adjusted kernel options to store condition number during numpy backend operations.
Introduced a `use_gpu` parameter to enable GPU acceleration in the `pykeops_torch_cg` function. Adjusted solver backend logic to toggle between CPU and GPU based on this parameter.
Enhanced the `ConjugateGradientSolver` function with
Replaced helper function-based preconditioning with the adaptive Nyström preconditioner in the PyKeOps solver. This includes configurable strategies for pivot selection (`aggressive`, `conservative`, `minimal`) and fallback handling for robust kernel matrix approximation. Removed unused diagonal and Jacobi preconditioners. Cleaned up redundant code.
Introduced a `verbose` parameter to control diagnostic print statements during the iteration process.
Introduced a `clear_cache` method in the `WeightCache` class for better memory management. Enhanced the numerical stability of the conjugate gradient solver with improved initialization and adaptive tolerances. Refactored interpolation logic to handle weights more efficiently, and adjusted benchmarking to test expanded solver configurations.
Copy link
Member Author

Leguark commented Aug 5, 2025

@Leguark Leguark changed the title [BUG] Fix condition number computation and optional plotting [ENH] Improve CG solver and add weights caching for better performance Sep 17, 2025
@Leguark Leguark marked this pull request as ready for review September 17, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant