-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Avoid DivisionByZero error when TensorNetwork simplifies to a scalar #6586
Avoid DivisionByZero error when TensorNetwork simplifies to a scalar #6586
Conversation
Problem: Python 3.12 requires quimb-1.8.0, but quimb-1.8.0 cannot evaluate path-info for TensorNetwork consisting of a scalar Tensor. Solution: Skip path-info evaluation for scalar TensorNetwork. Path-info is used for RAM estimation only which is not a problem for scalar TensorNetwork-s. This fixes unit test failure for cirq-core/cirq/contrib/quimb/grid_circuits_test.py::test_tensor_expectation_value Ref: jcmgray/quimb#231
path_info = tn.contract(get='path-info') | ||
ram_gb = path_info.largest_intermediate * 128 / 8 / 1024 / 1024 / 1024 | ||
else: | ||
ram_gb = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we raise an error or log a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is needed. The error happens for a trivial TensorNetwork([Tensor()])
for which the memory requirements will be tiny.
The bug was BTW already fixed upstream, but I think we should still merge this so we support the current quimb-1.8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a TODO to remove this when we upgrade quimb ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6586 +/- ##
=======================================
Coverage 97.79% 97.79%
=======================================
Files 1124 1124
Lines 95703 95705 +2
=======================================
+ Hits 93589 93595 +6
+ Misses 2114 2110 -4 ☔ View full report in Codecov by Sentry. |
…uantumlib#6586) Problem: Python 3.12 requires quimb-1.8.0, but quimb-1.8.0 cannot evaluate path-info for TensorNetwork consisting of a scalar Tensor. Solution: Skip path-info evaluation for scalar TensorNetwork. Path-info is used for RAM estimation only which is not a problem for scalar TensorNetwork-s. This fixes unit test failure for cirq-core/cirq/contrib/quimb/grid_circuits_test.py::test_tensor_expectation_value Ref: jcmgray/quimb#231
…uantumlib#6586) Problem: Python 3.12 requires quimb-1.8.0, but quimb-1.8.0 cannot evaluate path-info for TensorNetwork consisting of a scalar Tensor. Solution: Skip path-info evaluation for scalar TensorNetwork. Path-info is used for RAM estimation only which is not a problem for scalar TensorNetwork-s. This fixes unit test failure for cirq-core/cirq/contrib/quimb/grid_circuits_test.py::test_tensor_expectation_value Ref: jcmgray/quimb#231
Problem: Python 3.12 requires quimb-1.8.0, but quimb-1.8.0 cannot
evaluate path-info for TensorNetwork consisting of a scalar Tensor.
Solution: Skip path-info evaluation for scalar TensorNetwork.
Path-info is used for RAM estimation only which is not a problem
for scalar TensorNetwork-s.
This fixes unit test failure for
cirq-core/cirq/contrib/quimb/grid_circuits_test.py::test_tensor_expectation_value
Ref: jcmgray/quimb#231