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

Fix bug making TaskBasedCpuContractor different from TensorNetwork #6

Merged
merged 5 commits into from
May 17, 2021

Conversation

trevor-vincent
Copy link
Contributor

@trevor-vincent trevor-vincent commented May 16, 2021

Context:

We removed the swap from PathInfo but apparently we forgot to remove the node swap from TensorNetwork.hpp, this will definitely cause TaskBasedCpuContractor and TensorNetwork to get different results. Now they get the same result.

Description of the Change:

  • Three lines in TensorNetwork.hpp (which caused a discrepancy from TaskBasedCpuContractor.hpp) have been removed.
  • The GEMV binding for vector-matrix multiplication now transposes the matrix.

Benefits:

  • TaskBasedCpuContractor.hpp and TensorNetwork.hpp now get the same answer all the time.

Possible Drawbacks:

Nothing

Related GitHub Issues:

None

@github-actions
Copy link

github-actions bot commented May 16, 2021

Test Report (C++) on Ubuntu

    1 files  ±0      1 suites  ±0   0s ⏱️ ±0s
217 tests ±0  217 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
485 runs  ±0  485 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 5949562. ± Comparison against base commit 5949562.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented May 16, 2021

Test Report (C++) on MacOS

    1 files  ±0      1 suites  ±0   0s ⏱️ ±0s
217 tests ±0  217 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
485 runs  ±0  485 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 5949562. ± Comparison against base commit 5949562.

♻️ This comment has been updated with latest results.

mlxd
mlxd previously approved these changes May 17, 2021
Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Great job on finding this! All looks good on tests to me.

Though, I think we should create a separate task to contract a network (provided we are fine storing data in the repo), and compare the existing methods. This will also be useful with the GPU work coming down the line.

@mlxd mlxd dismissed their stale review May 17, 2021 13:25

Additional checks may be required

@mlxd
Copy link
Member

mlxd commented May 17, 2021

Just ran some comparisons on the same network against cotengra, and getting different contraction results with the same data and path. Is it possible to confirm the output from the changes here are commensurate with other packages?

Copy link
Collaborator

@Mandrenkov Mandrenkov left a comment

Choose a reason for hiding this comment

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

Nice catch!

That said, I don't quite understand how the ordering of two contracted nodes causes a discrepancy between the output of TensorNetwork::Contract() and TaskBasedCpuContractor::Contract(). Doesn't removing the swap just permute the indices of the node given by the contraction of two nodes? How does this change influence the value of an output scalar?

@Mandrenkov
Copy link
Collaborator

I've pushed a change to the GEMV binding which fixes a problem with the following contraction:

Tensor lhs({"i"}, {2}, {0, 1});
Tensor rhs({"i", "j"}, {2, 3}, {0, 1, 2, 3, 4, 5});
Tensor con = ContractTensors(lhs, rhs); // Before: {1, 4, 0}, Now: {3, 4, 5}

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

New changes look good to me! Nice work.

@trevor-vincent
Copy link
Contributor Author

Thanks Mikhail and Lee!

Copy link
Collaborator

@Mandrenkov Mandrenkov left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@trevor-vincent trevor-vincent merged commit 5949562 into main May 17, 2021
@trevor-vincent trevor-vincent deleted the fix-bug branch May 17, 2021 18:06
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