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

J1Spin indexing issue #4612

Merged
merged 8 commits into from
Jun 1, 2023
Merged

J1Spin indexing issue #4612

merged 8 commits into from
Jun 1, 2023

Conversation

shivupa
Copy link
Contributor

@shivupa shivupa commented May 24, 2023

Proposed changes

This indexing in the spin dependent 1 body jastrow is wrong. I need to figure out a test that triggers this.

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

  • Bugfix

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

AMD workstation

Checklist

  • 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
  • No. Documentation has been added (if appropriate)

@shivupa shivupa changed the title Fix indexing issue J1Spin indexing issue May 24, 2023
Comment on lines 170 to 172
for (int j = 0; j < NumTargetGroups; j++)
if (j == target_type && J1UniqueFunctors[igroup * NumTargetGroups + j] == nullptr)
J1UniqueFunctors[igroup * Nelec + j] = std::move(afunc);
Copy link
Contributor

@quantumsteve quantumsteve May 24, 2023

Choose a reason for hiding this comment

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

Suggested change
for (int j = 0; j < NumTargetGroups; j++)
if (j == target_type && J1UniqueFunctors[igroup * NumTargetGroups + j] == nullptr)
J1UniqueFunctors[igroup * Nelec + j] = std::move(afunc);
if (J1UniqueFunctors[igroup * NumTargetGroups + target_type] == nullptr)
J1UniqueFunctors[igroup * Nelec + target_type] = std::move(afunc);

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the check use igroup * NumTargetGroups and the assignment use igroup * Nelec?

@rcclay
Copy link
Contributor

rcclay commented May 24, 2023

How was this found?

@shivupa
Copy link
Contributor Author

shivupa commented May 24, 2023

I hit this in a positron and Be cluster calculation. I am trying now to make a lightweight version of that system to use as a test

@prckent
Copy link
Contributor

prckent commented May 24, 2023

Important catch. Worth studying the J2 and J3 implementations for similar faults once this is resolved.

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.

Can we have a unit test?

J1UniqueFunctors[i * NumTargetGroups + j] == nullptr)
J1UniqueFunctors[igroup * Nelec + j] = std::move(afunc);
}
{
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 see why loop i is even needed.
J1UniqueFunctors[source_type * NumTargetGroups + target_type]

Copy link
Contributor

Choose a reason for hiding this comment

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

If there were more than one combination of i and j then afunc would be moved multiple times.

Looks like that is happening on line 160 😟

Copy link
Contributor

Choose a reason for hiding this comment

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

Very true. target_type == -1 case seems broken. That needs to be sorted out when unifying J1 and J1Spin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah not sure what I was doing in the past but this was definitely wrong. target_type should only be -1 for spin independent J1 so the radial jastrow builder should never call this function with target_type == -1. I now raise a runtime error if we ever hit that case.

Also, yes, no loop is even needed.

@shivupa
Copy link
Contributor Author

shivupa commented May 25, 2023

Still needs a test

@shivupa
Copy link
Contributor Author

shivupa commented May 25, 2023

Important catch. Worth studying the J2 and J3 implementations for similar faults once this is resolved.

No issues in J2/J3

@shivupa
Copy link
Contributor Author

shivupa commented Jun 1, 2023

Ok I added a test that fails on the current develop only for the cloned version of the Jastrow (which makes sense since I saw this error when performing a Jastrow optimization).


/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:228: FAILED:
  CHECK( cloned_log == LogComplexApprox(expected_log) )
with expansion:
  (-1.74258,0)
  ==
  LogComplexApprox( (-3.58983,0) )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:245: FAILED:
  CHECK( cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]) )
with expansion:
  0.0 == Approx( -2.544 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:247: FAILED:
  CHECK( cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]) )
with expansion:
  -0.0 == Approx( -2.45001 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:245: FAILED:
  CHECK( cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]) )
with expansion:
  0.0 == Approx( -4.70578 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:247: FAILED:
  CHECK( cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]) )
with expansion:
  -0.0 == Approx( 0.0794429 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:245: FAILED:
  CHECK( cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]) )
with expansion:
  0.0 == Approx( -0.055314 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:247: FAILED:
  CHECK( cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]) )
with expansion:
  -0.0 == Approx( 0.0462761 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:245: FAILED:
  CHECK( cloned_dlogpsi[i] == ValueApprox(expected_dlogpsi[i]) )
with expansion:
  0.0 == Approx( -0.770138 )

/home/shiv/Documents/qmcpack/src/QMCWaveFunctions/tests/test_J1Spin.cpp:247: FAILED:
  CHECK( cloned_dhpsioverpsi[i] == ValueApprox(expected_dhpsioverpsi[i]) )
with expansion:
  -0.0 == Approx( -0.330801 )

===============================================================================
test cases:   28 |  27 passed | 1 failed
assertions: 1005 | 996 passed | 9 failed

@shivupa
Copy link
Contributor Author

shivupa commented Jun 1, 2023

Upload coverage step failing in CI. Seems unrelated

@ye-luo
Copy link
Contributor

ye-luo commented Jun 1, 2023

Test this please

@ye-luo
Copy link
Contributor

ye-luo commented Jun 1, 2023

Test this please

@ye-luo ye-luo enabled auto-merge June 1, 2023 21:57
@ye-luo ye-luo merged commit 58424b9 into QMCPACK:develop Jun 1, 2023
@prckent prckent mentioned this pull request Aug 18, 2023
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