Skip to content

Commit

Permalink
Minimum required version of quimb. (#3272)
Browse files Browse the repository at this point in the history
Alternatively, you can comment out `state_vector.py` line 150.

Fixes gh-3263
  • Loading branch information
mpharrigan committed Aug 28, 2020
1 parent 431d986 commit 1699cb3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cirq/contrib/quimb/state_vector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import Sequence, Union, List, Tuple, Dict, Optional

import numpy as np
Expand All @@ -6,6 +7,8 @@

import cirq

QUIMB_VERSION = tuple(int(x) for x in quimb.__version__.split('.'))


def circuit_to_tensors(circuit: cirq.Circuit,
qubits: Optional[Sequence[cirq.Qid]] = None,
Expand Down Expand Up @@ -147,7 +150,13 @@ def tensor_expectation_value(circuit: cirq.Circuit,
tags={'Q0', 'bra0'}) for q in qubits
]
tn = qtn.TensorNetwork(tensors + end_bras)
tn.rank_simplify(inplace=True)
if QUIMB_VERSION < (1, 3):
# coverage: ignore
warnings.warn('Please use quimb>=1.3 for optimal performance in '
'`tensor_expectation_value`. '
'See https://github.com/quantumlib/Cirq/issues/3263')
else:
tn.rank_simplify(inplace=True)
path_info = tn.contract(get='path-info')
ram_gb = path_info.largest_intermediate * 128 / 8 / 1024 / 1024 / 1024
if ram_gb > max_ram_gb:
Expand Down

0 comments on commit 1699cb3

Please sign in to comment.