Skip to content

module 'cirq.study' has no attribute 'ResultDict' #708

@RubensZimbres

Description

@RubensZimbres

Hello, I'm following the Colab notebook at https://www.tensorflow.org/quantum/tutorials/hello_many_worlds, downloaded the code and I'm running on Visual Studio. When I installed cirq for the first time, it worked. Now that I installed tensorflow-quantum==0.72 and tensorflow==2.7.0 I get the above error.

I created a Python 3.8 environment in Anaconda and installed tensorflow==2.7.0 and tensorflow-quantum==0.7.2

When I run:

import simpy import cirq

I get the following error:

AttributeError: module 'cirq.study' has no attribute 'ResultDict'

Also,
tensorflow-quantum 0.7.2 requires cirq-core==0.13.1, but you have cirq-core 1.0.0 which is incompatible. tensorflow-quantum 0.7.2 requires protobuf==3.17.3, but you have protobuf 3.20.1 which is incompatible.

! pip install cirq-core==0.13.1 ! pip install protobuf==3.17.3

But it didn't work.

Details of the error:

`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [2], in <cell line: 2>()
1 import tensorflow as tf
----> 2 import tensorflow_quantum as tfq
4 import sympy
5 import cirq

File ~/.local/lib/python3.8/site-packages/tensorflow_quantum/init.py:18, in
15 """Module functions for tensorflow_quantum.*"""
17 # Import basic ops and op getters.
---> 18 from tensorflow_quantum.core import (append_circuit, get_expectation_op,
19 get_sampled_expectation_op,
20 get_sampling_op, get_state_op,
21 get_unitary_op, padded_to_ragged,
22 padded_to_ragged2d, resolve_parameters)
24 # Import math ops.
25 from tensorflow_quantum.core import math_ops as math

File ~/.local/lib/python3.8/site-packages/tensorflow_quantum/core/init.py:17, in
15 """Imports to tensorflow_quantum.core.* level."""
16 # Import getters for constructing ops.
---> 17 from tensorflow_quantum.core.ops import (get_expectation_op,
18 get_sampled_expectation_op,
19 get_sampling_op, get_state_op,
20 get_unitary_op)
21 # Import regular ops.
22 from tensorflow_quantum.core.ops import (append_circuit, padded_to_ragged,
23 padded_to_ragged2d, resolve_parameters)

File ~/.local/lib/python3.8/site-packages/tensorflow_quantum/core/ops/init.py:18, in
15 """Module for tfq.core.ops.*"""
17 # Import getters for constructing ops.
---> 18 from tensorflow_quantum.core.ops.circuit_execution_ops import (
19 get_expectation_op, get_sampled_expectation_op, get_sampling_op,
20 get_state_op)
22 from tensorflow_quantum.core.ops.tfq_unitary_op import get_unitary_op
23 from tensorflow_quantum.core.ops.tfq_utility_ops import (append_circuit,
24 padded_to_ragged,
25 padded_to_ragged2d,
26 resolve_parameters)

File ~/.local/lib/python3.8/site-packages/tensorflow_quantum/core/ops/circuit_execution_ops.py:18, in
15 """A module for user-facing generators of tfq ops."""
16 import enum
---> 18 import cirq
20 from tensorflow_quantum.core.ops import (cirq_ops, tfq_simulate_ops,
21 tfq_utility_ops)
22 from tensorflow_quantum.python import quantum_context

File ~/.local/lib/python3.8/site-packages/cirq/init.py:624, in
616 # pylint: enable=redefined-builtin
617
618 # Unflattened sub-modules.
620 from cirq import (
621 testing,
622 )
--> 624 _compat.deprecated_submodule(
625 new_module_name='cirq_google',
626 old_parent=name,
627 old_child='google',
628 deadline="v0.14",
629 create_attribute=True,
630 )
632 _compat.deprecated_submodule(
633 new_module_name='cirq_aqt',
634 old_parent=name,
(...)
637 create_attribute=True,
638 )
641 _compat.deprecated_submodule(
642 new_module_name='cirq_ionq',
643 old_parent=name,
(...)
646 create_attribute=True,
647 )

File ~/.local/lib/python3.8/site-packages/cirq/_compat.py:626, in deprecated_submodule(new_module_name, old_parent, old_child, deadline, create_attribute)
624 if create_attribute:
625 try:
--> 626 new_module = importlib.import_module(new_module_name)
627 _setup_deprecated_submodule_attribute(
628 new_module_name, old_parent, old_child, deadline, new_module
629 )
630 except ImportError as ex:

File /usr/lib/python3.8/importlib/init.py:127, in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File ~/.local/lib/python3.8/site-packages/cirq_google/init.py:23, in
19 from cirq_google import api
21 from cirq_google._version import version
---> 23 from cirq_google.calibration import (
24 ALL_ANGLES_FLOQUET_PHASED_FSIM_CHARACTERIZATION,
25 CircuitWithCalibration,
26 FloquetPhasedFSimCalibrationOptions,
27 FloquetPhasedFSimCalibrationRequest,
28 FSimPhaseCorrections,
29 PhasedFSimCalibrationError,
30 PhasedFSimCalibrationOptions,
31 PhasedFSimCalibrationRequest,
32 PhasedFSimCalibrationResult,
33 PhasedFSimCharacterization,
34 PhasedFSimEngineSimulator,
35 XEBPhasedFSimCalibrationOptions,
36 XEBPhasedFSimCalibrationRequest,
37 LocalXEBPhasedFSimCalibrationOptions,
38 LocalXEBPhasedFSimCalibrationRequest,
39 SQRT_ISWAP_INV_PARAMETERS,
40 THETA_ZETA_GAMMA_FLOQUET_PHASED_FSIM_CHARACTERIZATION,
41 make_zeta_chi_gamma_compensation_for_moments,
42 make_zeta_chi_gamma_compensation_for_operations,
43 merge_matching_results,
44 prepare_characterization_for_circuits_moments,
45 prepare_floquet_characterization_for_moments,
46 prepare_characterization_for_moments,
47 prepare_floquet_characterization_for_moment,
48 prepare_characterization_for_moment,
49 prepare_floquet_characterization_for_operations,
50 prepare_characterization_for_operations,
51 run_calibrations,
52 run_floquet_characterization_for_moments,
53 run_zeta_chi_gamma_compensation_for_moments,
54 try_convert_sqrt_iswap_to_fsim,
55 WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION,
56 )
58 from cirq_google.devices import (
59 GoogleNoiseProperties,
60 GridDevice,
(...)
63 Sycamore23,
64 )
66 from cirq_google.engine import (
67 Calibration,
68 CalibrationLayer,
(...)
82 noise_properties_from_calibration,
83 )

File ~/.local/lib/python3.8/site-packages/cirq_google/calibration/init.py:17, in
1 # Copyright 2021 The Cirq Developers
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """Functions for calling the calibration API and characterizing qubits."""
---> 17 from cirq_google.calibration.engine_simulator import PhasedFSimEngineSimulator
19 from cirq_google.calibration.phased_fsim import (
20 ALL_ANGLES_FLOQUET_PHASED_FSIM_CHARACTERIZATION,
21 FloquetPhasedFSimCalibrationOptions,
(...)
38 try_convert_syc_or_sqrt_iswap_to_fsim,
39 )
41 from cirq_google.calibration.workflow import (
42 CircuitWithCalibration,
43 FSimPhaseCorrections,
(...)
55 run_zeta_chi_gamma_compensation_for_moments,
56 )

File ~/.local/lib/python3.8/site-packages/cirq_google/calibration/engine_simulator.py:32, in
30 import cirq
31 from cirq import value
---> 32 from cirq_google.calibration.phased_fsim import (
33 FloquetPhasedFSimCalibrationRequest,
34 PhaseCalibratedFSimGate,
35 IncompatibleMomentError,
36 PhasedFSimCalibrationRequest,
37 PhasedFSimCalibrationResult,
38 PhasedFSimCharacterization,
39 SQRT_ISWAP_INV_PARAMETERS,
40 try_convert_gate_to_fsim,
41 try_convert_sqrt_iswap_to_fsim,
42 )
44 ParametersDriftGenerator = Callable[[cirq.Qid, cirq.Qid, cirq.FSimGate], PhasedFSimCharacterization]
45 PhasedFsimDictParameters = Dict[
46 Tuple[cirq.Qid, cirq.Qid], Union[Dict[str, float], PhasedFSimCharacterization]
47 ]

File ~/.local/lib/python3.8/site-packages/cirq_google/calibration/phased_fsim.py:44, in
42 from cirq.experiments.xeb_fitting import XEBPhasedFSimCharacterizationOptions
43 from cirq_google.api import v2
---> 44 from cirq_google.engine import (
45 Calibration,
46 CalibrationLayer,
47 CalibrationResult,
48 Engine,
49 EngineJob,
50 util,
51 )
52 from cirq_google.ops import FSimGateFamily, SycamoreGate
54 if TYPE_CHECKING:

File ~/.local/lib/python3.8/site-packages/cirq_google/engine/init.py:18, in
1 # Copyright 2018 The Cirq Developers
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """Client for running on Google's Quantum Engine.
16 """
---> 18 from cirq_google.engine.abstract_engine import AbstractEngine
20 from cirq_google.engine.abstract_job import AbstractJob
22 from cirq_google.engine.abstract_processor import AbstractProcessor

File ~/.local/lib/python3.8/site-packages/cirq_google/engine/abstract_engine.py:26, in
24 import cirq
25 from cirq_google.cloud import quantum
---> 26 from cirq_google.engine import abstract_job, abstract_program, abstract_processor
28 VALID_DATE_TYPE = Union[datetime.datetime, datetime.date]
31 class AbstractEngine(abc.ABC):

File ~/.local/lib/python3.8/site-packages/cirq_google/engine/abstract_job.py:23, in
21 import cirq
22 from cirq_google.cloud import quantum
---> 23 from cirq_google.engine.engine_result import EngineResult
25 if TYPE_CHECKING:
26 import datetime

File ~/.local/lib/python3.8/site-packages/cirq_google/engine/engine_result.py:25, in
21 if TYPE_CHECKING:
22 import cirq
---> 25 class EngineResult(study.ResultDict):
26 """A ResultDict with additional job metadata.
27
28 Please see the documentation for cirq.ResultDict for more information.
(...)
32 job_finished_time: A timestamp for when the job finished.
33 """
35 def init(
36 self,
37 *, # Forces keyword args.
(...)
42 records: Optional[Mapping[str, np.ndarray]] = None,
43 ):

AttributeError: module 'cirq.study' has no attribute 'ResultDict'`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions