Skip to content
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

Hamiltonian updates for batched estimators #5295

Merged

Conversation

PDoakORNL
Copy link
Contributor

Proposed changes

The default decay behavior for ::mw_evaluatePerParticleWithToperator breaks any estimator needing per particle Hamiltonian values reported when tmoves were turned on. See #5245. Here we explicity declare and define ::mw_evaluatePerParticleWithToperator to ::mw_evaluatePerParticle instead of ::mw_evaluateWithToperator for
CoulombPotential, CoulombPBCAA, and CoulombPBCAB so that these energies are not omitted from the Batched EnergyDensityEstimator port.

We remove the unnecessary templating on real type from CoulombPotential and split its header into implementation and header to reduce unnecessary recompilation.

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

Delete the items that do not apply

  • Bugfix
  • New feature
  • Code style update (formatting, renaming)
  • Build related changes
  • Testing changes, in this PR no significant changed.
    Indirect testing of all new code is added with EnergyDensityEstimator unit tests in a coming PR.
  • 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 This PR is up to date with current the current state of 'develop'
  • Yes Code added or changed in the PR has been clang-formatted
  • No. This PR adds tests to cover any new code, or to catch a bug that is being fixed
  • Yes Documentation has been added (if appropriate)

@PDoakORNL PDoakORNL force-pushed the HamiltonianUpdatesForBatchedEstimators branch from a8dff12 to 3f1ccb5 Compare February 3, 2025 17:41
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.

It is nice to clean up the unnecessary template.

@@ -317,6 +318,30 @@ void CoulombPBCAA::mw_evaluatePerParticle(const RefVectorWithLeader<OperatorBase

for (const ListenerVector<RealType>& listener : listeners)
listener.report(walker_index, name, v_sample);

#if defined TRACE_CHECK && defined NDEBUG
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid the if defined protected code is likely to become dead code.
How about we introduce trace_check=yes/no input option for this class and similar ones?
Also throw proper exception instead using the ugly APP_ABORT.
We can turn on trace_check in the tests although not by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not an unreasonable fear. I will take a look at doing that tomorrow morning, otherwise I will remove.

Copy link
Contributor

@prckent prckent Feb 4, 2025

Choose a reason for hiding this comment

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

I prefer no more additional options if we can avoid them. Can we enable TRACE_CHECK purely in debug builds? Currently TRACE_CHECK is never activated in any CI or nightly test builds, nor featured in any documentation, so the check almost doesn't exist. If the code is broken the check will fail every Monte Carlo step.

(Comments apply to most of the extra preprocessor enabled checks in the code -- I think we should be getting rid of them as separate options as much as we can and simply making them active in debug builds so that they are actually used.)

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 APP_ABORT came with the copy paste of the trace block and dates to 2013 or before when I don't think there was any other guidance on this. I've fixed it for the added code. There are many other APP_ABORT throughout the QMCHamiltonian module many in within the scope of a QMCSection, they seem as if they will not be caught until qmcapp.cpp which is where the handling is for most non uniform runtime errors. But some significant percentage of them them are predictable at construction time and actually uniform and are just eating some branch prediction capability. I'll write an issue for them.

Copy link
Contributor

Choose a reason for hiding this comment

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

When code gets touched, the new code should follow our dev spec. https://qmcpack.readthedocs.io/en/develop/developing.html#log-and-error-output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this just protected by a

#ifndef NDEBUG

blocck so its not dead code and in debug it always runs, since this doesn't create new input it seems to have an insignificant impact on debug "performance" so far. The other "trace" code in that estimator needs more thought to make not "dead".

src/QMCHamiltonians/CoulombPotential.cpp Outdated Show resolved Hide resolved
src/QMCHamiltonians/CoulombPotential.h Show resolved Hide resolved
@PDoakORNL PDoakORNL force-pushed the HamiltonianUpdatesForBatchedEstimators branch from 3f1ccb5 to eb189e4 Compare February 5, 2025 21:41
@PDoakORNL PDoakORNL requested a review from ye-luo February 5, 2025 23:13
@PDoakORNL
Copy link
Contributor Author

test this please

@ye-luo ye-luo merged commit de4ae20 into QMCPACK:develop Feb 6, 2025
39 of 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