Skip to content

Conversation

@PDoakORNL
Copy link
Contributor

@PDoakORNL PDoakORNL commented Mar 20, 2025

Proposed changes

The important change is By providing accessors for working precision ksq and kcart in KContainer we continue to support low precision operations for mixed precision and full precision for full precision builds without having to branch at run time.

And KContainer now does its internal kshell sorting in full precision and previous PR's made the Lattice always full precision. This removes the ambiguity in number of kshells and which kpoints are members of which shells that mixed precision previously suffered from. This unblocks consistent unit testing that is dependent on kshell sorting. For instance for the Structure Factor estimator. Incidentally the number of kshells reported for mixed precision also becomes consistent for many other unit tests.

In order to have to compiler help direct member access that possibly returns incorrect precision KContainer made an actual class and accessors are also established for other members previously directly accessed.

Describe what this PR changes and why. If it closes an issue, link to it here
with a supported keyword.

What type(s) of changes does this code introduce?

Delete the items that do not apply

  • Bugfix
  • Refactoring (no functional changes_
  • Build related change)
  • Testing changes (e.g. new unit/integration/performance tests)
  • Documentation or build script changes
  • Other (please describe):

Does this introduce a breaking change?

  • Yes

What systems has this change been tested on?

Checklist

Update the following with a yes where the items apply. If you're unsure about any of them, don't hesitate to ask. This is
simply a reminder of what we are going to look for before merging your code.

  • Yes/No. This PR is up to date with current the current state of 'develop'
  • Yes/No. Code added or changed in the PR has been clang-formatted
  • Yes/No. This PR adds tests to cover any new code, or to catch a bug that is being fixed
  • Yes/No. Documentation has been added (if appropriate)

@prckent
Copy link
Contributor

prckent commented Mar 20, 2025

Happily it appears that this will likely fix #5384 . For the two HEG test failures in the CI I would simply bump the test tolerance:

27/895 Test  #143: deterministic-heg_14_gamma-sj-batch-1-1-potential .................................................***Failed    0.07 sec
Tests for series 0
  Testing quantity: LocalPotential
    reference mean value     :  -2.02361764
    reference error bar      :   0.00002000
    computed  mean value     :  -2.02367767
    computed  error bar      :   0.00000000
    pass tolerance           :   0.00006000  (  3.00000000 sigma)
    deviation from reference :  -0.00006003  ( -3.00160500 sigma)
    error bar of deviation   :   0.00002000
    significance probability :   0.99731426  (gaussian statistics)
    status of this test      :   fail

@prckent
Copy link
Contributor

prckent commented Mar 20, 2025

Test this please

@PDoakORNL PDoakORNL force-pushed the kcontainer_working_precision branch from fc69d34 to 17f0313 Compare March 21, 2025 15:58
@PDoakORNL PDoakORNL requested a review from ye-luo March 21, 2025 15:59
@PDoakORNL PDoakORNL changed the title [WIP] kcontainer now encapsulated and provides k elements at working prec kcontainer now encapsulated and provides k elements at working prec Mar 21, 2025
@PDoakORNL PDoakORNL changed the title kcontainer now encapsulated and provides k elements at working prec [WIP] kcontainer now encapsulated and provides k elements at working prec Mar 21, 2025
@PDoakORNL
Copy link
Contributor Author

test this please

@PDoakORNL PDoakORNL changed the title [WIP] kcontainer now encapsulated and provides k elements at working prec kcontainer now encapsulated and provides k elements at working prec Mar 21, 2025
prckent
prckent previously approved these changes Mar 24, 2025
Copy link
Contributor

@prckent prckent left a comment

Choose a reason for hiding this comment

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

LGTM. (Will still need a non-ORNL merge).

Thanks Peter. I have a couple of minor points, but I don't think they are worth holding up the PR for: first, there is some commented code that would be nice to remove. second, the "Working" data might be more clearly named "WorkingPrec" , or at least a few more comments to this effect added.


