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

Don't allow batched version to accept hamiltonian estimator input #4643

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

PDoakORNL
Copy link
Contributor

Proposed changes

Prevent legacy estimator inputs in batched input.
This addresses issue #4637

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

Delete the items that do not apply

  • New feature

Does this introduce a breaking change?

  • Yes if a user has these previous ignored input elements in the hamiltonian an exception is thrown and the code halts.

What systems has this change been tested on?

osx laptop

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)

@prckent prckent changed the title Don't allow batched version to except hamiltonian estimator input Don't allow batched version to accept hamiltonian estimator input Jun 24, 2023
@PDoakORNL PDoakORNL marked this pull request as ready for review June 30, 2023 21:08
@@ -176,8 +177,18 @@ bool HamiltonianFactory::build(xmlNodePtr cur)
targetH->addOperator(std::move(hs), "Grid", true);
}
}
else if (cname == "flux")
{
if (potName.size() < 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (potName.size() < 1)
if (potName.empty())

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 thinking of adding legacy_estimator? there is no guarantee we make the legacy ones working but at least users may have a chance to force it.

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'm not in favor of that as it will inhibit refactoring QMCHamiltonian. If there is a batched version the legacy version should be disabled for a batched run.

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 think by the finish of ecp the manual should not include mention of using the tag estimator in the Hamiltonian input node.

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 not in favor of that as it will inhibit refactoring QMCHamiltonian. If there is a batched version the legacy version should be disabled for a batched run.

If there is a batched version, the old input through Hamiltonian should be blocked. What if not? I would prefer giving user a chance to try out things without modifying the source code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think by the finish of ecp the manual should not include mention of using the tag estimator in the Hamiltonian input node.

I agree with this but the reality is we don't port estimators fast enough.

batched = true;
break;
}
ham_pool_->put(cur, batched);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the following work?

ham_pool_->put(cur, my_project_.getDriverVersion() == ProjectData::DriverVersion::BATCH);

If it works, please change the following place as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -45,7 +45,7 @@ class MinimalHamiltonianPool
doc.parseFromString(hamiltonian_xml);

xmlNodePtr root = doc.getRoot();
hpool.put(root);
hpool.put(root,true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please apply clang-format. There should be a space after the comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -176,8 +177,18 @@ bool HamiltonianFactory::build(xmlNodePtr cur)
targetH->addOperator(std::move(hs), "Grid", true);
}
}
else if (cname == "flux")
{
if (potName.size() < 1)
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 thinking of adding legacy_estimator? there is no guarantee we make the legacy ones working but at least users may have a chance to force it.

if (potName.size() < 1)
potName = "flux";
targetH->addOperator(std::make_unique<ConservedEnergy>(), potName, false);
}
else if (cname == "estimator")
Copy link
Contributor

Choose a reason for hiding this comment

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

Change here like cname == "estimator" || cname == "legacy_estimator" and the error check as
if (batched && cname == "estimator")

Copy link
Contributor Author

@PDoakORNL PDoakORNL Jul 17, 2023

Choose a reason for hiding this comment

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

I disagree with this change, legacy estimators that are going to continue to be allowed should be explicitly changed as the flux estimator has been. They are not "estimators" by the definition we will be using coming forward. They should be renabled individually if necessary. Further discussion of this should return to #4637 which this PR addresses, if this is the functionality you think is correct argue for it in #4637 with @jtkrogel and we can amend this PR or make another one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing to flux or legacy_estimator, I prefer the latter a more generic way.
We can only allow using legacy_estimator when batched driver is in use and the selected estimator doesn't have an actual batched implementation.

@@ -80,7 +80,7 @@
<pairpot type="pseudo" name="PseudoPot" source="ion0" wavefunction="psi0" format="xml">
<pseudo elementType="C" href="C.BFD.xml"/>
</pairpot>
<!-- <estimator type="flux" name="Flux"/> -->
<!-- <flux name="Flux"/> -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete this line.

