Skip to content

Keep up with quimb-1.5.0 #6087

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

Merged
merged 7 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cirq-core/cirq/contrib/quimb/state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def tensor_expectation_value(
if ram_gb > max_ram_gb:
raise MemoryError(f"We estimate that this contraction will take too much RAM! {ram_gb} GB")
e_val = tn.contract(inplace=True)
if isinstance(e_val, qtn.TensorNetwork):
e_val = e_val.item()
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAICT, the contraction above will always produce a scalar, so why not call item unconditionally?

e_val = tn.contract(inplace=True).item()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With quimb-1.4.2 tn.contract() may return a standard float which does not have the item method.
We could do e_val = np.asarray(tn.contract(...)).item(), but that is IMO harder to parse for humans than above. :)

We could also require quimb==1.5, but I feel that is a bit imposing on anyone installing cirq.

assert e_val.imag < tol
assert cast(complex, pauli_string.coefficient).imag < tol
return e_val.real * pauli_string.coefficient
3 changes: 3 additions & 0 deletions dev_tools/notebooks/notebook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
from dev_tools.notebooks import filter_notebooks, list_all_notebooks, rewrite_notebook

SKIP_NOTEBOOKS = [
# TODO(#6088) - enable notebooks below
'cirq-core/cirq/contrib/quimb/Contract-a-Grid-Circuit.ipynb',
# End of TODO(#6088)
# skipping vendor notebooks as we don't have auth sorted out
'**/aqt/*.ipynb',
'**/azure-quantum/*.ipynb',
Expand Down