Skip to content

cuDSS implementations of Cholesky solver and refactorization - #459

Merged
shakedregev merged 19 commits into
developfrom
andrew/cudss
Jul 24, 2026
Merged

cuDSS implementations of Cholesky solver and refactorization#459
shakedregev merged 19 commits into
developfrom
andrew/cudss

Conversation

@andrewxu319

@andrewxu319 andrewxu319 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Added cuDSS implementations of Cholesky solver and refactorization on CUDA. These are currently implemented in cuSolver, which is an older library. Updated unit tests for refactorization to test both the cuDSS and cuSolver implementations.

Proposed changes

Cholesky solver: rewrote with cuDSS, but retained cuSolver implementation. The user can pass the use_cudss parameter in the constructor to decide which version to use. It is true by default. The cuDSS implementation is around 4x the speed of the cuSolver implementation.

Refactorization: added LinSolverDirectCuDssRf class as an independent solver. It is very slightly slower than the cuSolver implementation. The interface is kept unchanged, but the following variables are actually unused:

  • Matrices L and U are allocated internally by cuDSS
  • Permutation vector Q is unused, only P. cuDSS only takes one permutation vector and computes the other
  • nboost / pivot_boost have no equivalents in cuDSS
    Other changes:
  • Updated SystemSolver.cpp to accept cudssrf as a factorization method
  • Updated testRefactor.cpp and testSysRefactor.cpp to run tests on both implementations

Checklist

  • All tests pass (make test and make test_install per testing instructions). Code tested on
    • [N/A] CPU backend
    • CUDA backend
    • [N/A] HIP backend
  • I have manually run the non-experimental examples and verified that residuals are close to machine precision. (In your build directory run: ./examples/<your_example>.exe -h to get instructions how to run examples). Code tested on:
    • [N/A] CPU backend
    • CUDA backend
    • [N/A] HIP backend
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows Re::Solve style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

@andrewxu319
andrewxu319 requested a review from shakedregev July 21, 2026 20:58
@shakedregev

shakedregev commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Fixed the changelog "conflict". Reviewing and testing this now. Please pull before making new changes.

Comment thread cmake/ReSolveFindCudaLibraries.cmake Outdated
Comment thread resolve/LinSolverDirectCuDssRf.cpp Outdated
Comment thread resolve/LinSolverDirectCuDssRf.cpp Outdated
Comment on lines +196 to +197
error_sum += cudssMatrixCreateDn(&rhs_descr, n, 1, n, rhs->getData(memory::DEVICE), CUDA_R_64F, CUDSS_LAYOUT_COL_MAJOR);
error_sum += cudssMatrixCreateDn(&x_descr, n, 1, n, x->getData(memory::DEVICE), CUDA_R_64F, CUDSS_LAYOUT_COL_MAJOR);

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.

Nothing to fix here, but I noted that CUDA doesn't support row major. This could cause conversion issues with the code down the line.

@shakedregev shakedregev 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.

Please make a new example which uses cudss. Ensure that the old examples with cuSolver still work with no changes. Also, unless you have tested and shown that transposing on the host is faster, I would transpose on the device. I expect it to be faster for large matrices. No need to reimplement everything, just call our existing functions.

@andrewxu319

Copy link
Copy Markdown
Collaborator Author

Please make a new example which uses cudss. Ensure that the old examples with cuSolver still work with no changes. Also, unless you have tested and shown that transposing on the host is faster, I would transpose on the device. I expect it to be faster for large matrices. No need to reimplement everything, just call our existing functions.

What are you referring to by transpose?

@andrewxu319

Copy link
Copy Markdown
Collaborator Author

Please make a new example which uses cudss. Ensure that the old examples with cuSolver still work with no changes. Also, unless you have tested and shown that transposing on the host is faster, I would transpose on the device. I expect it to be faster for large matrices. No need to reimplement everything, just call our existing functions.

Done. The new example cudssRefactor is a modified copy of sysRefactor.

@andrewxu319
andrewxu319 requested a review from shakedregev July 22, 2026 17:55
cudssMatrixDestroy(descr_b_);
cudssMatrixDestroy(descr_x_);
}
else

@shakedregev shakedregev Jul 23, 2026

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.

what is this else for? it seems within the nested if, but then the commands are outside the outer if

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If RESOLVE_USE_CUDSS is defined, there is an if/else that checks use_cudss_ and takes one branch. If RESOLVE_USE_CUDSS is not defined, there is no if/else, so the else is compiled out.

Comment thread resolve/hykkt/cholesky_cudss/CholeskySolverCuDss.cpp Outdated
Comment thread resolve/SystemSolver.cpp
Comment on lines +322 to +327
#ifdef RESOLVE_USE_CUDSS
}
else if (refactorizationMethod_ == "cudssrf")
{
refactorizationSolver_ = new ReSolve::LinSolverDirectCuDssRf();
#endif

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.

I find this writing style very confusing, though I see you are copying it and see why it works. I really this brackets should be within #ifdef statements.

Comment thread resolve/SystemSolver.cpp
Comment on lines +524 to +534
#ifdef RESOLVE_USE_CUDSS
else if (refactorizationMethod_ == "cudssrf")
{
LinSolverDirectCuDssRf* Rf = dynamic_cast<LinSolverDirectCuDssRf*>(refactorizationSolver_);
Rf->setNumericalProperties(1e-14, 1e-1);

status += refactorizationSolver_->setup(A_, L_, U_, P_, Q_);

is_solve_on_device_ = false;
}
#endif

@shakedregev shakedregev Jul 24, 2026

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.

This way looks much better and is easier to follow.

Comment thread tests/unit/hykkt/runHykktCholeskyCuDssTests.cpp Outdated
shakedregev and others added 3 commits July 24, 2026 13:51
Co-authored-by: Shaked Regev <35384901+shakedregev@users.noreply.github.com>

@shakedregev shakedregev 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.

Great work. Checked the tests and examples

Comment thread examples/cudssRefactor.cpp Outdated
@shakedregev
shakedregev merged commit 6038206 into develop Jul 24, 2026
6 checks passed
@shakedregev
shakedregev deleted the andrew/cudss branch July 24, 2026 19:06
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.

2 participants