@@ -80,7 +80,7 @@
<pairpot type="pseudo" name="PseudoPot" source="ion0" wavefunction="psi0" format="xml">
<pseudo elementType="C" href="C.BFD.xml"/>
</pairpot>
<!-- <estimator type="flux" name="Flux"/> -->
<!-- <flux name="Flux"/> -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete this line.

Copy link
Contributor Author

@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.

Addressed review

@@ -176,8 +177,18 @@ bool HamiltonianFactory::build(xmlNodePtr cur)
targetH->addOperator(std::move(hs), "Grid", true);
}
}
else if (cname == "flux")
{
if (potName.size() < 1)
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'm not in favor of that as it will inhibit refactoring QMCHamiltonian. If there is a batched version the legacy version should be disabled for a batched run.

@@ -45,7 +45,7 @@ class MinimalHamiltonianPool
doc.parseFromString(hamiltonian_xml);

xmlNodePtr root = doc.getRoot();
hpool.put(root);
hpool.put(root,true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -176,8 +177,18 @@ bool HamiltonianFactory::build(xmlNodePtr cur)
targetH->addOperator(std::move(hs), "Grid", true);
}
}
else if (cname == "flux")
{
if (potName.size() < 1)
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 think by the finish of ecp the manual should not include mention of using the tag estimator in the Hamiltonian input node.

batched = true;
break;
}
ham_pool_->put(cur, batched);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

@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 consider this PR complete in its solution to #4637. I will not further update it to track develop unless it is approved.

if (potName.size() < 1)
potName = "flux";
targetH->addOperator(std::make_unique<ConservedEnergy>(), potName, false);
}
else if (cname == "estimator")
Copy link
Contributor Author

@PDoakORNL PDoakORNL Jul 17, 2023

Choose a reason for hiding this comment

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

I disagree with this change, legacy estimators that are going to continue to be allowed should be explicitly changed as the flux estimator has been. They are not "estimators" by the definition we will be using coming forward. They should be renabled individually if necessary. Further discussion of this should return to #4637 which this PR addresses, if this is the functionality you think is correct argue for it in #4637 with @jtkrogel and we can amend this PR or make another one.

@PDoakORNL PDoakORNL force-pushed the protect_from_estimator_input_in_qmchamiltonian_in_batched branch from b4b4c40 to 3101da4 Compare July 17, 2023 19:29
@PDoakORNL PDoakORNL enabled auto-merge (squash) July 17, 2023 19:29
@prckent
Copy link
Contributor

prckent commented Jul 21, 2023

Taking a look at this, we are not going to add legacy_estimator in future. We need to focus on estimators for the batched code and not get entangled with supporting more legacy. This would take time, resources and tackling complexity we should simply not engage with. Users should use updated estimators for the batched code or simply run an older version until their needed estimator is available.

@jtkrogel Are you OK with <flux name="Flux"/> and the changes here? My opinion is that this is mergable now.

@prckent
Copy link
Contributor

prckent commented Jul 21, 2023

Test this please

@jtkrogel
Copy link
Contributor

I don't understand the need for changing the notation around "flux" (<flux/>). It is a statistical estimator (<estimator/>). It should be ported (or not) to the batched code under the same conditions as all the rest.

For the purpose of this PR, the only requirement I see is that <estimator/>'s are banished from <hamiltonian/>. The priority around moving other estimators to the batched code framework is separate.

Perhaps we just learned that "flux" is a higher priority estimator for porting than others. I don't think that should hold up the rest of the work here.

@ye-luo
Copy link
Contributor

ye-luo commented Jul 21, 2023

I feel unnecessary to introduce <flux name="Flux"/>. If we decide to allow such estimators still in the Hamiltonian input section, having legacy_estimator input style is more generic. Users needs to opt-in if they really want to try such a feature and the experience is allowed to be a hit and miss. In the current situation, we block everything and porting is slow.

@PDoakORNL
Copy link
Contributor Author

I think it is desirable to block everything that has not been examined and properly ported.

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.

5 participants