for (int i = 0; i < ref.groups(); i++)
{
std::complex<double> rhok_sum, rhok_even_sum;
Copy link
Contributor

Choose a reason for hiding this comment

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

My fix https://github.com/QMCPACK/qmcpack/pull/5382/files needs to be reinstated .

@ye-luo
Copy link
Contributor

ye-luo commented Mar 24, 2025

There are a lot of changes involved with replacing direct member access with accessor functions. That makes reviewing the actual change difficult. Could you make a list of bullet points highlighting functional changes?
second questions, how much timings are changed in Coulomb terms in performance tests?

@PDoakORNL
Copy link
Contributor Author

Timings should be practically unchanged the cost of initializing the cached low precision values of ksq and kcart is outside of the particle move loop. There is a slight memory cost in mixed precision for the lowered precision ksq and kcart vectors.

@PDoakORNL
Copy link
Contributor Author

test this please

//////////////////////////////////////////////////////////////////////////////////////

#include "catch.hpp"
#include "OhmmsPETE/TinyVector.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel it is needed here. Can it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one can't be removed. Either it has to be here or in checkVector.hpp and I remember a review comment removing it from that file.

Copy link
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

Please make a separate PR with all the changes under Utilities. It should simplify the review process.

PDoakORNL added a commit to PDoakORNL/qmcpack that referenced this pull request Apr 1, 2025
@PDoakORNL
Copy link
Contributor Author

this is going to have a clash with #5410 which I need to look at after that merges so don't merge.

using PositionFull = QMCTraits::QTFull::PosType;
static constexpr int DIM = OHMMS_DIM;
using AppPosition = typename QMCTraits::PosType;
using Position = typename QMCTypes<Real, DIM>::PosType;
Copy link
Contributor

Choose a reason for hiding this comment

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

With this change, there are three precision in this class.
REAL, QMCTraits::FullPrecRealType and QMCTraits::PosType (effectively QMCTraits::RealType)
This seems defeating the purpose of templates.

@ye-luo
Copy link
Contributor

ye-luo commented Apr 2, 2025

Trying a simple fix #5411
If it works, we can avoid convoluted precisions in KContainer.
I still think making KContainer template useful. It affects StructFact which does benefit from lower precision. Using template allows us enabling precision selection at runtime although this feature is considered low priority.

There are a lot of changes in this PR making KContainer comply to our coding standard. That is a very good thing to do. Unfortunately they made code review very hard. I'd recommend making such types of change separately from actual functional changes. It is unclear to me if we can still cherry-pick them or just redo them from scratch.

@PDoakORNL
Copy link
Contributor Author

I think you are being unecessarily restrictive with this and having just had to write an midterm EPM I am accutely aware of how much my performance is effected by our code review process. @prckent please resolve this I am not initerested in revising this again and I do not think it is excessively difficult to review.

@ye-luo
Copy link
Contributor

ye-luo commented Apr 2, 2025

I did a very careful review of the whole code and I expressed my concern #5389 (comment) of the key functional change in this PR. Regarding your KPI, that is an offline discussion. If all the assessor changes were in a separate PRs, such PRs should have been merged already.

@prckent
Copy link
Contributor

prckent commented Apr 2, 2025

I'll take a proper look this afternoon. Dev velocity is a key point and also a concern of mine. I tend to think we should merge this since the tests pass and it is clearly a step in the right direction. No need to keep chopping it up.

@ye-luo
Copy link
Contributor

ye-luo commented Apr 2, 2025

I'll take a proper look this afternoon. Dev velocity is a key point and also a concern of mine. I tend to think we should merge this since the tests pass and it is clearly a step in the right direction. No need to keep chopping it up.

I don't advice chopping it up. Instead, just drop this PR and add accessor/private in the develop. Probably just need some scripting. That seems sufficient to get other dependent PRs to proceed.

Dev speed is critical. I frequently reorganized my intended changes into smaller PRs. Please please experienced developers do the same. It is not just helping reviewers but also to get their work finalized timely. They are the largest beneficiary.

@prckent
Copy link
Contributor

prckent commented Apr 2, 2025

Having reviewed the status, I don’t think the return on investment is there to justify splitting this PR or redoing it again (4th time?). While we all strive for small PRs, that doesn’t always work out. The current PR is clearly several steps forward and the tests pass. I think it is time to merge and move on to other things that will benefit QMCPACK users more (observables, shared spline memory etc.).

@ye-luo
Copy link
Contributor

ye-luo commented Apr 2, 2025

Let me explain my technical assessment of this PR. I raised the concern, the key functional change of this PR is flawed and made the code further complicated. To address this flaw, extra effort will be needed to clean up the over complicated precision handling if we merge this PR and I'm afraid it's not worth it. The alternative route will be actually using an easily understandable fix of the k sorting. Then do minimal fix (adding a few access functions) to enable structure factor estimator #5303/#5406. They are quite self contained. This alternative route has one drawback that KContainer is not made template. Basically we need to defer the template change.

My understanding that the urgent work is to enable estimators not making KContainers template. Taking the alternative route allows to make the needed fix and we can focus working on the actual needed code.

Copy link
Contributor

@prckent prckent left a comment

Choose a reason for hiding this comment

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

I am happy to merge this as is. Let me know your preference @PDoakORNL .

Copy link
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

For expediting the development of the structure factor estimator, let us merge this PR.

@ye-luo
Copy link
Contributor

ye-luo commented Apr 3, 2025

Test this please

@prckent prckent merged commit 5bbbec5 into QMCPACK:develop Apr 4, 2025
41 checks passed
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.

3 participants