Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements batched deflation for MILC. Most of the work was limited to the QUDA/MILC interface, however, there is one change (the first one listed below) that goes beyond that scope, so please check that one in particular to ensure that my solution is okay.
errorQuda()
inconstructDeflationSpace()
towarningQuda()
. See below for more descriptionqudaCleanUpDeflationSpace()
. See below for more descriptioninvertQuda()
to preserve the deflation space. The preservation of the eigenvectors and eigenvalues is then controlled from the MILC side by the appropriate parameters in theQudaEigParam
struct.tol_restart
andcuda_prec_eigensolver
from the MILC sideinvertQuda()
were copied toinvertQudaMsrc()
.Note there is a companion MILC pull request at milc-qcd/milc_qcd#76
Note that this implementation only performs deflation for even parity solves. This seems to be fine when the UML solver is selected for MILC. With UML, the odd parity solution is reconstructed from the even parity solution and then polished with a few CG iterations. Usually this is a small number and might not benefit from deflation anyway. On the other hand, if the CG or CGZ solvers are preferred then odd parity deflation should also be implemented in the future.
More details:
errorQuda()
inconstructDeflationSpace()
towarningQuda()
. Here's why:When loading eigenvectors from file,
loadFromFile()
->computeEvals()
is called, which extends the deflation space by the amount of the batch size:After the first deflated solve, the deflation space is preserved, but it is now of size
evecs.size() + batch_size
.This is fine for the first deflated solve, but on the second deflated solve, when
constructDeflationSpace()
is called and the preserved deflation space is attempted to be loaded, the following check fails:It expects
However, it is now actually
Replacing the
errorQuda()
withwarningQuda()
allows it to run, and it runs fine. However, if there are cases where we really need the warning to be an error, then this is probably not the right way to fix it.qudaCleanUpDeflationSpace()
, which can be called from MILC to clean up the deflation space. An alternative approach would be to setpreserve_deflation_space
to false on the last solve. However, this would limit how much we could amortize the cost of the eigenvector loading. The parameter input file for a large MILC calculation is chunked into "readin sets". MILC reads one of these readin sets, performs all calculations therein, and then reads the next readin set. So during a job, MILC does not know when it is doing the last solve. At best, it knows it's the last solve in the current readin set. So it seemed to me the best way to ensure that the deflation space is preserved over all readin sets is to add a cleanup function that can be called from MILC'sfinalize_quda()
function inmilc_qcd/generic/milc_to_quda_utilities.c
.