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

Update OptimizableObject and its usage #4168

Merged
merged 15 commits into from
Aug 17, 2022
Merged

Conversation

ye-luo
Copy link
Contributor

@ye-luo ye-luo commented Aug 11, 2022

Proposed changes

Add OptimizableObject as a base class for classes directly owning variational parameters.
No more as base class of WFC/SPOSet.
Following this API design.
https://github.com/ye-luo/qmcpack/wiki/Optimization-API-changes

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

  • Refactoring (no functional changes, no api changes)

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

epyc-server

Checklist

  • Yes. This PR is up to date with current the current state of 'develop'

@ye-luo ye-luo marked this pull request as draft August 11, 2022 13:24
@ye-luo ye-luo mentioned this pull request Aug 11, 2022
@ye-luo ye-luo marked this pull request as ready for review August 12, 2022 23:23
@ye-luo
Copy link
Contributor Author

ye-luo commented Aug 15, 2022

@PDoakORNL in this PR OptimizableObject is moved out of base classes and added as a base class only on their derived classes with actual optimizable parameters.

@ye-luo ye-luo requested a review from markdewing August 16, 2022 18:29
@markdewing
Copy link
Contributor

Is there a plan to get rid of checkInVariables and resetParameters in favor of using only checkInVariablesExclusive and resetParametersExclusive? (In other words, is having both functions in the API an intermediate state of the code?)

@markdewing
Copy link
Contributor

Eventually I would like an API that removes the need to call checkOutVariables to propagate the global-to-local index mapping.

@ye-luo
Copy link
Contributor Author

ye-luo commented Aug 16, 2022

Is there a plan to get rid of checkInVariables and resetParameters in favor of using only checkInVariablesExclusive and resetParametersExclusive? (In other words, is having both functions in the API an intermediate state of the code?)

Yes. SPO/WFC level of checkInVariables and resetParameters will be removed. Not there yet ;)

@ye-luo
Copy link
Contributor Author

ye-luo commented Aug 16, 2022

Eventually I would like an API that removes the need to call checkOutVariables to propagate the global-to-local index mapping.

I found checkOutVariables is still needed, it settings internal state for later evaluateDerivatives. In case of ROHF, there is only one set of sposet but there are two objects. So checkOutVariables needs to be called on both objects and thus needs to be called from TWF tree.

PDoakORNL
PDoakORNL previously approved these changes Aug 17, 2022
Copy link
Contributor

@PDoakORNL PDoakORNL left a comment

Choose a reason for hiding this comment

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

I think the documentation is coming along. I think the "Exclusive" name is confusing but I'm not going to push for "NonTraversing" or "Local" that doesn't need to be fixed this PR.

src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp Outdated Show resolved Hide resolved
src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp Outdated Show resolved Hide resolved
* };
* A vector will be created by calling extractOptimizableObjects().
* All the checkInVariables() will be called through this vector and thus
* checkInVariablesExclusive implementation should only handle non-OptimizableObject members.
Copy link
Contributor

Choose a reason for hiding this comment

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

So to me the use of inclusive and exclusive here is not very clear. I immediately thought of it terms of thread when I saw the Exclusive on this method. i.e. only call if you are certain you will be the only caller. Exclusive/Inclusive I might also have the sense of a range that does or doesn't include the endpoints or an operation that checks in any variable not already checked in (XOR/OR).

The difference here is whether the call traverses the implicit tree of optimizables below the object called with checkInVariables or not. So its easier for me to think of it as a "Traversing" checkInVariables (the legacy call) or a NonTraversing the new checkInVariablesExclusive call. Or as a recursive vs. nonrecursive call.

Copy link
Contributor

Choose a reason for hiding this comment

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

It does seem clear in the new design the traversal occurs with extractOptimizableObjects so the checkInVariables must be non traversing.

I don't think this is a bad design especially since the "tree" is adhoc and each "node" used to class handle calling its leaves/branches in an adhoc way.

Now that "tree" traversal is in classes extract method and the checkIn/reset/whatever are in methods that just do that which is better.

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 was taking the notion from inclusive/exclusive timer.

void resetParameters(const opt_variables_type& active);
void reportStatus(std::ostream& os) final;

// extractOptimizableObjectRefs is not enabled in BackflowTransformation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is part of why this object is final? Not sure whether this needs to be documented more at this time but it leaves me wondering why BackFlowTransformation is a special case. This probably really amounts to BackFlow needing better documentation which is beyond this PR.

Copy link
Contributor Author

@ye-luo ye-luo Aug 17, 2022

Choose a reason for hiding this comment

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

Right now there is a Clang compiler warning. Adding final in the class stops the warning. BackFlowTransformation should never be inherited and thus I think adding final is OK.

@ye-luo
Copy link
Contributor Author

ye-luo commented Aug 17, 2022

@markdewing Does this PR look good to you?

@ye-luo
Copy link
Contributor Author

ye-luo commented Aug 17, 2022

Test this please

@ye-luo ye-luo enabled auto-merge August 17, 2022 17:52
@ye-luo ye-luo merged commit ef397cc into QMCPACK:develop Aug 17, 2022
@ye-luo ye-luo deleted the update-optojb branch August 17, 2022 23:24
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