Skip to content

Conversation

davpoolechem
Copy link
Contributor

@davpoolechem davpoolechem commented Aug 19, 2022

Description

This PR is the second in a series of planned PRs designed to remove density screening from the TwoBodyAOInt object and into the JK object, with PR #2547 being the first such PR. Having density screening available in TwoBodyAOInt runs the risk of applying density screening to algorithms where density screening doesn't make sense. Thus, it would be a good idea to move the logic of density screening to where it is more correctly applied, i.e., the JK object.

The primary purposes of this PR are twofold:

  1. First, this PR introduce the shell_significant() framework to the JK class. The shell_significant() framework starts with a shell_significant() virtual function that exists in the base JK class. The shell_significant() function can then be redefined specifically for different JK derived classes as needed. The existence of shell_significant() provides a unified framework for performing screening for any JK method, and it also provides the method by which density screening can be added directly to the relevant JK classes.
  2. Second, this PR uses the shell_significant() framework to reimplement screening for certain JK methods. Most significantly, as implied in the first point, the biggest change in this regard was the removal of shell_significant_density() from TwoBodyAOInt into the domain and its reimplementation into the DirectJK shell_significant() definition. With this change, density screening is now the domain of individual JK classes rather than the TwoBodyAOInt class, which was one of the primary goals of this overall refactor PR set in the first place. Additionally, another method that was subject to slight changes from the shell_significant() framework was the Yoshimine PKJK algorithm, in which its test for shell significance was implemented using the shell_significant() framework.

Notes

I wanted to outline what the next steps were for this chain of PRs, since this one accomplishes one of the main goals of the refactor in the first place:

  1. Separate out density screening from the SCREENING keyword and into its own keyword (likely something like DENSITY_SCREENING)
  2. Removal of any density matrix function/variable from TwoBodyAOInt. Without density screening in TwoBodyAOInt, these density matrix references in TwoBodyAOInt are unnecessary and more properly placed into JK, as well.

Todos

  • Implementation of shell_significant() framework in JK class to represent shell significance testing.
  • Removal of shell_significant_density() from TwoBodyAOInt.
  • Reimplementation of density screening in DirectJK via the shell_significant framework.
  • Reimplementation of density screening in other JK methods via the shell_significant framework.
  • Alteration of other shell quartet screening implementations in other JK algorithms via the JK framework.

Questions

  • The shell_significant framework has not yet been added to DFJCOSK. Should that be done this PR, or added in a later PR?

Checklist

Status

  • Ready for review
  • Ready for merge

@davpoolechem davpoolechem force-pushed the dpoole34/shell-significant branch from 235d939 to 566ba18 Compare August 19, 2022 18:20
Copy link
Contributor

@andyj10224 andyj10224 left a comment

Choose a reason for hiding this comment

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

Looks good, I left some comments. Namely, my biggest concern is about removing the screening density keyword and moving update_density away from TwoBodyAOInt. I think it would make more sense to get it all done in one PR, but that is my personal opinion.

@@ -77,7 +77,7 @@ TwoBodyAOInt::TwoBodyAOInt(const IntegralFactory *intsfactory, int deriv)
else if (screentype == "CSAM")
screening_type_ = ScreeningType::CSAM;
else if (screentype == "DENSITY")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to diable setting screening density altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason this is still in here is to account for cases where density screening is used in the HF step and another form of screening is used through TwoBodyAOInt for a later step in the calculation. Looking through the code, it seems that an example of this is in the DirectJKGrad class, which uses TwoBodyAOInt screening functions in its tests for shell block significance.

This will certainly be removed once density screening is separated out as a keyword, though.

// The density screened ERI bound (Eq. 6)
return (mn_mn * rs_rs * max_density * max_density >= screening_threshold_squared_);
}
double TwoBodyAOInt::shell_pair_max_density(int i, int M, int N) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move shell_pair_max_density to JK in this PR or the next? I don't think this belongs in TwoBodyAOInt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My plan was to move this whenever update_density gets moved, which I'm planning on being the next PR.

@davpoolechem
Copy link
Contributor Author

davpoolechem commented Aug 19, 2022

Looks good, I left some comments. Namely, my biggest concern is about removing the screening density keyword and moving update_density away from TwoBodyAOInt. I think it would make more sense to get it all done in one PR, but that is my personal opinion.

