Skip to content

Conversation

pratikvn
Copy link
Member

@pratikvn pratikvn commented Oct 15, 2023

This PR uses the distributed coarse level generation from PGM to use as a coarse level for the additive Schwarz preconditioner. The only requirement is that the galerkin product generator ($RAP$) generate a multigrid::MultigridLevel which is a triplet of restrict, prolong and coarse operators. The user additionally also needs to set the solver for the coarse level.

TODO

+ [ ] Add options to switch between multiplicative and additive
+ [ ] Options for arbitrary number of levels.

Possible issues

  1. The coarse level solve significantly reduces the number of iterations, but can be extremely expensive. Maybe makes sense to apply coarse solve, only a few times instead of every preconditioner apply (need to be careful of consistency of preconditioner apply) ?
  2. Weighting between the local solver solution and the coarse solution is unclear.
  3. Though the coarse solve and the local solve are independent, we have no way of performing them in parallel. This will probably require a rewrite of the apply interface to enable asynchronicity, in addition to support for multiple streams/queues.

@pratikvn pratikvn self-assigned this Oct 15, 2023
@ginkgo-bot ginkgo-bot added reg:testing This is related to testing. mod:core This is related to the core module. reg:example This is related to the examples. type:preconditioner This is related to the preconditioners labels Oct 15, 2023
@tcojean tcojean added this to the Ginkgo 1.9.0 milestone May 3, 2024
@yhmtsai yhmtsai force-pushed the distributed_pgm branch 4 times, most recently from a10beb2 to 8667fa1 Compare May 9, 2024 08:00
Base automatically changed from distributed_pgm to develop May 9, 2024 12:23
@pratikvn pratikvn marked this pull request as draft July 11, 2024 14:31
@pratikvn pratikvn force-pushed the multilevel-schwarz branch 2 times, most recently from 24c6f7d to 8df491e Compare August 12, 2024 14:45
@pratikvn pratikvn force-pushed the multilevel-schwarz branch from 8df491e to 9101732 Compare October 7, 2024 12:18
@MarcelKoch MarcelKoch modified the milestones: Ginkgo 1.9.0, Ginkgo 1.10.0 Dec 9, 2024
@pratikvn pratikvn marked this pull request as ready for review January 31, 2025 16:03
@pratikvn pratikvn changed the title WIP: Add a Multilevel schwarz preconditioner Add a Multilevel schwarz preconditioner Jan 31, 2025
@pratikvn
Copy link
Member Author

As a first step, I just added a two-level preconditioner with equal weighting for the local solution and the coarse solution. I think it maybe makes sense to try this out in some applications and then think about arbitrary number of levels, additive/multiplicative etc.

@pratikvn pratikvn added the 1:ST:ready-for-review This PR is ready for review label Jan 31, 2025
@pratikvn pratikvn requested a review from a team January 31, 2025 16:05
@pratikvn pratikvn force-pushed the multilevel-schwarz branch from f21ade0 to 9d9b829 Compare April 9, 2025 14:57
@pratikvn pratikvn requested a review from yhmtsai April 10, 2025 08:46

gko::remove_complex<ValueType> cweight =
gko::detail::real_impl(parameters_.coarse_weight);
if (cweight > 0.0 && cweight <= 1.0) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (cweight > 0.0 && cweight <= 1.0) {
if (cweight >= 0.0 && cweight <= 1.0) {

this->coarse_solver_ = share(parameters_.coarse_solver->generate(
as<Matrix<ValueType, LocalIndexType, GlobalIndexType>>(
coarse)));
}
Copy link
Member

Choose a reason for hiding this comment

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

throw an error or assert if coarse_level_ or coarse_solver are nullptr.
Do you need the fallback option?
For example, the problem is small enough or different reason such that multigrid level does not generate proper one.
User seems to easily have a wrong expectation. we do not perform the two-level schwarz.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would say that is out of scope of what Schwarz should do. I think the user has to ensure that the coarse level has valid inputs. The fallback option will be that there is no coarse level solve.

Comment on lines 111 to 112
this->local_solver_->apply(gko::detail::get_local(dense_b),
gko::detail::get_local(dense_x));
Copy link
Member

Choose a reason for hiding this comment

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

you need to wrap if (this->local_solver) to ensure it is not nullptr

@pratikvn pratikvn requested a review from yhmtsai April 10, 2025 12:12
@pratikvn pratikvn added 1:ST:ready-to-merge This PR is ready to merge. and removed 1:ST:ready-for-review This PR is ready for review labels Apr 10, 2025
Copy link

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 97.61905% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.36%. Comparing base (fc280ab) to head (d6c3ebc).
Report is 23 commits behind head on develop.

Files with missing lines Patch % Lines
core/distributed/preconditioner/schwarz.cpp 94.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1431      +/-   ##
===========================================
- Coverage    89.57%   89.36%   -0.21%     
===========================================
  Files          824      824              
  Lines        68815    68983     +168     
===========================================
+ Hits         61643    61649       +6     
- Misses        7172     7334     +162     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pratikvn pratikvn merged commit 83d1fc5 into develop Apr 11, 2025
13 of 14 checks passed
@pratikvn pratikvn deleted the multilevel-schwarz branch April 11, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1:ST:ready-to-merge This PR is ready to merge. mod:core This is related to the core module. reg:example This is related to the examples. reg:testing This is related to testing. type:distributed-functionality type:preconditioner This is related to the preconditioners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants