-
Notifications
You must be signed in to change notification settings - Fork 110
Feature/distance-preconditioning #1428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/distance-preconditioning #1428
Conversation
Use `alpha` and `source_time` in `QudaInvertParam` to configure distance preconditioning.
…ter compilation. It's not `std::if_enablt_t`'s fault.
maddyscientist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SaltyChiang for this PR, and for making aware of this method (which I was not aware before your work 😄 ).
It's great to have this feature added to QUDA, but one issue is that there is a lot of code duplication here. A few ideas:
- I wonder if we can have a single
applyWilsonfunction, that simply takes an extra template parameterdistance_pcto avoid having two different definitions ofapplyWilson. - Then instead of
if (d == 3) {
out += ratio_fwd * (U * in.project(d, proj_dir)).reconstruct(d, proj_dir);
} else {
out += (U * in.project(d, proj_dir)).reconstruct(d, proj_dir);
}we could use something like
out += ratio_fwd[d] * (U * in.project(d, proj_dir)).reconstruct(d, proj_dir);where ratio_fwd would be a constexpr array that would trivially evaluate as 1.0 when distance_pc = 1 or if d < 3. I think that would allow us to have a single applyWilson definition.
- For the different .cu files: perhaps we could have a single .hpp file that contains all the boilerplate and have this file included in the stub files dslash_wilson.cu and dslash_wilson_distance.cu, for example, where the only different between the two is a booled template parameter. E.g., like we have dslash_coarse.cu and dslash_coarse_dagger.cu, etc.
Have you given any consideration to the light quark preconditioning technique outlined in the paper?
@maddyscientist That's sounds better than my implementation. Thanks and I'll try to do that these days.
I'll check these files, thank you for your advice.
Sure. The light quark preconditioning described in the paper requires a 4D Lines 2742 to 2745 in b9be584
In fact, leaving the alpha0 negative will trigger a t-direction light quark preconditioning. (I use the sign of alpha0 to decide whether to apply the coefficient or the inverse) I've tried this with the CG solver, but don't see a significant improvement in iteration numbers. Using multigrid for light quarks should be a much better strategy in my opinion.
|
mathiaswagner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reviewed cmake but that looks uncontroversial.
f1c1bbe to
12231df
Compare
12231df to
ea3567d
Compare
|
@maddyscientist I move some common parts of dslash subroutine into public hpp files for Wilson and clover. I tried your advice about setting coefficients in Wilson kernel and the performance without distance preconditioning is the same as before. Do you think these modifications fit the QUDA's standard? I'll add more comments and tests for distance precondition later. |
maddyscientist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SaltyChiang, I see your changes and this looks like a great improvement, thanks for your efforts here. I think we'll be able to get this merged with a bit more cleanup. I've left some comments, but some other outstanding things:
- Make the distance preconditioning an optional CMake parameter, so that a user can disable it if they don't need it to reduce compilation time and binary size
- Provide a sensible error message if distance preconditioning is requested for a Dirac operator type that it's not supported on
- Can you think of a good test for the distance preconditioning? Ideally we'd want to augment the invert_test suite to test this.
- Also good to test that apply the reweighting to a quark field and removing it recovers the original field.
- Apply clang format
A CMake parameter called
I show that only Wilson and clover dslash support the distance preconditioning in the error message, not sure if this is enough.
Two parameters There are some other modifications:
|
Maybe make this parameter
That's fine, thank you.
For testing, I was thinking you should add some specific distance preconditioning to invert_test_gtest.hpp. That way, if the Dirac operator is being tested is the Wilson or Clover operator, and distance preconditioning is enabled, then we would test distance preconditioning with the CG solver. We have a bunch of conditional tests in invert_test_gtest at the moment, so it shouldn't be hard to add this. If we include a distance preconditioning test in invert_test_gtest, then it would be automatically run when
Does distance preconditioning break the multi-shift solver? I haven't thought too hard about this, but naively the distance preconditioning shouldn't break the shifted nature of the Krylov space.
Understood, that's fine.
I think this should be fine, and just work. |
Use `QUDA_DIRAC_DISTANCE_PRECONDITIONING` to build the code for distance preconditioning.
The parameter is renamed to
There shouldn't be any mathematical problem with the multi-shift solver. I considered that the multi-shift solver is usually used in RHMC algorithm, where the source is a spinor in which all time slices are filled with random values. This indicates that the solution will not have a small magnitude at
Some tests are skipped if distance preconditioning is enabled with |
|
Enable distance preconditioning for other solvers except for multigrid. I tried some tests and they passed: ./invert_test --dslash-type wilson --dim 4 4 4 8 --niter 1000 --ngcrkrylov 8 --matpc even-even --distance-pc-alpha0 0.1 --distance-pc-t0 1 --enable-testing true
./invert_test --dslash-type clover --compute-clover true --dim 4 4 4 8 --niter 1000 --ngcrkrylov 8 --matpc even-even --distance-pc-alpha0 0.1 --distance-pc-t0 1 --enable-testing true
./invert_test --dslash-type clover --compute-clover true --dim 4 4 4 8 --niter 1000 --ngcrkrylov 8 --matpc even-even-asym --distance-pc-alpha0 0.1 --distance-pc-t0 1 --enable-testing true |
maddyscientist
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work you've done on this @SaltyChiang. The PR is looking great. Just a couple of things left to do before merging this:
- replicate the additions to
QudaInvertParamin the Fortran interface - move a function definition into
spinor_reweight.cu
Once you've done this, then we can get this merged.
|
Also need this CI build error to be fixed |
Fix errors in the STRICT build.
|
@Jenkins ok to test |
We have been working on the bottom quark with the clover action recently. We cannot obtain a stable plateau in the effective mass diagram even though we have set the residual to be 1e-15. I implement the distance preconditioning algorithm proposed in https://arxiv.org/pdf/1006.4028.pdf.
Two parameters
distance_pc_alpha0anddistance_pc_t0are added toQudaInverParam, which follow Eq.(9) in the paper. I treated the preconditioning as a special solver instead of a new Dirac action, so I just modified the Wilson Dslash and didn't make a newDiracclass. The preconditioning is only enabled when callinginverQuda.I use a point source to solve propagators with different

distance_pc_alpha0and draw the effective mass diagram generated from the pseudoscalar meson correlation functions. The effect of the preconditioning is shown below.The effective mass plot becomes much better with alpha0=1.5.
The preconditioning is only enabled for CG inverter now due to a lack of testing. This could be enabled in more inverters later.
I created wilson_distance.cu, wilson_clover_distance.cu and wilson_clover_distance_preconditioned.cu, because the compilation time will be extremely long if I add distance and non-distance functions in one file.