Thank you very much for the comments! I do appreciate it. As for your points, my thought was to implement both of these changes in future PRs, maybe as a single future PR, maybe as their own separate ones. I think there's a good argument to be made for making a separate option for density screening in this PR, and I'd be quite willing to do that. But, I do believe that removing update_density should be its own PR, as that PR would consist of removing ALL references to the density matrix from TwoBodyAOInt, and I think it would be easier to review and clearer intent if update_density was separated out in its own PR.

@@ -1111,7 +1118,7 @@ void PKMgrYoshimine::compute_integrals(bool wK) {
for (size_t j = 0; j <= i; ++j) {
int RR = sh_pairs[j].first;
int SS = sh_pairs[j].second;
if (tb[thread]->shell_significant(PP, QQ, RR, SS)) {
if (shell_significant(PP, QQ, RR, SS)) {
Copy link
Member

Choose a reason for hiding this comment

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

so why does this no longer get applied per-thread? (read as naive, not insightful, question)

Copy link
Contributor Author

@davpoolechem davpoolechem Aug 19, 2022

Choose a reason for hiding this comment

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

The shell_significant function in PKMgrYoshimine is defined to do its shell significance test using the sieve_ variable in the base PKManager class instead of through the TwoBodyAOInt object. Theoretically, shell_significant in PKMgrYoshimine could be redefined to use tb[thread]'s shell_significant definition, though it would be somewhat clumsy since it would require passing { tb[thread] } (or something like that, basically just a vector with only tb[thread] in it) as the optional argument for int.

Talking about it here though makes me wonder whether using sieve_ is the best approach for the shell_significant definition, however. I tested it a while back when I first implemented it, and the screened shell quartet counts matched up between this PR's implementation and the previous one, but I really may want to recheck that for my own sake.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ERISieve class is deprecated in favor of having the TwoBodyAOInt object do the sieving. This was originally decided as part of the L2 discussion and has been reaffirmed on Slack just a week or two ago. I was in the process of getting rid of ERISieve when this PR came up.

We'll need to agree about the future of "what class is responsible for sieving" before this PR can be merged in.

@loriab
Copy link
Member

loriab commented Aug 19, 2022

undefined symbol: _ZNK3psi12TwoBodyAOInt22shell_pair_max_densityEiii in case you hadn't clicked through to it yet

@davpoolechem
Copy link
Contributor Author

undefined symbol: _ZNK3psi12TwoBodyAOInt22shell_pair_max_densityEiii in case you hadn't clicked through to it yet

I did indeed notice that! I think I know the problem, so I will apply the fix in just a little bit.

@davpoolechem
Copy link
Contributor Author

All right, CI issue should be fixed now!

Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz left a comment

Choose a reason for hiding this comment

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

Blocking this PR until we can resolve the question of "is TwoBodyAOInt responsible for sieving, or is ERISieve"? Happy to talk about this after ACS Chicago.

@JonathonMisiewicz
Copy link
Contributor

FTR, David and I have agreed to pause this PR until after #2682 and #2665 come in.

@loriab loriab added this to the Psi4 1.8 milestone Nov 28, 2022
@davpoolechem
Copy link
Contributor Author

Blocking this PR until we can resolve the question of "is TwoBodyAOInt responsible for sieving, or is ERISieve"? Happy to talk about this after ACS Chicago.

To add an update to this, some of us (Jonathan, I, and others) discussed this issue at PsiCon 2022. We came to the conclusion that TwoBodyAOInt would be responsible for sieving, and that ERISieve will be removed from Psi4. As use of ERISieve is seemingly localized to the PKJK algorithm, I will be the one responsible for its removal.

Until then, this PR will likely be further delayed.

@davpoolechem davpoolechem mentioned this pull request Apr 28, 2023
10 tasks
@loriab loriab modified the milestones: Psi4 1.8, Psi4 1.9 May 4, 2023
@davpoolechem davpoolechem force-pushed the dpoole34/shell-significant branch from ad4722e to bdf3073 Compare July 11, 2023 14:27
@andyj10224
Copy link
Contributor

andyj10224 commented Jun 24, 2024

@davpoolechem Since #3098 has been opened, should we close this PR?

@davpoolechem
Copy link
Contributor Author

davpoolechem commented Aug 1, 2024

@davpoolechem Since #3098 has been opened, should we close this PR?

You are correct, we should! And so I will.

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.

4 participants