mirror of https://github.com/Qiskit/qiskit.git
Remove legacy simulators (#1615)
* Removing simulators * Fixing some test * Fixing test * Test * Email * Fixing test * Passing locally * Hack to get aer * Diego fix * Trying to fix windows errors * Aer to basicaer * Adding lint * Removing test around and making aer only on one folder. * Adding HACK FROM THE DEPTHS OF DESPAIR AS AER DOES NOT WORK ON MAC * Oops Diego hack I did not implement correctly * Linting * do not import Aer at the top of tests * lint * two more CHANGELOG lines
This commit is contained in:
parent
8245a11be4
commit
b2bbb3f059
|
@ -29,6 +29,7 @@ stage_generic: &stage_generic
|
|||
# Install step for jobs that require compilation and qa.
|
||||
- pip install -U -r requirements.txt
|
||||
- pip install -U -r requirements-dev.txt
|
||||
- pip install qiskit-aer
|
||||
# Create the basic cmake structure, setting out/ as the default dir.
|
||||
- mkdir out && cd out && cmake $CMAKE_FLAGS ..
|
||||
script:
|
||||
|
@ -140,7 +141,7 @@ jobs:
|
|||
|
||||
# Run the tests against without compilation (GNU/Linux, Python 3.5)
|
||||
- stage: lint and pure python test
|
||||
<<: *stage_linux_no_compile
|
||||
<<: *stage_linux
|
||||
|
||||
# "test" stage
|
||||
###########################################################################
|
||||
|
|
|
@ -24,14 +24,20 @@ Changed
|
|||
-------
|
||||
|
||||
- The ``Exception`` subclasses have been moved to an ``.exceptions`` module
|
||||
within each package (for example, ``qiskit.exceptions.QiskitError``). (#1600).
|
||||
within each package (for example, ``qiskit.exceptions.QiskitError``) (#1600).
|
||||
- The ``QiskitTestCase`` and testing utilities are now included as part of
|
||||
``qiskit.test`` and thus available for third-party implementations. (#1616).
|
||||
``qiskit.test`` and thus available for third-party implementations (#1616)
|
||||
- The snapshot instruction now takes ``label`` and ``snap_type`` instead of
|
||||
``slot`` (#1615).
|
||||
|
||||
Removed
|
||||
-------
|
||||
|
||||
- Removed the wrapper folder as part of the post 0.7 cleanup
|
||||
- Removed the wrapper folder as part of the post 0.7 cleanup (#1613).
|
||||
- Removed the python wrappers of the legacy simualtors now that
|
||||
Qiskit Aer is out (#1615).
|
||||
- Removed simulator instructions ``save``, ``load``, ``wait``, ``noise``
|
||||
as unsupported in Aer (#1615).
|
||||
|
||||
`0.7.0`_ - 2018-12-19
|
||||
=====================
|
||||
|
|
|
@ -35,6 +35,7 @@ install:
|
|||
- pip.exe install jupyter
|
||||
- pip.exe install ipywidgets
|
||||
- pip.exe install stestr
|
||||
- pip.exe install qiskit-aer
|
||||
# TODO(mtreinish): uncomment this when testing-cabal/subunit#33 is fixed
|
||||
# - pip.exe install junitxml
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ __path__ = pkgutil.extend_path(__path__, __name__)
|
|||
# Please note these are global instances, not modules.
|
||||
from qiskit.providers.ibmq import IBMQ
|
||||
from qiskit.providers.builtinsimulators import BasicAer
|
||||
from qiskit.providers.legacysimulators import LegacySimulators
|
||||
|
||||
# Try to import the Aer provider if th Aer element is installed.
|
||||
try:
|
||||
|
|
|
@ -6,8 +6,5 @@
|
|||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""Instructions usable by simulator backends."""
|
||||
from .load import load
|
||||
from .noise import noise
|
||||
from .save import save
|
||||
|
||||
from .snapshot import snapshot
|
||||
from .wait import wait
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""
|
||||
Simulator command to load a saved quantum state.
|
||||
"""
|
||||
from qiskit import QuantumCircuit
|
||||
from qiskit import QuantumRegister
|
||||
from qiskit.circuit import Instruction
|
||||
from qiskit.extensions.exceptions import ExtensionError
|
||||
from qiskit.extensions.standard import header # pylint: disable=unused-import
|
||||
|
||||
|
||||
class Load(Instruction):
|
||||
"""Simulator load instruction."""
|
||||
|
||||
def __init__(self, slot, qubits, circ):
|
||||
"""Create new load instruction."""
|
||||
super().__init__("load", [slot], list(qubits), [], circ)
|
||||
|
||||
def inverse(self):
|
||||
"""Special case. Return self."""
|
||||
return self
|
||||
|
||||
def reapply(self, circ):
|
||||
"""Reapply this instruction to corresponding qubits in circ."""
|
||||
self._modifiers(circ.load(self.param[0]))
|
||||
|
||||
|
||||
def load(self, slot):
|
||||
"""Load the internal simulator representation (statevector, probability,
|
||||
density matrix, clifford table)
|
||||
Works on all qubits, and prevents reordering (like barrier).
|
||||
|
||||
Args:
|
||||
slot (int): a slot to load from
|
||||
|
||||
Returns:
|
||||
QuantumCircuit: with attached command
|
||||
|
||||
Raises:
|
||||
ExtensionError: malformed command
|
||||
"""
|
||||
tuples = []
|
||||
if isinstance(self, QuantumCircuit):
|
||||
for register in self.qregs:
|
||||
tuples.append(register)
|
||||
if not tuples:
|
||||
raise ExtensionError("no qubits for load")
|
||||
if slot is None:
|
||||
raise ExtensionError("no load slot passed")
|
||||
qubits = []
|
||||
for tuple_element in tuples:
|
||||
if isinstance(tuple_element, QuantumRegister):
|
||||
for j in range(tuple_element.size):
|
||||
self._check_qubit((tuple_element, j))
|
||||
qubits.append((tuple_element, j))
|
||||
else:
|
||||
self._check_qubit(tuple_element)
|
||||
qubits.append(tuple_element)
|
||||
self._check_dups(qubits)
|
||||
return self._attach(Load(slot, qubits, self))
|
||||
|
||||
|
||||
# Add to QuantumCircuit class
|
||||
QuantumCircuit.load = load
|
|
@ -1,69 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""
|
||||
Simulator command to toggle noise off or on.
|
||||
"""
|
||||
from qiskit import QuantumCircuit
|
||||
from qiskit import QuantumRegister
|
||||
from qiskit.circuit import Instruction
|
||||
from qiskit.extensions.exceptions import ExtensionError
|
||||
from qiskit.extensions.standard import header # pylint: disable=unused-import
|
||||
|
||||
|
||||
class Noise(Instruction):
|
||||
"""Simulator noise operation."""
|
||||
|
||||
def __init__(self, switch, qubits, circ):
|
||||
"""Create new noise instruction."""
|
||||
super().__init__("noise", [switch], list(qubits), [], circ)
|
||||
|
||||
def inverse(self):
|
||||
"""Special case. Return self."""
|
||||
return self
|
||||
|
||||
def reapply(self, circ):
|
||||
"""Reapply this instruction to corresponding qubits in circ."""
|
||||
self._modifiers(circ.noise(self.param[0]))
|
||||
|
||||
|
||||
def noise(self, switch):
|
||||
"""Turn noise on/off in simulator.
|
||||
Works on all qubits, and prevents reordering (like barrier).
|
||||
|
||||
Args:
|
||||
switch (int): turn noise on (1) or off (0)
|
||||
|
||||
Returns:
|
||||
QuantumCircuit: with attached command
|
||||
|
||||
Raises:
|
||||
ExtensionError: malformed command
|
||||
"""
|
||||
tuples = []
|
||||
if isinstance(self, QuantumCircuit):
|
||||
for register in self.qregs:
|
||||
tuples.append(register)
|
||||
if not tuples:
|
||||
raise ExtensionError("no qubits for noise")
|
||||
if switch is None:
|
||||
raise ExtensionError("no noise switch passed")
|
||||
qubits = []
|
||||
for tuple_element in tuples:
|
||||
if isinstance(tuple_element, QuantumRegister):
|
||||
for j in range(tuple_element.size):
|
||||
self._check_qubit((tuple_element, j))
|
||||
qubits.append((tuple_element, j))
|
||||
else:
|
||||
self._check_qubit(tuple_element)
|
||||
qubits.append(tuple_element)
|
||||
self._check_dups(qubits)
|
||||
return self._attach(Noise(switch, qubits, self))
|
||||
|
||||
|
||||
# Add to QuantumCircuit class
|
||||
QuantumCircuit.noise = noise
|
|
@ -1,70 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""
|
||||
Simulator command to save the quantum state.
|
||||
"""
|
||||
from qiskit import QuantumCircuit
|
||||
from qiskit import QuantumRegister
|
||||
from qiskit.circuit import Instruction
|
||||
from qiskit.extensions.exceptions import ExtensionError
|
||||
from qiskit.extensions.standard import header # pylint: disable=unused-import
|
||||
|
||||
|
||||
class Save(Instruction):
|
||||
"""Simulator save instruction."""
|
||||
|
||||
def __init__(self, slot, qubits, circ):
|
||||
"""Create save save instruction."""
|
||||
super().__init__("save", [slot], list(qubits), [], circ)
|
||||
|
||||
def inverse(self):
|
||||
"""Special case. Return self."""
|
||||
return self
|
||||
|
||||
def reapply(self, circ):
|
||||
"""Reapply this instruction to corresponding qubits in circ."""
|
||||
self._modifiers(circ.save(self.param[0]))
|
||||
|
||||
|
||||
def save(self, slot):
|
||||
"""Save the internal simulator representation (statevector, probability,
|
||||
density matrix, clifford table).
|
||||
Works on all qubits, and prevents reordering (like barrier).
|
||||
|
||||
Args:
|
||||
slot (int): a slot to save into
|
||||
|
||||
Returns:
|
||||
QuantumCircuit: with attached command
|
||||
|
||||
Raises:
|
||||
ExtensionError: malformed command
|
||||
"""
|
||||
tuples = []
|
||||
if isinstance(self, QuantumCircuit):
|
||||
for register in self.qregs:
|
||||
tuples.append(register)
|
||||
if not tuples:
|
||||
raise ExtensionError("no qubits for save")
|
||||
if slot is None:
|
||||
raise ExtensionError("no save slot passed")
|
||||
qubits = []
|
||||
for tuple_element in tuples:
|
||||
if isinstance(tuple_element, QuantumRegister):
|
||||
for j in range(tuple_element.size):
|
||||
self._check_qubit((tuple_element, j))
|
||||
qubits.append((tuple_element, j))
|
||||
else:
|
||||
self._check_qubit(tuple_element)
|
||||
qubits.append(tuple_element)
|
||||
self._check_dups(qubits)
|
||||
return self._attach(Save(slot, qubits, self))
|
||||
|
||||
|
||||
# Add to QuantumCircuit class
|
||||
QuantumCircuit.save = save
|
|
@ -18,9 +18,9 @@ from qiskit.extensions.standard import header # pylint: disable=unused-import
|
|||
class Snapshot(Instruction):
|
||||
"""Simulator snapshot instruction."""
|
||||
|
||||
def __init__(self, slot, qubits, circ):
|
||||
def __init__(self, label, snap_type, qubits, circ):
|
||||
"""Create new snapshot instruction."""
|
||||
super().__init__("snapshot", [slot], list(qubits), [], circ)
|
||||
super().__init__("snapshot", [label, snap_type], list(qubits), [], circ)
|
||||
|
||||
def inverse(self):
|
||||
"""Special case. Return self."""
|
||||
|
@ -28,16 +28,16 @@ class Snapshot(Instruction):
|
|||
|
||||
def reapply(self, circ):
|
||||
"""Reapply this instruction to corresponding qubits in circ."""
|
||||
self._modifiers(circ.snapshot(self.param[0]))
|
||||
self._modifiers(circ.snapshot(self.param[0], self.param[1]))
|
||||
|
||||
|
||||
def snapshot(self, slot):
|
||||
"""Take a snapshot of the internal simulator representation (statevector,
|
||||
probability, density matrix, clifford table)
|
||||
def snapshot(self, label, snap_type='statevector'):
|
||||
"""Take a snapshot of the internal simulator representation (statevector)
|
||||
Works on all qubits, and prevents reordering (like barrier).
|
||||
|
||||
Args:
|
||||
slot (int): a snapshot slot to report the result
|
||||
label (str): a snapshot label to report the result
|
||||
snap_type (str): a snapshot type (only supports statevector)
|
||||
|
||||
Returns:
|
||||
QuantumCircuit: with attached command
|
||||
|
@ -51,8 +51,8 @@ def snapshot(self, slot):
|
|||
tuples.append(register)
|
||||
if not tuples:
|
||||
raise ExtensionError("no qubits for snapshot")
|
||||
if slot is None:
|
||||
raise ExtensionError("no snapshot slot passed")
|
||||
if label is None:
|
||||
raise ExtensionError("no snapshot label passed")
|
||||
qubits = []
|
||||
for tuple_element in tuples:
|
||||
if isinstance(tuple_element, QuantumRegister):
|
||||
|
@ -63,7 +63,7 @@ def snapshot(self, slot):
|
|||
self._check_qubit(tuple_element)
|
||||
qubits.append(tuple_element)
|
||||
self._check_dups(qubits)
|
||||
return self._attach(Snapshot(slot, qubits, self))
|
||||
return self._attach(Snapshot(label, snap_type, qubits, self))
|
||||
|
||||
|
||||
# Add to QuantumCircuit class
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
"""
|
||||
Aer's qasm_simulator single qubit wait gate.
|
||||
"""
|
||||
from qiskit import QuantumCircuit
|
||||
from qiskit import QuantumRegister
|
||||
from qiskit.circuit import Gate
|
||||
from qiskit.circuit import InstructionSet
|
||||
from qiskit.qasm import _node as node
|
||||
|
||||
|
||||
class WaitGate(Gate): # pylint: disable=abstract-method
|
||||
"""Wait gate."""
|
||||
|
||||
def __init__(self, t, qubit, circ=None):
|
||||
"""Create new wait gate."""
|
||||
super().__init__("wait", [t], [qubit], circ)
|
||||
|
||||
def inverse(self):
|
||||
"""Invert this gate."""
|
||||
return self # self-inverse
|
||||
|
||||
def reapply(self, circ):
|
||||
"""Reapply this gate to corresponding qubits in circ."""
|
||||
self._modifiers(circ.wait(self.param[0], self.qargs[0]))
|
||||
|
||||
|
||||
def wait(self, t, q):
|
||||
"""Apply wait for time t to q."""
|
||||
if isinstance(q, QuantumRegister):
|
||||
gs = InstructionSet()
|
||||
for j in range(q.size):
|
||||
gs.add(self.wait(t, (q, j)))
|
||||
return gs
|
||||
self._check_qubit(q)
|
||||
return self._attach(WaitGate(t, q, self))
|
||||
|
||||
|
||||
# Add to QuantumCircuit class
|
||||
QuantumCircuit.wait = wait
|
||||
|
||||
# idle for time t (identity)
|
||||
QuantumCircuit.definitions["wait"] = {
|
||||
"print": False,
|
||||
"opaque": False,
|
||||
"n_args": 1,
|
||||
"n_bits": 1,
|
||||
"args": ["t"],
|
||||
"bits": ["a"],
|
||||
# gate wait(t) a { }
|
||||
"body": node.GateBody([])
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""Legacy C++ simulators from Qiskit versions prior to 0.7"""
|
||||
|
||||
from .legacyprovider import LegacyProvider
|
||||
from .qasm_simulator import QasmSimulator, CliffordSimulator
|
||||
from .statevector_simulator import StatevectorSimulator
|
||||
|
||||
LegacySimulators = LegacyProvider() # pylint: disable=invalid-name
|
|
@ -1,78 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""Provider for C++ simulator backends coming from the built-in Aer in versions prior to 0.7"""
|
||||
|
||||
import logging
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
|
||||
from qiskit.exceptions import QiskitError
|
||||
from qiskit.providers.builtinsimulators import SimulatorsProvider
|
||||
|
||||
from .qasm_simulator import QasmSimulator, CliffordSimulator
|
||||
from .statevector_simulator import StatevectorSimulator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
LEGACY_SIMULATORS = [
|
||||
QasmSimulator,
|
||||
StatevectorSimulator,
|
||||
CliffordSimulator
|
||||
]
|
||||
|
||||
DEPRECATION_MSG = """Simulators in the LegacySimulators provider are deprecated. If you want
|
||||
maximum compatibility, you can use those in the Simulators provider. If you want to make the most
|
||||
of performance, consider installing the Qiskit Aer element and user the Aer provider."""
|
||||
|
||||
|
||||
class LegacyProvider(SimulatorsProvider):
|
||||
"""Provider for legacy simulators backends."""
|
||||
|
||||
def backends(self, name=None, filters=None, **kwargs):
|
||||
warnings.warn(DEPRECATION_MSG, DeprecationWarning)
|
||||
return super().backends(name=name, filter=filters, **kwargs)
|
||||
|
||||
def get_backend(self, name=None, **kwargs):
|
||||
warnings.warn(DEPRECATION_MSG, DeprecationWarning)
|
||||
return super().get_backend(name=name, **kwargs)
|
||||
|
||||
def _verify_backends(self):
|
||||
"""
|
||||
Return the legacy simulators backends in `LEGACY_SIMULATORS` that are
|
||||
effectively available (as some of them might depend on the presence
|
||||
of an optional dependency or on the existence of a binary).
|
||||
|
||||
Returns:
|
||||
dict[str:BaseBackend]: a dict of legacy simulators backend instances for
|
||||
the backends that could be instantiated, keyed by backend name.
|
||||
"""
|
||||
ret = OrderedDict()
|
||||
for backend_cls in LEGACY_SIMULATORS:
|
||||
try:
|
||||
backend_instance = self._get_backend_instance(backend_cls)
|
||||
backend_name = backend_instance.name()
|
||||
ret[backend_name] = backend_instance
|
||||
except QiskitError as err:
|
||||
# Ignore backends that could not be initialized.
|
||||
logger.info('legacy simulator %s is not available: %s',
|
||||
backend_cls, str(err))
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def _deprecated_backend_names():
|
||||
"""Returns deprecated backend names."""
|
||||
return {
|
||||
'local_qasm_simulator_cpp': 'qasm_simulator',
|
||||
'local_statevector_simulator_cpp': 'statevector_simulator',
|
||||
'local_qiskit_simulator': 'qasm_simulator',
|
||||
'local_qasm_simulator': 'qasm_simulator',
|
||||
'local_statevector_simulator': 'statevector_simulator'
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
return 'LegacySimulators'
|
|
@ -1,517 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""
|
||||
Interface to C++ quantum circuit simulator with realistic noise.
|
||||
"""
|
||||
|
||||
|
||||
import uuid
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
from subprocess import PIPE
|
||||
import platform
|
||||
|
||||
from math import log2
|
||||
import numpy as np
|
||||
from qiskit._util import local_hardware_info
|
||||
from qiskit.providers.models import BackendConfiguration
|
||||
from qiskit.providers import BaseBackend
|
||||
from qiskit.providers.builtinsimulators.simulatorsjob import SimulatorsJob
|
||||
from qiskit.result import Result
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
EXTENSION = '.exe' if platform.system() == 'Windows' else ''
|
||||
|
||||
# Add path to compiled qasm simulator
|
||||
DEFAULT_SIMULATOR_PATHS = [
|
||||
# This is the path where Makefile creates the simulator by default
|
||||
os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'../../../out/src/qasm-simulator-cpp/qasm_simulator_cpp'
|
||||
+ EXTENSION)),
|
||||
# This is the path where PIP installs the simulator
|
||||
os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'qasm_simulator_cpp' + EXTENSION)),
|
||||
]
|
||||
|
||||
|
||||
class QasmSimulator(BaseBackend):
|
||||
"""C++ quantum circuit simulator with realistic noise"""
|
||||
|
||||
DEFAULT_CONFIGURATION = {
|
||||
'backend_name': 'qasm_simulator',
|
||||
'backend_version': '1.0.0',
|
||||
'n_qubits': int(log2(local_hardware_info()['memory'] * (1024**3)/16)),
|
||||
'url': 'https://github.com/Qiskit/qiskit-terra/src/qasm-simulator-cpp',
|
||||
'simulator': True,
|
||||
'local': True,
|
||||
'conditional': True,
|
||||
'open_pulse': False,
|
||||
'memory': True,
|
||||
'max_shots': 65536,
|
||||
'description': 'A C++ realistic noise simulator for qasm experiments',
|
||||
'basis_gates': ['u0', 'u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z',
|
||||
'h', 's', 'sdg', 't', 'tdg', 'rzz', 'snapshot', 'wait',
|
||||
'noise', 'save', 'load'],
|
||||
'gates': [
|
||||
{
|
||||
'name': 'u0',
|
||||
'parameters': ['gamma'],
|
||||
'qasm_def': 'gate u0(gamma) q { U(0,0,0) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'u1',
|
||||
'parameters': ['lambda'],
|
||||
'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'u2',
|
||||
'parameters': ['phi', 'lambda'],
|
||||
'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'u3',
|
||||
'parameters': ['theta', 'phi', 'lambda'],
|
||||
'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'cx',
|
||||
'parameters': ['c', 't'],
|
||||
'qasm_def': 'gate cx c,t { CX c,t; }'
|
||||
},
|
||||
{
|
||||
'name': 'cz',
|
||||
'parameters': ['a', 'b'],
|
||||
'qasm_def': 'gate cz a,b { h b; cx a,b; h b; }'
|
||||
},
|
||||
{
|
||||
'name': 'id',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate id a { U(0,0,0) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'x',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate x a { u3(pi,0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'y',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate y a { u3(pi,pi/2,pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'z',
|
||||
'parameters': ['z'],
|
||||
'qasm_def': 'gate z a { u1(pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'h',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate h a { u2(0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 's',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate s a { u1(pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'sdg',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate sdg a { u1(-pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 't',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate t a { u1(pi/4) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'tdg',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate tdg a { u1(-pi/4) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'rzz',
|
||||
'parameters': ['theta', 'a', 'b'],
|
||||
'qasm_def': 'gate rzz(theta) a,b { cx a,b; u1(theta) b; cx a,b; }'
|
||||
},
|
||||
{
|
||||
'name': 'snapshot',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate snapshot(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'wait',
|
||||
'parameters': ['t'],
|
||||
'qasm_def': 'gate wait(t) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'noise',
|
||||
'parameters': ['switch'],
|
||||
'qasm_def': 'gate noise(switch) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'save',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate save(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'load',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate load(slot) q { TODO }'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def __init__(self, configuration=None, provider=None):
|
||||
super().__init__(configuration=(configuration or
|
||||
BackendConfiguration.from_dict(self.DEFAULT_CONFIGURATION)),
|
||||
provider=provider)
|
||||
|
||||
# Try to use the default executable if not specified.
|
||||
if 'exe' in self._configuration:
|
||||
paths = [self._configuration.exe]
|
||||
else:
|
||||
paths = DEFAULT_SIMULATOR_PATHS
|
||||
|
||||
# Ensure that the executable is available.
|
||||
try:
|
||||
self._configuration.exe = next(
|
||||
path for path in paths if (os.path.exists(path) and
|
||||
os.path.getsize(path) > 100))
|
||||
except StopIteration:
|
||||
raise FileNotFoundError('Simulator executable not found (using %s)' %
|
||||
getattr(self._configuration, 'exe', 'default locations'))
|
||||
|
||||
def run(self, qobj):
|
||||
"""Run a qobj on the backend."""
|
||||
job_id = str(uuid.uuid4())
|
||||
job = SimulatorsJob(self, job_id, self._run_job, qobj)
|
||||
job.submit()
|
||||
return job
|
||||
|
||||
def _run_job(self, job_id, qobj):
|
||||
"""Run a Qobj on the backend."""
|
||||
self._validate(qobj)
|
||||
qobj_dict = qobj.as_dict()
|
||||
result = run(qobj_dict, self._configuration.exe)
|
||||
result['job_id'] = job_id
|
||||
|
||||
# Ensure that the required results fields are present, even if the
|
||||
# job failed.
|
||||
result['results'] = result.get('results', [])
|
||||
result['qobj_id'] = result.get('qobj_id', 'unavailable')
|
||||
result['backend_name'] = result.get('backend_name', self.name())
|
||||
result['backend_version'] = result.get('backend_version',
|
||||
self.configuration().backend_version)
|
||||
|
||||
return Result.from_dict(result)
|
||||
|
||||
def _validate(self, qobj):
|
||||
for experiment in qobj.experiments:
|
||||
if 'measure' not in [op.name for
|
||||
op in experiment.instructions]:
|
||||
logger.warning("no measurements in circuit '%s', "
|
||||
"classical register will remain all zeros.",
|
||||
experiment.header.name)
|
||||
|
||||
|
||||
class CliffordSimulator(BaseBackend):
|
||||
""""C++ Clifford circuit simulator with realistic noise."""
|
||||
|
||||
DEFAULT_CONFIGURATION = {
|
||||
'backend_name': 'clifford_simulator',
|
||||
'backend_version': '1.0.0',
|
||||
'n_qubits': int(log2(local_hardware_info()['memory'] * (1024**3)/16)),
|
||||
'url': 'https://github.com/Qiskit/qiskit-terra/src/qasm-simulator-cpp',
|
||||
'simulator': True,
|
||||
'local': True,
|
||||
'conditional': True,
|
||||
'open_pulse': False,
|
||||
'memory': False,
|
||||
'max_shots': 65536,
|
||||
'description': 'A C++ Clifford simulator with approximate noise',
|
||||
'basis_gates': ['cx', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'snapshot',
|
||||
'wait', 'noise', 'save', 'load'],
|
||||
'gates': [
|
||||
{
|
||||
'name': 'cx',
|
||||
'parameters': ['c', 't'],
|
||||
'qasm_def': 'gate cx c,t { CX c,t; }'
|
||||
},
|
||||
{
|
||||
'name': 'id',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate id a { U(0,0,0) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'x',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate x a { u3(pi,0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'y',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate y a { u3(pi,pi/2,pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'z',
|
||||
'parameters': ['z'],
|
||||
'qasm_def': 'gate z a { u1(pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'h',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate h a { u2(0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 's',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate s a { u1(pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'sdg',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate sdg a { u1(-pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'snapshot',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate snapshot(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'wait',
|
||||
'parameters': ['t'],
|
||||
'qasm_def': 'gate wait(t) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'noise',
|
||||
'parameters': ['switch'],
|
||||
'qasm_def': 'gate noise(switch) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'save',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate save(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'load',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate load(slot) q { TODO }'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def __init__(self, configuration=None, provider=None):
|
||||
super().__init__(configuration=(configuration or
|
||||
BackendConfiguration.from_dict(self.DEFAULT_CONFIGURATION)),
|
||||
provider=provider)
|
||||
|
||||
# Try to use the default executable if not specified.
|
||||
if 'exe' in self._configuration:
|
||||
paths = [self._configuration.exe]
|
||||
else:
|
||||
paths = DEFAULT_SIMULATOR_PATHS
|
||||
|
||||
# Ensure that the executable is available.
|
||||
try:
|
||||
self._configuration.exe = next(
|
||||
path for path in paths if (os.path.exists(path) and
|
||||
os.path.getsize(path) > 100))
|
||||
except StopIteration:
|
||||
raise FileNotFoundError('Simulator executable not found (using %s)' %
|
||||
getattr(self._configuration, 'exe', 'default locations'))
|
||||
|
||||
def run(self, qobj):
|
||||
"""Run a Qobj on the backend.
|
||||
|
||||
Args:
|
||||
qobj (dict): job description
|
||||
|
||||
Returns:
|
||||
SimulatorsJob: derived from BaseJob
|
||||
"""
|
||||
job_id = str(uuid.uuid4())
|
||||
job = SimulatorsJob(self, job_id, self._run_job, qobj)
|
||||
job.submit()
|
||||
return job
|
||||
|
||||
def _run_job(self, job_id, qobj):
|
||||
qobj_dict = qobj.as_dict()
|
||||
self._validate()
|
||||
# set backend to Clifford simulator
|
||||
if 'config' in qobj_dict:
|
||||
qobj_dict['config']['simulator'] = 'clifford'
|
||||
else:
|
||||
qobj_dict['config'] = {'simulator': 'clifford'}
|
||||
result = run(qobj_dict, self._configuration.exe)
|
||||
result['job_id'] = job_id
|
||||
|
||||
# Ensure that the required results fields are present, even if the
|
||||
# job failed.
|
||||
result['results'] = result.get('results', [])
|
||||
result['qobj_id'] = result.get('qobj_id', 'unavailable')
|
||||
result['backend_name'] = result.get('backend_name', self.name())
|
||||
result['backend_version'] = result.get('backend_version',
|
||||
self.configuration().backend_version)
|
||||
|
||||
return Result.from_dict(result)
|
||||
|
||||
def _validate(self):
|
||||
return
|
||||
|
||||
|
||||
def run(qobj, executable):
|
||||
"""
|
||||
Run simulation on C++ simulator inside a subprocess.
|
||||
|
||||
Args:
|
||||
qobj (Qobj): qobj dictionary defining the simulation to run
|
||||
executable (string): filename (with path) of the simulator executable
|
||||
Returns:
|
||||
dict: A dict of simulation results
|
||||
"""
|
||||
|
||||
# Open subprocess and execute external command
|
||||
try:
|
||||
with subprocess.Popen([executable, '-'],
|
||||
stdin=PIPE, stdout=PIPE, stderr=PIPE) as proc:
|
||||
cin = json.dumps(qobj).encode()
|
||||
cout, cerr = proc.communicate(cin)
|
||||
if cerr:
|
||||
logger.error('ERROR: Simulator encountered a runtime error: %s',
|
||||
cerr.decode())
|
||||
sim_output = json.loads(cout.decode())
|
||||
return sim_output
|
||||
except FileNotFoundError:
|
||||
msg = "ERROR: Simulator exe not found at: %s" % executable
|
||||
logger.error(msg)
|
||||
return {'status': msg, 'success': False}
|
||||
|
||||
|
||||
def cx_error_matrix(cal_error, zz_error):
|
||||
"""
|
||||
Return the coherent error matrix for CR error model of a CNOT gate.
|
||||
|
||||
Args:
|
||||
cal_error (double): calibration error of rotation
|
||||
zz_error (double): ZZ interaction term error
|
||||
|
||||
Returns:
|
||||
numpy.ndarray: A coherent error matrix U_error for the CNOT gate.
|
||||
|
||||
Details:
|
||||
|
||||
The ideal cross-resonsance (CR) gate corresponds to a 2-qubit rotation
|
||||
U_CR_ideal = exp(-1j * (pi/2) * XZ/2)
|
||||
|
||||
where qubit-0 is the control, and qubit-1 is the target. This can be
|
||||
converted to a CNOT gate by single-qubit rotations::
|
||||
|
||||
U_CX = U_L * U_CR_ideal * U_R
|
||||
|
||||
The noisy rotation is implemented as
|
||||
U_CR_noise = exp(-1j * (pi/2 + cal_error) * (XZ + zz_error ZZ)/2)
|
||||
|
||||
The retured error matrix is given by
|
||||
U_error = U_L * U_CR_noise * U_R * U_CX^dagger
|
||||
"""
|
||||
# pylint: disable=invalid-name
|
||||
if cal_error == 0 and zz_error == 0:
|
||||
return np.eye(4)
|
||||
|
||||
cx_ideal = np.array([[1, 0, 0, 0],
|
||||
[0, 0, 0, 1],
|
||||
[0, 0, 1, 0],
|
||||
[0, 1, 0, 0]])
|
||||
b = np.sqrt(1.0 + zz_error * zz_error)
|
||||
a = b * (np.pi / 2.0 + cal_error) / 2.0
|
||||
sp = (1.0 + 1j * zz_error) * np.sin(a) / b
|
||||
sm = (1.0 - 1j * zz_error) * np.sin(a) / b
|
||||
c = np.cos(a)
|
||||
cx_noise = np.array([[c + sm, 0, -1j * (c - sm), 0],
|
||||
[0, 1j * (c - sm), 0, c + sm],
|
||||
[-1j * (c - sp), 0, c + sp, 0],
|
||||
[0, c + sp, 0, 1j * (c - sp)]]) / np.sqrt(2)
|
||||
return cx_noise.dot(cx_ideal.conj().T)
|
||||
|
||||
|
||||
def x90_error_matrix(cal_error, detuning_error):
|
||||
"""
|
||||
Return the coherent error matrix for a X90 rotation gate.
|
||||
|
||||
Args:
|
||||
cal_error (double): calibration error of rotation
|
||||
detuning_error (double): detuning amount for rotation axis error
|
||||
|
||||
Returns:
|
||||
numpy.ndarray: A coherent error matrix U_error for the X90 gate.
|
||||
|
||||
Details:
|
||||
|
||||
The ideal X90 rotation is a pi/2 rotation about the X-axis:
|
||||
U_X90_ideal = exp(-1j (pi/2) X/2)
|
||||
|
||||
The noisy rotation is implemented as
|
||||
U_X90_noise = exp(-1j (pi/2 + cal_error) (cos(d) X + sin(d) Y)/2)
|
||||
|
||||
where d is the detuning_error.
|
||||
|
||||
The retured error matrix is given by
|
||||
U_error = U_X90_noise * U_X90_ideal^dagger
|
||||
"""
|
||||
# pylint: disable=invalid-name
|
||||
if cal_error == 0 and detuning_error == 0:
|
||||
return np.eye(2)
|
||||
else:
|
||||
x90_ideal = np.array([[1., -1.j], [-1.j, 1]]) / np.sqrt(2)
|
||||
c = np.cos(0.5 * cal_error)
|
||||
s = np.sin(0.5 * cal_error)
|
||||
gamma = np.exp(-1j * detuning_error)
|
||||
x90_noise = np.array([[c - s, -1j * (c + s) * gamma],
|
||||
[-1j * (c + s) * np.conj(gamma), c - s]]) / np.sqrt(2)
|
||||
return x90_noise.dot(x90_ideal.conj().T)
|
||||
|
||||
|
||||
def _generate_coherent_error_matrix(config):
|
||||
"""
|
||||
Generate U_error matrix for CX and X90 gates.
|
||||
|
||||
Args:
|
||||
config (dict): the config of a qobj circuit
|
||||
|
||||
This parses the config for the following noise parameter keys and returns a
|
||||
coherent error matrix for simulation coherent noise::
|
||||
|
||||
* 'CX' gate: 'calibration_error', 'zz_error'
|
||||
* 'X90' gate: 'calibration_error', 'detuning_error'
|
||||
"""
|
||||
# pylint: disable=invalid-name
|
||||
if 'noise_params' in config:
|
||||
# Check for CR coherent error parameters
|
||||
if 'CX' in config['noise_params']:
|
||||
noise_cx = config['noise_params']['CX']
|
||||
cal_error = noise_cx.pop('calibration_error', 0)
|
||||
zz_error = noise_cx.pop('zz_error', 0)
|
||||
# Add to current coherent error matrix
|
||||
if not cal_error == 0 or not zz_error == 0:
|
||||
u_error = noise_cx.get('U_error', np.eye(4))
|
||||
u_error = u_error.dot(cx_error_matrix(cal_error, zz_error))
|
||||
config['noise_params']['CX']['U_error'] = u_error
|
||||
# Check for X90 coherent error parameters
|
||||
if 'X90' in config['noise_params']:
|
||||
noise_x90 = config['noise_params']['X90']
|
||||
cal_error = noise_x90.pop('calibration_error', 0)
|
||||
detuning_error = noise_x90.pop('detuning_error', 0)
|
||||
# Add to current coherent error matrix
|
||||
if not cal_error == 0 or not detuning_error == 0:
|
||||
u_error = noise_x90.get('U_error', np.eye(2))
|
||||
u_error = u_error.dot(x90_error_matrix(cal_error,
|
||||
detuning_error))
|
||||
config['noise_params']['X90']['U_error'] = u_error
|
|
@ -1,202 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
"""
|
||||
Interface to C++ quantum circuit simulator with realistic noise.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import uuid
|
||||
from math import log2
|
||||
from numpy import array
|
||||
|
||||
from qiskit._util import local_hardware_info
|
||||
from qiskit.providers.models import BackendConfiguration
|
||||
from qiskit.qobj import QobjInstruction
|
||||
from qiskit.providers.builtinsimulators import SimulatorsJob, SimulatorError
|
||||
|
||||
from .qasm_simulator import QasmSimulator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StatevectorSimulator(QasmSimulator):
|
||||
"""C++ statevector simulator"""
|
||||
|
||||
DEFAULT_CONFIGURATION = {
|
||||
'backend_name': 'statevector_simulator',
|
||||
'backend_version': '1.0.0',
|
||||
'n_qubits': int(log2(local_hardware_info()['memory'] * (1024**3)/16)),
|
||||
'url': 'https://github.com/Qiskit/qiskit-terra/src/qasm-simulator-cpp',
|
||||
'simulator': True,
|
||||
'local': True,
|
||||
'conditional': False,
|
||||
'open_pulse': False,
|
||||
'memory': False,
|
||||
'max_shots': 65536,
|
||||
'description': 'A single-shot C++ statevector simulator for the |0> state evolution',
|
||||
'basis_gates': ['u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h',
|
||||
's', 'sdg', 't', 'tdg', 'rzz', 'load', 'save',
|
||||
'snapshot'],
|
||||
'gates': [
|
||||
{
|
||||
'name': 'u1',
|
||||
'parameters': ['lambda'],
|
||||
'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'u2',
|
||||
'parameters': ['phi', 'lambda'],
|
||||
'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'u3',
|
||||
'parameters': ['theta', 'phi', 'lambda'],
|
||||
'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'
|
||||
},
|
||||
{
|
||||
'name': 'cx',
|
||||
'parameters': ['c', 't'],
|
||||
'qasm_def': 'gate cx c,t { CX c,t; }'
|
||||
},
|
||||
{
|
||||
'name': 'cz',
|
||||
'parameters': ['a', 'b'],
|
||||
'qasm_def': 'gate cz a,b { h b; cx a,b; h b; }'
|
||||
},
|
||||
{
|
||||
'name': 'id',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate id a { U(0,0,0) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'x',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate x a { u3(pi,0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'y',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate y a { u3(pi,pi/2,pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'z',
|
||||
'parameters': ['z'],
|
||||
'qasm_def': 'gate z a { u1(pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'h',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate h a { u2(0,pi) a; }'
|
||||
},
|
||||
{
|
||||
'name': 's',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate s a { u1(pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'sdg',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate sdg a { u1(-pi/2) a; }'
|
||||
},
|
||||
{
|
||||
'name': 't',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate t a { u1(pi/4) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'tdg',
|
||||
'parameters': ['a'],
|
||||
'qasm_def': 'gate tdg a { u1(-pi/4) a; }'
|
||||
},
|
||||
{
|
||||
'name': 'rzz',
|
||||
'parameters': ['theta', 'a', 'b'],
|
||||
'qasm_def': 'gate rzz(theta) a,b { cx a,b; u1(theta) b; cx a,b; }'
|
||||
},
|
||||
{
|
||||
'name': 'load',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate load(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'save',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate save(slot) q { TODO }'
|
||||
},
|
||||
{
|
||||
'name': 'snapshot',
|
||||
'parameters': ['slot'],
|
||||
'qasm_def': 'gate snapshot(slot) q { TODO }'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def __init__(self, configuration=None, provider=None):
|
||||
super().__init__(configuration=(configuration or
|
||||
BackendConfiguration.from_dict(self.DEFAULT_CONFIGURATION)),
|
||||
provider=provider)
|
||||
|
||||
def run(self, qobj):
|
||||
"""Run a qobj on the backend."""
|
||||
job_id = str(uuid.uuid4())
|
||||
job = SimulatorsJob(self, job_id, self._run_job, qobj)
|
||||
job.submit()
|
||||
return job
|
||||
|
||||
def _run_job(self, job_id, qobj):
|
||||
"""Run a Qobj on the backend."""
|
||||
self._validate(qobj)
|
||||
final_state_key = 32767 # Internal key for final state snapshot
|
||||
# Add final snapshots to circuits
|
||||
for experiment in qobj.experiments:
|
||||
experiment.instructions.append(
|
||||
QobjInstruction(name='snapshot', params=[final_state_key],
|
||||
label='MISSING', type='MISSING')
|
||||
)
|
||||
result = super()._run_job(job_id, qobj)
|
||||
# Remove added snapshot from qobj
|
||||
for experiment in qobj.experiments:
|
||||
del experiment.instructions[-1]
|
||||
# Extract final state snapshot and move to 'statevector' data field
|
||||
for experiment_result in result.results:
|
||||
snapshots = experiment_result.data.snapshots.to_dict()
|
||||
if str(final_state_key) in snapshots['statevector']:
|
||||
final_state_key = str(final_state_key)
|
||||
# Pop off final snapshot added above
|
||||
final_state = snapshots['statevector'].pop(final_state_key)[0]
|
||||
final_state = array([v[0] + 1j * v[1] for v in final_state], dtype=complex)
|
||||
# Add final state to results data
|
||||
experiment_result.data.statevector = final_state
|
||||
# Remove snapshot dict if empty
|
||||
if snapshots == {}:
|
||||
delattr(experiment_result.data, 'snapshots')
|
||||
return result
|
||||
|
||||
def _validate(self, qobj):
|
||||
"""Semantic validations of the qobj which cannot be done via schemas.
|
||||
Some of these may later move to backend schemas.
|
||||
|
||||
1. No shots
|
||||
2. No measurements in the middle
|
||||
"""
|
||||
if qobj.config.shots != 1:
|
||||
logger.info("statevector simulator only supports 1 shot. "
|
||||
"Setting shots=1.")
|
||||
qobj.config.shots = 1
|
||||
for experiment in qobj.experiments:
|
||||
if getattr(experiment.config, 'shots', 1) != 1:
|
||||
logger.info("statevector simulator only supports 1 shot. "
|
||||
"Setting shots=1 for circuit %s.", experiment.name)
|
||||
experiment.config.shots = 1
|
||||
for op in experiment.instructions:
|
||||
if op.name in ['measure', 'reset']:
|
||||
raise SimulatorError(
|
||||
"In circuit {}: statevector simulator does not support "
|
||||
"measure or reset.".format(experiment.header.name))
|
|
@ -92,6 +92,7 @@ class QiskitTestCase(unittest.TestCase):
|
|||
TypeError: raises TestCase failureException if the test fails.
|
||||
"""
|
||||
def valid_comparison(value):
|
||||
"""compare value to delta, within places accuracy"""
|
||||
if places is not None:
|
||||
return round(value, places) == 0
|
||||
else:
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
import functools
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from qiskit.providers.ibmq.credentials import Credentials, discover_credentials
|
||||
from qiskit.providers.legacysimulators import QasmSimulator
|
||||
|
||||
from .utils import Path
|
||||
from .http_recorder import http_recorder
|
||||
|
@ -25,9 +25,12 @@ def is_cpp_simulator_available():
|
|||
Returns:
|
||||
bool: True if simulator executable is available
|
||||
"""
|
||||
# TODO: HACK FROM THE DEPTHS OF DESPAIR AS AER DOES NOT WORK ON MAC
|
||||
if sys.platform == 'darwin':
|
||||
return False
|
||||
try:
|
||||
QasmSimulator()
|
||||
except FileNotFoundError:
|
||||
import qiskit.providers.aer # pylint: disable=unused-import
|
||||
except ImportError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ class DagUnroller:
|
|||
# Extensions should not be hardcoded in the DAGUnroller.
|
||||
extra_fields = None
|
||||
if current_node["op"].name == "snapshot":
|
||||
extra_fields = {'type': 'MISSING', 'label': 'MISSING',
|
||||
extra_fields = {'type': str(current_node["op"].param[1]),
|
||||
'label': str(current_node["op"].param[0]),
|
||||
'texparams': []}
|
||||
|
||||
self.backend.start_gate(current_node["op"],
|
||||
|
|
2
setup.py
2
setup.py
|
@ -95,7 +95,7 @@ setup(
|
|||
quantum circuits easily, and takes care of the constraints of real hardware.""",
|
||||
url="https://github.com/Qiskit/qiskit-terra",
|
||||
author="Qiskit Development Team",
|
||||
author_email="qiskit@us.ibm.com",
|
||||
author_email="qiskit@qiskit.org",
|
||||
license="Apache 2.0",
|
||||
classifiers=[
|
||||
"Environment :: Console",
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""Qiskit built-in simulators and legacy simulators integration tests."""
|
||||
"""Qiskit BasicAer integration tests."""
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
|
||||
"""Tests for all BasicAer simulators."""
|
||||
|
||||
from qiskit import BasicAer
|
||||
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
|
||||
from qiskit import compile # pylint: disable=redefined-builtin
|
||||
from qiskit.qobj import QobjHeader
|
||||
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
class TestBasicAerQobj(QiskitTestCase):
|
||||
"""Tests for all the Terra simulators."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
qr = QuantumRegister(1)
|
||||
cr = ClassicalRegister(1)
|
||||
self.qc1 = QuantumCircuit(qr, cr, name='circuit0')
|
||||
self.qc1.h(qr[0])
|
||||
|
||||
def test_qobj_headers_in_result(self):
|
||||
"""Test that the qobj headers are passed onto the results."""
|
||||
custom_qobj_header = {'x': 1, 'y': [1, 2, 3], 'z': {'a': 4}}
|
||||
|
||||
for backend in BasicAer.backends():
|
||||
with self.subTest(backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
# Update the Qobj header.
|
||||
qobj.header = QobjHeader.from_dict(custom_qobj_header)
|
||||
# Update the Qobj.experiment header.
|
||||
qobj.experiments[0].header.some_field = 'extra info'
|
||||
|
||||
result = backend.run(qobj).result()
|
||||
self.assertEqual(result.header.to_dict(), custom_qobj_header)
|
||||
self.assertEqual(result.results[0].header.some_field,
|
||||
'extra info')
|
||||
|
||||
def test_job_qobj(self):
|
||||
"""Test job.qobj()."""
|
||||
for backend in BasicAer.backends():
|
||||
with self.subTest(backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
job = backend.run(qobj)
|
||||
self.assertEqual(job.qobj(), qobj)
|
|
@ -0,0 +1,65 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=unused-import
|
||||
# pylint: disable=redefined-builtin
|
||||
|
||||
"""Test Qiskit's QuantumCircuit class for multiple registers."""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from qiskit import BasicAer
|
||||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
||||
from qiskit import compile, execute
|
||||
from qiskit import QiskitError
|
||||
from qiskit.quantum_info import state_fidelity, process_fidelity, Pauli, basis_state
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
class TestCircuitMultiRegs(QiskitTestCase):
|
||||
"""QuantumCircuit Qasm tests."""
|
||||
|
||||
def test_circuit_multi(self):
|
||||
"""Test circuit multi regs declared at start.
|
||||
"""
|
||||
qreg0 = QuantumRegister(2, 'q0')
|
||||
creg0 = ClassicalRegister(2, 'c0')
|
||||
qreg1 = QuantumRegister(2, 'q1')
|
||||
creg1 = ClassicalRegister(2, 'c1')
|
||||
circ = QuantumCircuit(qreg0, qreg1)
|
||||
circ.x(qreg0[1])
|
||||
circ.x(qreg1[0])
|
||||
|
||||
meas = QuantumCircuit(qreg0, qreg1, creg0, creg1)
|
||||
meas.measure(qreg0, creg0)
|
||||
meas.measure(qreg1, creg1)
|
||||
|
||||
qc = circ + meas
|
||||
|
||||
backend_sim = BasicAer.get_backend('qasm_simulator')
|
||||
qobj_qc = compile(qc, backend_sim, seed_mapper=34342)
|
||||
qobj_circ = compile(circ, backend_sim, seed_mapper=3438)
|
||||
|
||||
result = backend_sim.run(qobj_qc).result()
|
||||
counts = result.get_counts(qc)
|
||||
|
||||
target = {'01 10': 1024}
|
||||
|
||||
backend_sim = BasicAer.get_backend('statevector_simulator')
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
state = result.get_statevector(circ)
|
||||
|
||||
backend_sim = BasicAer.get_backend('unitary_simulator')
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
unitary = result.get_unitary(circ)
|
||||
|
||||
self.assertEqual(counts, target)
|
||||
self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state), 1.0, places=7)
|
||||
self.assertAlmostEqual(process_fidelity(Pauli(label='IXXI').to_matrix(), unitary),
|
||||
1.0, places=7)
|
|
@ -6,23 +6,23 @@
|
|||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=missing-docstring,redefined-builtin
|
||||
from sys import version_info
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
|
||||
from qiskit import compile
|
||||
from qiskit.providers.builtinsimulators.qasm_simulator import QasmSimulatorPy
|
||||
from qiskit import BasicAer
|
||||
|
||||
from ..common import QiskitTestCase, Path
|
||||
|
||||
|
||||
class TestBuiltinQasmSimulatorPy(QiskitTestCase):
|
||||
"""Test the built-in qasm_simulator."""
|
||||
class TestBasicAerQasmSimulator(QiskitTestCase):
|
||||
"""Test the Basic qasm_simulator."""
|
||||
|
||||
def setUp(self):
|
||||
self.seed = 88
|
||||
self.backend = QasmSimulatorPy()
|
||||
self.backend = BasicAer.get_backend('qasm_simulator')
|
||||
qasm_filename = self._get_resource_path('example.qasm', Path.QASMS)
|
||||
compiled_circuit = QuantumCircuit.from_qasm_file(qasm_filename)
|
||||
compiled_circuit.name = 'test'
|
||||
|
@ -32,7 +32,7 @@ class TestBuiltinQasmSimulatorPy(QiskitTestCase):
|
|||
"""Test single shot run."""
|
||||
shots = 1
|
||||
self.qobj.config.shots = shots
|
||||
result = QasmSimulatorPy().run(self.qobj).result()
|
||||
result = self.backend.run(self.qobj).result()
|
||||
self.assertEqual(result.success, True)
|
||||
|
||||
def test_qasm_simulator(self):
|
||||
|
@ -79,9 +79,6 @@ class TestBuiltinQasmSimulatorPy(QiskitTestCase):
|
|||
self.assertEqual(counts_if_true, {'111': 100})
|
||||
self.assertEqual(counts_if_false, {'001': 100})
|
||||
|
||||
@unittest.skipIf(version_info.minor == 5,
|
||||
"Due to gate ordering issues with Python 3.5 "
|
||||
"we have to disable this test until fixed")
|
||||
def test_teleport(self):
|
||||
"""test teleportation as in tutorials"""
|
||||
self.log.info('test_teleport')
|
|
@ -15,11 +15,6 @@ from os import path
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from qiskit.providers.legacysimulators import QasmSimulator
|
||||
from qiskit.providers.legacysimulators import StatevectorSimulator
|
||||
from qiskit.providers.builtinsimulators import QasmSimulatorPy
|
||||
from qiskit.providers.builtinsimulators import StatevectorSimulatorPy
|
||||
from qiskit.providers.builtinsimulators import UnitarySimulatorPy
|
||||
from ..common import QiskitTestCase
|
||||
from .._mockutils import new_fake_qobj, FakeBackend
|
||||
|
||||
|
@ -27,14 +22,6 @@ from .._mockutils import new_fake_qobj, FakeBackend
|
|||
class TestSimulatorsJob(QiskitTestCase):
|
||||
"""Test how backends create SimulatorsJob objects and the SimulatorsJob class."""
|
||||
|
||||
_backends = [
|
||||
QasmSimulator,
|
||||
QasmSimulatorPy,
|
||||
StatevectorSimulator,
|
||||
StatevectorSimulatorPy,
|
||||
UnitarySimulatorPy
|
||||
]
|
||||
|
||||
def test_multiple_execution(self):
|
||||
# Notice that it is Python responsibility to test the executors
|
||||
# can run several tasks at the same time. It is our responsibility to
|
|
@ -10,13 +10,12 @@
|
|||
import unittest
|
||||
from qiskit import QuantumCircuit, QuantumRegister
|
||||
from qiskit import execute
|
||||
from qiskit import LegacySimulators
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
from qiskit import BasicAer
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class StatevectorSimulatorTest(QiskitTestCase):
|
||||
"""Test legacy C++ statevector simulator."""
|
||||
"""Test BasicAer statevector simulator."""
|
||||
|
||||
def setUp(self):
|
||||
qr = QuantumRegister(2)
|
||||
|
@ -27,7 +26,7 @@ class StatevectorSimulatorTest(QiskitTestCase):
|
|||
def test_statevector_simulator(self):
|
||||
"""Test final state vector for single circuit run."""
|
||||
result = execute(self.q_circuit,
|
||||
backend=LegacySimulators.get_backend('statevector_simulator')).result()
|
||||
backend=BasicAer.get_backend('statevector_simulator')).result()
|
||||
self.assertEqual(result.success, True)
|
||||
actual = result.get_statevector(self.q_circuit)
|
||||
|
|
@ -13,40 +13,17 @@ import numpy as np
|
|||
|
||||
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
|
||||
from qiskit import compile
|
||||
from qiskit.providers.builtinsimulators.unitary_simulator import UnitarySimulatorPy
|
||||
from ..common import QiskitTestCase, Path
|
||||
from qiskit import BasicAer
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
class BuiltinUnitarySimulatorPyTest(QiskitTestCase):
|
||||
"""Test built-in unitary simulator."""
|
||||
class BasicAerUnitarySimulatorPyTest(QiskitTestCase):
|
||||
"""Test BasicAer unitary simulator."""
|
||||
|
||||
def setUp(self):
|
||||
self.seed = 88
|
||||
self.qasm_filename = self._get_resource_path('example.qasm', Path.QASMS)
|
||||
self.backend = UnitarySimulatorPy()
|
||||
self.backend = BasicAer.get_backend('unitary_simulator')
|
||||
|
||||
def test_unitary_simulator_py(self):
|
||||
"""test generation of circuit unitary"""
|
||||
circuit = QuantumCircuit.from_qasm_file(self.qasm_filename)
|
||||
qobj = compile(circuit, backend=self.backend, shots=1)
|
||||
# strip measurements from circuit to avoid warnings
|
||||
instructions = [op for op in qobj.experiments[0].instructions
|
||||
if op.name != 'measure']
|
||||
qobj.experiments[0].instructions = instructions
|
||||
# numpy.savetxt currently prints complex numbers in a way
|
||||
# loadtxt can't read. To save file do,
|
||||
# fmtstr=['% .4g%+.4gj' for i in range(numCols)]
|
||||
# np.savetxt('example_unitary_matrix.dat', numpyMatrix, fmt=fmtstr,
|
||||
# delimiter=',')
|
||||
expected = np.loadtxt(self._get_resource_path('example_unitary_matrix.dat'),
|
||||
dtype='complex', delimiter=',')
|
||||
|
||||
result = self.backend.run(qobj).result()
|
||||
self.assertTrue(np.allclose(result.get_unitary(circuit),
|
||||
expected,
|
||||
rtol=1e-3))
|
||||
|
||||
def test_builtin_unitary_simulator_py(self):
|
||||
def test_basicaer_unitary_simulator_py(self):
|
||||
"""Test unitary simulator."""
|
||||
circuits = self._test_circuits()
|
||||
qobj = compile(circuits, backend=self.backend)
|
|
@ -14,18 +14,15 @@ import os
|
|||
import tempfile
|
||||
import unittest
|
||||
|
||||
from qiskit import BasicAer, LegacySimulators
|
||||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
||||
from qiskit import compile, execute
|
||||
from qiskit import QiskitError
|
||||
from qiskit.quantum_info import state_fidelity, process_fidelity, Pauli, basis_state
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
from qiskit.converters.circuit_to_dag import circuit_to_dag
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
class TestCircuitMultiRegs(QiskitTestCase):
|
||||
"""QuantumCircuit Qasm tests."""
|
||||
|
||||
@requires_cpp_simulator
|
||||
def test_circuit_multi(self):
|
||||
"""Test circuit multi regs declared at start.
|
||||
"""
|
||||
|
@ -43,45 +40,6 @@ class TestCircuitMultiRegs(QiskitTestCase):
|
|||
|
||||
qc = circ + meas
|
||||
|
||||
backend_sim = BasicAer.get_backend('qasm_simulator')
|
||||
qobj_qc = compile(qc, backend_sim, seed_mapper=34342)
|
||||
qobj_circ = compile(circ, backend_sim, seed_mapper=3438)
|
||||
|
||||
result = backend_sim.run(qobj_qc).result()
|
||||
counts = result.get_counts(qc)
|
||||
|
||||
backend_sim = LegacySimulators.get_backend('qasm_simulator')
|
||||
result = backend_sim.run(qobj_qc).result()
|
||||
counts_py = result.get_counts(qc)
|
||||
|
||||
target = {'01 10': 1024}
|
||||
|
||||
backend_sim = LegacySimulators.get_backend('statevector_simulator')
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
state = result.get_statevector(circ)
|
||||
|
||||
backend_sim = BasicAer.get_backend('statevector_simulator')
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
state_py = result.get_statevector(circ)
|
||||
|
||||
backend_sim = BasicAer.get_backend('unitary_simulator')
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
unitary = result.get_unitary(circ)
|
||||
|
||||
self.assertEqual(counts, target)
|
||||
self.assertEqual(counts_py, target)
|
||||
self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state), 1.0, places=7)
|
||||
self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state_py), 1.0, places=7)
|
||||
self.assertAlmostEqual(process_fidelity(Pauli(label='IXXI').to_matrix(), unitary),
|
||||
1.0, places=7)
|
||||
|
||||
def test_circuit_multi_case2(self):
|
||||
"""Test circuit multi regs declared at start.
|
||||
"""
|
||||
qreg0 = QuantumRegister(2, 'q0')
|
||||
creg0 = ClassicalRegister(2, 'c0')
|
||||
qreg1 = QuantumRegister(2, 'q1')
|
||||
creg1 = ClassicalRegister(2, 'c1')
|
||||
circ2 = QuantumCircuit()
|
||||
circ2.add_register(qreg0)
|
||||
circ2.add_register(qreg1)
|
||||
|
@ -98,20 +56,10 @@ class TestCircuitMultiRegs(QiskitTestCase):
|
|||
|
||||
qc2 = circ2 + meas2
|
||||
|
||||
backend_sim = BasicAer.get_backend('statevector_simulator')
|
||||
result = execute(circ2, backend_sim).result()
|
||||
state = result.get_statevector(circ2)
|
||||
dag_qc = circuit_to_dag(qc)
|
||||
dag_qc2 = circuit_to_dag(qc2)
|
||||
dag_circ2 = circuit_to_dag(circ2)
|
||||
dag_circ = circuit_to_dag(circ)
|
||||
|
||||
backend_sim = BasicAer.get_backend('qasm_simulator')
|
||||
result = execute(qc2, backend_sim).result()
|
||||
counts = result.get_counts(qc2)
|
||||
|
||||
backend_sim = BasicAer.get_backend('unitary_simulator')
|
||||
result = execute(circ2, backend_sim).result()
|
||||
unitary = result.get_unitary(circ2)
|
||||
|
||||
target = {'01 10': 1024}
|
||||
self.assertEqual(target, counts)
|
||||
self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state), 1.0, places=7)
|
||||
self.assertAlmostEqual(process_fidelity(Pauli(label='IXXI').to_matrix(), unitary),
|
||||
1.0, places=7)
|
||||
self.assertEqual(dag_qc, dag_qc2)
|
||||
self.assertEqual(dag_circ, dag_circ2)
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
0.3536+0j, 0.3536-4.33e-17j, 0.3536-4.33e-17j, 0.3536-8.66e-17j, 0.3536-4.33e-17j, 0.3536-8.66e-17j, 0.3536-8.66e-17j, 0.3536-1.299e-16j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j
|
||||
0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0.3536+0j,-0.3536+4.33e-17j, 0.3536-4.33e-17j,-0.3536+8.66e-17j, 0.3536-4.33e-17j,-0.3536+8.66e-17j, 0.3536-8.66e-17j,-0.3536+1.299e-16j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+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0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j, 0+0j
|
|
@ -19,7 +19,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from qiskit import LegacySimulators, QuantumRegister, ClassicalRegister, QuantumCircuit, execute, compile\n",
|
||||
"from qiskit import BasicAer, QuantumRegister, ClassicalRegister, QuantumCircuit, execute, compile\n",
|
||||
"from qiskit.tools.parallel import parallel_map\n",
|
||||
"from qiskit.tools.monitor import job_monitor\n",
|
||||
"from qiskit.tools.events import TextProgressBar\n",
|
||||
|
@ -32,7 +32,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sim_backend = LegacySimulators.get_backend('qasm_simulator')"
|
||||
"sim_backend = BasicAer.get_backend('qasm_simulator')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
"""Qiskit Aer integration tests. These can be removed if they are covered in Aer"""
|
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
|
||||
"""Tests for all BasicAer simulators."""
|
||||
|
||||
import unittest
|
||||
|
||||
import qiskit
|
||||
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
|
||||
from qiskit import compile # pylint: disable=redefined-builtin
|
||||
from qiskit.qobj import QobjHeader
|
||||
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class TestBasicAerQobj(QiskitTestCase):
|
||||
"""Tests for all the Terra simulators."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
qr = QuantumRegister(1)
|
||||
cr = ClassicalRegister(1)
|
||||
self.qc1 = QuantumCircuit(qr, cr, name='circuit0')
|
||||
self.qc1.h(qr[0])
|
||||
|
||||
def test_qobj_headers_in_result(self):
|
||||
"""Test that the qobj headers are passed onto the results."""
|
||||
custom_qobj_header = {'x': 1, 'y': [1, 2, 3], 'z': {'a': 4}}
|
||||
for backend in qiskit.providers.aer.Aer.backends():
|
||||
with self.subTest(backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
# Update the Qobj header.
|
||||
qobj.header = QobjHeader.from_dict(custom_qobj_header)
|
||||
# Update the Qobj.experiment header.
|
||||
qobj.experiments[0].header.some_field = 'extra info'
|
||||
|
||||
result = backend.run(qobj).result()
|
||||
self.assertEqual(result.header.to_dict(), custom_qobj_header)
|
||||
self.assertEqual(result.results[0].header.some_field,
|
||||
'extra info')
|
||||
|
||||
@unittest.skip("skipping as aer does not support. I made an issue")
|
||||
def test_job_qobj(self):
|
||||
"""Test job.qobj()."""
|
||||
for backend in qiskit.providers.aer.Aer.backends():
|
||||
with self.subTest(backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
job = backend.run(qobj)
|
||||
self.assertEqual(job.qobj(), qobj)
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=unused-import
|
||||
|
||||
"""Tests for verifying the correctness of simulator extension instructions."""
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
|
||||
import qiskit
|
||||
import qiskit.extensions.simulator
|
||||
from qiskit.quantum_info import state_fidelity
|
||||
from qiskit.result.postprocess import format_statevector
|
||||
from qiskit import execute
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class TestExtensionsSimulator(QiskitTestCase):
|
||||
"""Test instruction extensions for builtinsimulators simulators:
|
||||
save, load, noise, snapshot, wait
|
||||
"""
|
||||
_desired_fidelity = 0.99
|
||||
|
||||
def test_snapshot(self):
|
||||
"""snapshot a bell state in the middle of circuit"""
|
||||
basis_gates = 'cx,u1,u2,u3,snapshot'
|
||||
qr = qiskit.QuantumRegister(2)
|
||||
cr = qiskit.ClassicalRegister(2)
|
||||
circuit = qiskit.QuantumCircuit(qr, cr)
|
||||
circuit.h(qr[0])
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.snapshot('3')
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.h(qr[1])
|
||||
|
||||
sim = qiskit.providers.aer.StatevectorSimulator()
|
||||
result = execute(circuit, sim, basis_gates=basis_gates).result()
|
||||
# TODO: rely on Result.get_statevector() postprocessing rather than manual
|
||||
snapshots = result.data(0)['snapshots']['statevector']['3']
|
||||
snapshot = format_statevector(snapshots[0])
|
||||
target = [0.70710678 + 0.j, 0. + 0.j, 0. + 0.j, 0.70710678 + 0.j]
|
||||
fidelity = state_fidelity(snapshot, target)
|
||||
self.assertGreater(
|
||||
fidelity, self._desired_fidelity,
|
||||
"snapshot has low fidelity{0:.2g}.".format(fidelity))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
|
@ -0,0 +1,66 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=unused-import
|
||||
# pylint: disable=redefined-builtin
|
||||
|
||||
"""Test Qiskit's QuantumCircuit class for multiple registers."""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import qiskit
|
||||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
||||
from qiskit import compile, execute
|
||||
from qiskit import QiskitError
|
||||
from qiskit.quantum_info import state_fidelity, process_fidelity, Pauli, basis_state
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
class TestCircuitMultiRegs(QiskitTestCase):
|
||||
"""QuantumCircuit Qasm tests."""
|
||||
|
||||
@requires_cpp_simulator
|
||||
def test_circuit_multi(self):
|
||||
"""Test circuit multi regs declared at start.
|
||||
"""
|
||||
qreg0 = QuantumRegister(2, 'q0')
|
||||
creg0 = ClassicalRegister(2, 'c0')
|
||||
qreg1 = QuantumRegister(2, 'q1')
|
||||
creg1 = ClassicalRegister(2, 'c1')
|
||||
circ = QuantumCircuit(qreg0, qreg1)
|
||||
circ.x(qreg0[1])
|
||||
circ.x(qreg1[0])
|
||||
|
||||
meas = QuantumCircuit(qreg0, qreg1, creg0, creg1)
|
||||
meas.measure(qreg0, creg0)
|
||||
meas.measure(qreg1, creg1)
|
||||
|
||||
qc = circ + meas
|
||||
|
||||
backend_sim = qiskit.providers.aer.QasmSimulator()
|
||||
qobj_qc = compile(qc, backend_sim, seed_mapper=34342)
|
||||
qobj_circ = compile(circ, backend_sim, seed_mapper=3438)
|
||||
|
||||
result = backend_sim.run(qobj_qc).result()
|
||||
counts = result.get_counts(qc)
|
||||
|
||||
target = {'01 10': 1024}
|
||||
|
||||
backend_sim = qiskit.providers.aer.StatevectorSimulator()
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
state = result.get_statevector(circ)
|
||||
|
||||
backend_sim = qiskit.providers.aer.UnitarySimulator()
|
||||
result = backend_sim.run(qobj_circ).result()
|
||||
unitary = result.get_unitary(circ)
|
||||
|
||||
self.assertEqual(counts, target)
|
||||
self.assertAlmostEqual(state_fidelity(basis_state('0110', 4), state), 1.0, places=7)
|
||||
self.assertAlmostEqual(process_fidelity(Pauli(label='IXXI').to_matrix(), unitary),
|
||||
1.0, places=7)
|
|
@ -0,0 +1,152 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=missing-docstring,redefined-builtin
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
|
||||
import qiskit
|
||||
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
|
||||
from qiskit import compile
|
||||
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator, Path
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class TestAerQasmSimulator(QiskitTestCase):
|
||||
"""Test the Aer qasm_simulator."""
|
||||
|
||||
def setUp(self):
|
||||
self.seed = 88
|
||||
self.backend = qiskit.providers.aer.QasmSimulator()
|
||||
qasm_filename = self._get_resource_path('example.qasm', Path.QASMS)
|
||||
compiled_circuit = QuantumCircuit.from_qasm_file(qasm_filename)
|
||||
compiled_circuit.name = 'test'
|
||||
self.qobj = compile(compiled_circuit, backend=self.backend)
|
||||
|
||||
def test_qasm_simulator_single_shot(self):
|
||||
"""Test single shot run."""
|
||||
shots = 1
|
||||
self.qobj.config.shots = shots
|
||||
result = self.backend.run(self.qobj).result()
|
||||
self.assertEqual(result.success, True)
|
||||
|
||||
def test_qasm_simulator(self):
|
||||
"""Test data counts output for single circuit run against reference."""
|
||||
result = self.backend.run(self.qobj).result()
|
||||
shots = 1024
|
||||
threshold = 0.04 * shots
|
||||
counts = result.get_counts('test')
|
||||
target = {'100 100': shots / 8, '011 011': shots / 8,
|
||||
'101 101': shots / 8, '111 111': shots / 8,
|
||||
'000 000': shots / 8, '010 010': shots / 8,
|
||||
'110 110': shots / 8, '001 001': shots / 8}
|
||||
self.assertDictAlmostEqual(counts, target, threshold)
|
||||
|
||||
def test_if_statement(self):
|
||||
shots = 100
|
||||
qr = QuantumRegister(3, 'qr')
|
||||
cr = ClassicalRegister(3, 'cr')
|
||||
|
||||
circuit_if_true = QuantumCircuit(qr, cr)
|
||||
circuit_if_true.x(qr[0])
|
||||
circuit_if_true.x(qr[1])
|
||||
circuit_if_true.measure(qr[0], cr[0])
|
||||
circuit_if_true.measure(qr[1], cr[1])
|
||||
circuit_if_true.x(qr[2]).c_if(cr, 0x3)
|
||||
circuit_if_true.measure(qr[0], cr[0])
|
||||
circuit_if_true.measure(qr[1], cr[1])
|
||||
circuit_if_true.measure(qr[2], cr[2])
|
||||
|
||||
circuit_if_false = QuantumCircuit(qr, cr)
|
||||
circuit_if_false.x(qr[0])
|
||||
circuit_if_false.measure(qr[0], cr[0])
|
||||
circuit_if_false.measure(qr[1], cr[1])
|
||||
circuit_if_false.x(qr[2]).c_if(cr, 0x3)
|
||||
circuit_if_false.measure(qr[0], cr[0])
|
||||
circuit_if_false.measure(qr[1], cr[1])
|
||||
circuit_if_false.measure(qr[2], cr[2])
|
||||
qobj = compile([circuit_if_true, circuit_if_false],
|
||||
backend=self.backend, shots=shots, seed=self.seed)
|
||||
|
||||
result = self.backend.run(qobj).result()
|
||||
counts_if_true = result.get_counts(circuit_if_true)
|
||||
counts_if_false = result.get_counts(circuit_if_false)
|
||||
self.assertEqual(counts_if_true, {'111': 100})
|
||||
self.assertEqual(counts_if_false, {'001': 100})
|
||||
|
||||
def test_teleport(self):
|
||||
"""test teleportation as in tutorials"""
|
||||
self.log.info('test_teleport')
|
||||
pi = np.pi
|
||||
shots = 10000
|
||||
qr = QuantumRegister(3, 'qr')
|
||||
cr0 = ClassicalRegister(1, 'cr0')
|
||||
cr1 = ClassicalRegister(1, 'cr1')
|
||||
cr2 = ClassicalRegister(1, 'cr2')
|
||||
circuit = QuantumCircuit(qr, cr0, cr1, cr2, name='teleport')
|
||||
circuit.h(qr[1])
|
||||
circuit.cx(qr[1], qr[2])
|
||||
circuit.ry(pi/4, qr[0])
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.h(qr[0])
|
||||
circuit.barrier(qr)
|
||||
circuit.measure(qr[0], cr0[0])
|
||||
circuit.measure(qr[1], cr1[0])
|
||||
circuit.z(qr[2]).c_if(cr0, 1)
|
||||
circuit.x(qr[2]).c_if(cr1, 1)
|
||||
circuit.measure(qr[2], cr2[0])
|
||||
qobj = compile(circuit, backend=self.backend, shots=shots, seed=self.seed)
|
||||
results = self.backend.run(qobj).result()
|
||||
data = results.get_counts('teleport')
|
||||
alice = {
|
||||
'00': data['0 0 0'] + data['1 0 0'],
|
||||
'01': data['0 1 0'] + data['1 1 0'],
|
||||
'10': data['0 0 1'] + data['1 0 1'],
|
||||
'11': data['0 1 1'] + data['1 1 1']
|
||||
}
|
||||
bob = {
|
||||
'0': data['0 0 0'] + data['0 1 0'] + data['0 0 1'] + data['0 1 1'],
|
||||
'1': data['1 0 0'] + data['1 1 0'] + data['1 0 1'] + data['1 1 1']
|
||||
}
|
||||
self.log.info('test_teleport: circuit:')
|
||||
self.log.info('test_teleport: circuit:')
|
||||
self.log.info(circuit.qasm())
|
||||
self.log.info('test_teleport: data %s', data)
|
||||
self.log.info('test_teleport: alice %s', alice)
|
||||
self.log.info('test_teleport: bob %s', bob)
|
||||
alice_ratio = 1/np.tan(pi/8)**2
|
||||
bob_ratio = bob['0']/float(bob['1'])
|
||||
error = abs(alice_ratio - bob_ratio) / alice_ratio
|
||||
self.log.info('test_teleport: relative error = %s', error)
|
||||
self.assertLess(error, 0.05)
|
||||
|
||||
def test_memory(self):
|
||||
qr = QuantumRegister(4, 'qr')
|
||||
cr0 = ClassicalRegister(2, 'cr0')
|
||||
cr1 = ClassicalRegister(2, 'cr1')
|
||||
circ = QuantumCircuit(qr, cr0, cr1)
|
||||
circ.h(qr[0])
|
||||
circ.cx(qr[0], qr[1])
|
||||
circ.x(qr[3])
|
||||
circ.measure(qr[0], cr0[0])
|
||||
circ.measure(qr[1], cr0[1])
|
||||
circ.measure(qr[2], cr1[0])
|
||||
circ.measure(qr[3], cr1[1])
|
||||
|
||||
shots = 50
|
||||
qobj = compile(circ, backend=self.backend, shots=shots, memory=True)
|
||||
result = self.backend.run(qobj).result()
|
||||
memory = result.get_memory()
|
||||
self.assertEqual(len(memory), shots)
|
||||
for mem in memory:
|
||||
self.assertIn(mem, ['10 00', '10 11'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -14,7 +14,6 @@ import qiskit
|
|||
import qiskit.extensions.simulator
|
||||
from qiskit.quantum_info import state_fidelity
|
||||
from qiskit import execute
|
||||
from qiskit import BasicAer, IBMQ, LegacySimulators
|
||||
from ..common import requires_qe_access, QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
|
@ -31,8 +30,8 @@ class TestCrossSimulation(QiskitTestCase):
|
|||
circuit.h(qr[0])
|
||||
circuit.cx(qr[0], qr[1])
|
||||
|
||||
sim_cpp = LegacySimulators.get_backend('statevector_simulator')
|
||||
sim_py = BasicAer.get_backend('statevector_simulator')
|
||||
sim_cpp = qiskit.providers.aer.StatevectorSimulator()
|
||||
sim_py = qiskit.providers.builtinsimulators.StatevectorSimulatorPy()
|
||||
result_cpp = execute(circuit, sim_cpp).result()
|
||||
result_py = execute(circuit, sim_py).result()
|
||||
statevector_cpp = result_cpp.get_statevector()
|
||||
|
@ -52,8 +51,8 @@ class TestCrossSimulation(QiskitTestCase):
|
|||
circuit.cx(qr[1], qr[2])
|
||||
circuit.measure(qr, cr)
|
||||
|
||||
sim_cpp = LegacySimulators.get_backend('qasm_simulator')
|
||||
sim_py = BasicAer.get_backend('qasm_simulator')
|
||||
sim_cpp = qiskit.providers.aer.QasmSimulator()
|
||||
sim_py = qiskit.providers.builtinsimulators.QasmSimulatorPy()
|
||||
shots = 2000
|
||||
result_cpp = execute(circuit, sim_cpp, shots=shots).result()
|
||||
result_py = execute(circuit, sim_py, shots=shots).result()
|
||||
|
@ -75,8 +74,8 @@ class TestCrossSimulation(QiskitTestCase):
|
|||
circuit.h(qr[2])
|
||||
circuit.measure(qr[2], cr[2])
|
||||
|
||||
sim_cpp = LegacySimulators.get_backend('qasm_simulator')
|
||||
sim_py = BasicAer.get_backend('qasm_simulator')
|
||||
sim_cpp = qiskit.providers.aer.QasmSimulator()
|
||||
sim_py = qiskit.providers.builtinsimulators.QasmSimulatorPy()
|
||||
shots = 1000
|
||||
result_cpp = execute(circuit, sim_cpp, shots=shots, seed=1).result()
|
||||
result_py = execute(circuit, sim_py, shots=shots, seed=1).result()
|
|
@ -0,0 +1,103 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=missing-docstring
|
||||
|
||||
"""SimulatorsJob creation and test suite."""
|
||||
|
||||
import uuid
|
||||
from contextlib import contextmanager
|
||||
from os import path
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from ..common import QiskitTestCase
|
||||
from .._mockutils import new_fake_qobj, FakeBackend
|
||||
|
||||
|
||||
class TestSimulatorsJob(QiskitTestCase):
|
||||
"""Test how backends create SimulatorsJob objects and the SimulatorsJob class."""
|
||||
|
||||
def test_multiple_execution(self):
|
||||
# Notice that it is Python responsibility to test the executors
|
||||
# can run several tasks at the same time. It is our responsibility to
|
||||
# use the executor correctly. That is what this test checks.
|
||||
|
||||
taskcount = 10
|
||||
target_tasks = [lambda: None for _ in range(taskcount)]
|
||||
|
||||
job_id = str(uuid.uuid4())
|
||||
backend = FakeBackend()
|
||||
# pylint: disable=invalid-name,redefined-outer-name
|
||||
with mocked_executor() as (SimulatorJob, executor):
|
||||
for index in range(taskcount):
|
||||
job = SimulatorJob(backend, job_id, target_tasks[index], new_fake_qobj())
|
||||
job.submit()
|
||||
|
||||
self.assertEqual(executor.submit.call_count, taskcount)
|
||||
for index in range(taskcount):
|
||||
_, callargs, _ = executor.submit.mock_calls[index]
|
||||
submitted_task = callargs[0]
|
||||
target_task = target_tasks[index]
|
||||
self.assertEqual(submitted_task, target_task)
|
||||
|
||||
def test_cancel(self):
|
||||
# Again, cancelling jobs is beyond our responsibility. In this test
|
||||
# we only check if we delegate on the proper method of the underlaying
|
||||
# future object.
|
||||
|
||||
job_id = str(uuid.uuid4())
|
||||
backend = FakeBackend()
|
||||
# pylint: disable=invalid-name,redefined-outer-name
|
||||
with mocked_executor() as (SimulatorsJob, executor):
|
||||
job = SimulatorsJob(backend, job_id, lambda: None, new_fake_qobj())
|
||||
job.submit()
|
||||
job.cancel()
|
||||
|
||||
self.assertCalledOnce(executor.submit)
|
||||
mocked_future = executor.submit.return_value
|
||||
self.assertCalledOnce(mocked_future.cancel)
|
||||
|
||||
def assertCalledOnce(self, mocked_callable):
|
||||
"""Assert a mocked callable has been called once."""
|
||||
call_count = mocked_callable.call_count
|
||||
self.assertEqual(
|
||||
call_count, 1,
|
||||
'Callable object has been called more than once ({})'.format(
|
||||
call_count))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def mocked_executor():
|
||||
"""Context that patches the derived executor classes to return the same
|
||||
executor object. Also patches the future object returned by executor's
|
||||
submit()."""
|
||||
|
||||
import importlib
|
||||
import concurrent.futures as futures
|
||||
import qiskit.providers.builtinsimulators.simulatorsjob as simulatorsjob
|
||||
|
||||
executor = unittest.mock.MagicMock(spec=futures.Executor)
|
||||
executor.submit.return_value = unittest.mock.MagicMock(spec=futures.Future)
|
||||
mock_options = {'return_value': executor, 'autospec': True}
|
||||
with patch.object(futures, 'ProcessPoolExecutor', **mock_options),\
|
||||
patch.object(futures, 'ThreadPoolExecutor', **mock_options):
|
||||
importlib.reload(simulatorsjob)
|
||||
yield simulatorsjob.SimulatorsJob, executor
|
||||
|
||||
|
||||
@contextmanager
|
||||
def mocked_simulator_binaries():
|
||||
"""Context to force binary-based simulators to think the simulators exist.
|
||||
"""
|
||||
with patch.object(path, 'exists', return_value=True, autospec=True),\
|
||||
patch.object(path, 'getsize', return_value=1000, autospec=True):
|
||||
yield
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
|
@ -0,0 +1,94 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=missing-docstring
|
||||
# pylint: disable=redefined-builtin
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
|
||||
import qiskit
|
||||
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
|
||||
from qiskit import compile
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class AerUnitarySimulatorPyTest(QiskitTestCase):
|
||||
"""Test Aer unitary simulator."""
|
||||
|
||||
def setUp(self):
|
||||
self.backend = qiskit.providers.aer.UnitarySimulator()
|
||||
|
||||
def test_aer_unitary_simulator_py(self):
|
||||
"""Test unitary simulator."""
|
||||
circuits = self._test_circuits()
|
||||
qobj = compile(circuits, backend=self.backend)
|
||||
job = self.backend.run(qobj)
|
||||
sim_unitaries = [job.result().get_unitary(circ) for circ in circuits]
|
||||
reference_unitaries = self._reference_unitaries()
|
||||
norms = [np.trace(np.dot(np.transpose(np.conj(target)), actual))
|
||||
for target, actual in zip(reference_unitaries, sim_unitaries)]
|
||||
for norm in norms:
|
||||
self.assertAlmostEqual(norm, 8)
|
||||
|
||||
def _test_circuits(self):
|
||||
"""Return test circuits for unitary simulator"""
|
||||
qr = QuantumRegister(3)
|
||||
cr = ClassicalRegister(3)
|
||||
qc1 = QuantumCircuit(qr, cr)
|
||||
qc2 = QuantumCircuit(qr, cr)
|
||||
qc3 = QuantumCircuit(qr, cr)
|
||||
qc4 = QuantumCircuit(qr, cr)
|
||||
qc5 = QuantumCircuit(qr, cr)
|
||||
# Test circuit 1: HxHxH
|
||||
qc1.h(qr)
|
||||
# Test circuit 2: IxCX
|
||||
qc2.cx(qr[0], qr[1])
|
||||
# Test circuit 3: CXxY
|
||||
qc3.y(qr[0])
|
||||
qc3.cx(qr[1], qr[2])
|
||||
# Test circuit 4: (CX.I).(IxCX).(IxIxX)
|
||||
qc4.h(qr[0])
|
||||
qc4.cx(qr[0], qr[1])
|
||||
qc4.cx(qr[1], qr[2])
|
||||
# Test circuit 5 (X.Z)x(Z.Y)x(Y.X)
|
||||
qc5.x(qr[0])
|
||||
qc5.y(qr[0])
|
||||
qc5.y(qr[1])
|
||||
qc5.z(qr[1])
|
||||
qc5.z(qr[2])
|
||||
qc5.x(qr[2])
|
||||
return [qc1, qc2, qc3, qc4, qc5]
|
||||
|
||||
def _reference_unitaries(self):
|
||||
"""Return reference unitaries for test circuits"""
|
||||
# Gate matrices
|
||||
gate_h = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
|
||||
gate_x = np.array([[0, 1], [1, 0]])
|
||||
gate_y = np.array([[0, -1j], [1j, 0]])
|
||||
gate_z = np.array([[1, 0], [0, -1]])
|
||||
gate_cx = np.array([[1, 0, 0, 0],
|
||||
[0, 0, 0, 1],
|
||||
[0., 0, 1, 0],
|
||||
[0, 1, 0, 0]])
|
||||
# Unitary matrices
|
||||
target_unitary1 = np.kron(np.kron(gate_h, gate_h), gate_h)
|
||||
target_unitary2 = np.kron(np.eye(2), gate_cx)
|
||||
target_unitary3 = np.kron(gate_cx, gate_y)
|
||||
target_unitary4 = np.dot(np.kron(gate_cx, np.eye(2)),
|
||||
np.dot(np.kron(np.eye(2), gate_cx),
|
||||
np.kron(np.eye(4), gate_h)))
|
||||
target_unitary5 = np.kron(np.kron(np.dot(gate_x, gate_z),
|
||||
np.dot(gate_z, gate_y)),
|
||||
np.dot(gate_y, gate_x))
|
||||
return [target_unitary1, target_unitary2, target_unitary3,
|
||||
target_unitary4, target_unitary5]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -1,168 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_conditionals",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 1,
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {
|
||||
"backend_name": "qasm_simulator"
|
||||
},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "single creg (c0=0)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0]
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0],
|
||||
"conditional": {"type": "equals", "mask": "0x1", "val": "0x0"}
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [1],
|
||||
"conditional": {"type": "equals", "mask": "0x1", "val": "0x1"}
|
||||
},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "single creg (c0=1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0]
|
||||
},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0],
|
||||
"conditional": {"type": "equals", "mask": "0x1", "val": "0x0"}
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [1],
|
||||
"conditional": {"type": "equals", "mask": "0x1", "val": "0x1"}
|
||||
},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "two creg (c1=0)",
|
||||
"clbit_labels": [["c0", 1], ["c1", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0]
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0],
|
||||
"conditional": {"type": "equals", "mask": "0x2", "val": "0x0"}
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [1],
|
||||
"conditional": {"type": "equals", "mask": "0x2", "val": "0x1"}
|
||||
},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "two creg (c1=1)",
|
||||
"clbit_labels": [["c0", 1], ["c1", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0]
|
||||
},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [1],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [1]
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [0],
|
||||
"conditional": {"type": "equals", "mask": "0x2", "val": "0x0"}
|
||||
},
|
||||
{
|
||||
"name": "U",
|
||||
"params": [3.14159265358979, 0.0, 3.14159265358979],
|
||||
"qubits": [1],
|
||||
"conditional": {"type": "equals", "mask": "0x2", "val": "0x1"}
|
||||
},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_measure_opt",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 2000,
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2,
|
||||
"seed": 1,
|
||||
"data" : ["density_matrix", "probabilities"]
|
||||
},
|
||||
"header": {
|
||||
"backend_name": "qasm_simulator"
|
||||
},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "x0 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "x", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "x1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "x", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "x0 x1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "x", "qubits": [0]},
|
||||
{"name": "x", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "y0 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "y", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "y1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "y", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "y0 y1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "y", "qubits": [0]},
|
||||
{"name": "y", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 h1 measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "bell measure (opt)",
|
||||
"memory_slots": 2,
|
||||
"creg_sizes": [["c", 2]],
|
||||
"clbit_labels": [["c", 0], ["c", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "cx", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [1], "clbits": [1]}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_measure_opt_flag",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 5,
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {"backend_name": "qasm_simulator"},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "measure (sampled)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "trivial (sampled)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "reset1 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "reset2 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]},
|
||||
{"name": "reset", "qubits": [0]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "reset3 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "gate1 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "gate2 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "gate3 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "u1", "qubits": [0], "params": [0.0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "gate4 (shots)",
|
||||
"clbit_labels": [["c", 2]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 2,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "measure", "memory": [0], "params": [], "qubits": [0], "clbits": [0]},
|
||||
{"name": "measure", "memory": [1], "params": [], "qubits": [0], "clbits": [1]},
|
||||
{"name": "u1", "qubits": [0], "params": [0.0]}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_reset",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 1,
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {"backend_name": "qasm_simulator"},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "reset",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "x reset",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "x", "qubits": [0]},
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "y reset",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "y", "qubits": [0]},
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h reset",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "reset", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_save_load",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 1,
|
||||
"n_qubits": 1,
|
||||
"memory_slots": 1,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {"backend_name": "qasm_simulator"},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "save_command",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "save", "params": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "save", "params": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [10]},
|
||||
{"name": "load", "params": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [1]},
|
||||
{"name": "load", "params": [1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [11]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,864 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_qasm_single_qubit_gates",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 1,
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {"backend_name": "qasm_simulator"},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "snapshot",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "id(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "U", "params": [0.0, 0.0, 0.0], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "id(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u3", "params": [0.0, 0.0, 0.0], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "id(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u1", "params": [0.0], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "id(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "id", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "x(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "U", "params": [3.14159265358979, 0.0, 3.14159265358979], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "x(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u3", "params": [3.14159265358979, 0.0, 3.14159265358979], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "x(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "x", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "y(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "U", "params": [3.14159265358979, 1.5707963267948966, 1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "y(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u3", "params": [3.14159265358979, 1.5707963267948966, 1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "y(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "y", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "U", "params": [1.5707963267948966, 0.0, 3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u3", "params": [1.5707963267948966, 0.0, 3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(u2)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "u2", "params": [0.0, 3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) z(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "U", "params": [0.0, 0.0, 3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) z(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u3", "params": [0.0, 0.0, 3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) z(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u1", "params": [3.141592653589793], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) z(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "z", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) s(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "U", "params": [0.0, 0.0, 1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) s(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u3", "params": [0.0, 0.0, 1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) s(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u1", "params": [1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) s(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "s", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) sdg(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "U", "params": [0.0, 0.0, -1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) sdg(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u3", "params": [0.0, 0.0, -1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) sdg(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u1", "params": [-1.5707963267948966], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) sdg(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "sdg", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) t(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "U", "params": [0.0, 0.0, 0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) t(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u3", "params": [0.0, 0.0, 0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) t(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u1", "params": [0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) t(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "t", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) tdg(U)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "U", "params": [0.0, 0.0, -0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) tdg(u3)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u3", "params": [0.0, 0.0, -0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) tdg(u1)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "u1", "params": [-0.7853981633974483], "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
"header": {
|
||||
"name": "h(direct) tdg(direct)",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 1
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "tdg", "qubits": [0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,498 +0,0 @@
|
|||
{
|
||||
"qobj_id": "test_two_qubit_gates",
|
||||
"type": "QASM",
|
||||
"schema_version": "1.0.0",
|
||||
"config": {
|
||||
"shots": 1,
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2,
|
||||
"seed": 1
|
||||
},
|
||||
"header": {"backend_name": "qasm_simulator"},
|
||||
"experiments": [
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 CX01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "CX", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 CX10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "CX", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 CX01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "CX", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 CX10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "CX", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 cx01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "cx", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 cx10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "cx", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 cx01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cx", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 cx10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cx", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 cz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "cz", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 cz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "cz", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 cz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cz", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 cz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cz", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 h1 cz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cz", "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 h1 cz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "cz", "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 rzz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 rzz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 rzz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h1 rzz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 h1 rzz01",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [0, 1]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"name": "h0 h1 rzz10",
|
||||
"clbit_labels": [["c0", 1]],
|
||||
"qubit_labels": [["q", 0], ["q", 1]]
|
||||
},
|
||||
"config": {
|
||||
"memory_slots": 1,
|
||||
"n_qubits": 2
|
||||
},
|
||||
"instructions": [
|
||||
{"name": "h", "qubits": [0]},
|
||||
{"name": "h", "qubits": [1]},
|
||||
{"name": "rzz", "params": [1.5707963267948966], "qubits": [1, 0]},
|
||||
{"name": "snapshot", "label": "", "type": "", "params": [0]},
|
||||
{
|
||||
"name": "measure",
|
||||
"memory": [0],
|
||||
"params": [],
|
||||
"qubits": [0],
|
||||
"clbits": [0]
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=unused-import
|
||||
|
||||
"""Tests for verifying the correctness of simulator extension instructions."""
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
import qiskit
|
||||
import qiskit.extensions.simulator
|
||||
from qiskit import BasicAer, LegacySimulators
|
||||
from qiskit.quantum_info import state_fidelity
|
||||
from qiskit.result.postprocess import format_statevector
|
||||
from qiskit import execute
|
||||
from ..common import QiskitTestCase, requires_cpp_simulator
|
||||
|
||||
|
||||
@requires_cpp_simulator
|
||||
class TestExtensionsSimulator(QiskitTestCase):
|
||||
"""Test instruction extensions for builtinsimulators simulators:
|
||||
save, load, noise, snapshot, wait
|
||||
"""
|
||||
_desired_fidelity = 0.99
|
||||
|
||||
def test_save_load(self):
|
||||
"""save |+>|0>, do some stuff, then load"""
|
||||
qr = qiskit.QuantumRegister(2)
|
||||
cr = qiskit.ClassicalRegister(2)
|
||||
circuit = qiskit.QuantumCircuit(qr, cr)
|
||||
circuit.h(qr[0])
|
||||
circuit.save(1)
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.cx(qr[1], qr[0])
|
||||
circuit.h(qr[1])
|
||||
circuit.load(1)
|
||||
|
||||
sim = LegacySimulators.get_backend('statevector_simulator')
|
||||
result = execute(circuit, sim).result()
|
||||
statevector = result.get_statevector()
|
||||
target = [0.70710678 + 0.j, 0.70710678 + 0.j, 0. + 0.j, 0. + 0.j]
|
||||
fidelity = state_fidelity(statevector, target)
|
||||
self.assertGreater(
|
||||
fidelity, self._desired_fidelity,
|
||||
"save-load statevector has low fidelity{0:.2g}.".format(fidelity))
|
||||
|
||||
def test_snapshot(self):
|
||||
"""snapshot a bell state in the middle of circuit"""
|
||||
qr = qiskit.QuantumRegister(2)
|
||||
cr = qiskit.ClassicalRegister(2)
|
||||
circuit = qiskit.QuantumCircuit(qr, cr)
|
||||
circuit.h(qr[0])
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.snapshot('3')
|
||||
circuit.cx(qr[0], qr[1])
|
||||
circuit.h(qr[1])
|
||||
|
||||
sim = LegacySimulators.get_backend('statevector_simulator')
|
||||
result = execute(circuit, sim).result()
|
||||
# TODO: rely on Result.get_statevector() postprocessing rather than manual
|
||||
snapshots = result.data(0)['snapshots']['statevector']['3']
|
||||
snapshot = format_statevector(snapshots[0])
|
||||
target = [0.70710678 + 0.j, 0. + 0.j, 0. + 0.j, 0.70710678 + 0.j]
|
||||
fidelity = state_fidelity(snapshot, target)
|
||||
self.assertGreater(
|
||||
fidelity, self._desired_fidelity,
|
||||
"snapshot has low fidelity{0:.2g}.".format(fidelity))
|
||||
|
||||
def test_noise(self):
|
||||
"""turn on a pauli x noise for qubits 0 and 2"""
|
||||
qr = qiskit.QuantumRegister(3)
|
||||
cr = qiskit.ClassicalRegister(3)
|
||||
circuit = qiskit.QuantumCircuit(qr, cr)
|
||||
circuit.iden(qr[0])
|
||||
circuit.noise(0)
|
||||
circuit.iden(qr[1])
|
||||
circuit.noise(1)
|
||||
circuit.iden(qr[2])
|
||||
circuit.measure(qr, cr)
|
||||
|
||||
config = {
|
||||
'noise_params': {
|
||||
'id': {'p_pauli': [1.0, 0.0, 0.0]}
|
||||
}
|
||||
}
|
||||
sim = LegacySimulators.get_backend('qasm_simulator')
|
||||
shots = 1000
|
||||
result = execute(circuit, sim, config=config, shots=shots).result()
|
||||
counts = result.get_counts()
|
||||
target = {'101': shots}
|
||||
self.assertEqual(counts, target)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
|
@ -1,457 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
# pylint: disable=missing-docstring,redefined-builtin
|
||||
|
||||
import json
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
from numpy.linalg import norm
|
||||
|
||||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
|
||||
from qiskit.providers.legacysimulators.qasm_simulator import (QasmSimulator,
|
||||
cx_error_matrix,
|
||||
x90_error_matrix)
|
||||
from qiskit.qobj import Qobj
|
||||
from qiskit.result.postprocess import format_statevector
|
||||
from qiskit.quantum_info import state_fidelity
|
||||
from qiskit import compile
|
||||
from ..common import QiskitTestCase, Path
|
||||
from ..common import requires_cpp_simulator
|
||||
|
||||
|
||||
class TestLegacyQasmSimulator(QiskitTestCase):
|
||||
"""
|
||||
Test legacy C++ QASM simulator.
|
||||
"""
|
||||
|
||||
@requires_cpp_simulator
|
||||
def setUp(self):
|
||||
self.backend = QasmSimulator()
|
||||
|
||||
qasm_file_name = 'example.qasm'
|
||||
qasm_file_path = self._get_resource_path(qasm_file_name, Path.QASMS)
|
||||
self.qc1 = QuantumCircuit.from_qasm_file(qasm_file_path)
|
||||
|
||||
qr = QuantumRegister(2, 'q')
|
||||
cr = ClassicalRegister(2, 'c')
|
||||
self.qc2 = QuantumCircuit(qr, cr)
|
||||
self.qc2.h(qr[0])
|
||||
self.qc2.measure(qr[0], cr[0])
|
||||
|
||||
self.qobj = compile([self.qc1, self.qc2], backend=self.backend,
|
||||
shots=2000, seed=1111)
|
||||
|
||||
def test_x90_coherent_error_matrix(self):
|
||||
x90 = np.array([[1, -1j], [-1j, 1]]) / np.sqrt(2)
|
||||
u_matrix = x90_error_matrix(0., 0.).dot(x90)
|
||||
target = x90
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10,
|
||||
msg="identity error matrix")
|
||||
u_matrix = x90_error_matrix(np.pi / 2., 0.).dot(x90)
|
||||
target = -1j * np.array([[0, 1], [1, 0]])
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10)
|
||||
u_matrix = x90_error_matrix(0., np.pi / 2.).dot(x90)
|
||||
target = np.array([[1., -1], [1, 1.]]) / np.sqrt(2.)
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10)
|
||||
u_matrix = x90_error_matrix(np.pi / 2, np.pi / 2.).dot(x90)
|
||||
target = np.array([[0., -1], [1, 0.]])
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10)
|
||||
u_matrix = x90_error_matrix(0.02, -0.03)
|
||||
self.assertAlmostEqual(norm(u_matrix.dot(u_matrix.conj().T) - np.eye(2)), 0.0,
|
||||
places=10, msg="Test error matrix is unitary")
|
||||
|
||||
def test_cx_coherent_error_matrix(self):
|
||||
cx_matrix = np.array([[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]])
|
||||
u_matrix = cx_error_matrix(0., 0.).dot(cx_matrix)
|
||||
target = cx_matrix
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10,
|
||||
msg="identity error matrix")
|
||||
u_matrix = cx_error_matrix(np.pi / 2., 0.).dot(cx_matrix)
|
||||
target = np.array([[1, 0, 1j, 0],
|
||||
[0, -1j, 0, 1],
|
||||
[1j, 0, 1, 0],
|
||||
[0, 1, 0, -1j]]) / np.sqrt(2)
|
||||
self.assertAlmostEqual(norm(u_matrix - target), 0.0, places=10)
|
||||
u_matrix = cx_error_matrix(0.03, -0.04)
|
||||
self.assertAlmostEqual(norm(u_matrix.dot(u_matrix.conj().T) - np.eye(4)), 0.0,
|
||||
places=10, msg="Test error matrix is unitary")
|
||||
|
||||
def test_run_qobj(self):
|
||||
result = self.backend.run(self.qobj).result()
|
||||
shots = self.qobj.config.shots
|
||||
threshold = 0.04 * shots
|
||||
counts = result.get_counts(self.qc1)
|
||||
target = {'100 100': shots / 8, '011 011': shots / 8,
|
||||
'101 101': shots / 8, '111 111': shots / 8,
|
||||
'000 000': shots / 8, '010 010': shots / 8,
|
||||
'110 110': shots / 8, '001 001': shots / 8}
|
||||
self.assertDictAlmostEqual(counts, target, threshold)
|
||||
|
||||
def test_qobj_measure_opt(self):
|
||||
filename = self._get_resource_path('qobj/cpp_measure_opt.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
shots = qobj.config.shots
|
||||
expected_data = {
|
||||
'measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'00': shots},
|
||||
'statevector': np.array([1, 0, 0, 0])},
|
||||
'x0 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'01': shots},
|
||||
'statevector': np.array([0, 1, 0, 0])},
|
||||
'x1 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'10': shots},
|
||||
'statevector': np.array([0, 0, 1, 0])},
|
||||
'x0 x1 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'11': shots},
|
||||
'statevector': np.array([0, 0, 0, 1])},
|
||||
'y0 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'01': shots},
|
||||
'statevector': np.array([0, 1j, 0, 0])},
|
||||
'y1 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'10': shots},
|
||||
'statevector': np.array([0, 0, 1j, 0])},
|
||||
'y0 y1 measure (opt)': {
|
||||
'deterministic': True,
|
||||
'counts': {'11': shots},
|
||||
'statevector': np.array([0, 0, 0, -1j])},
|
||||
'h0 measure (opt)': {
|
||||
'deterministic': False,
|
||||
'counts': {'00': shots / 2, '01': shots / 2},
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0, 0])},
|
||||
'h1 measure (opt)': {
|
||||
'deterministic': False,
|
||||
'counts': {'00': shots / 2, '10': shots / 2},
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1 / np.sqrt(2), 0])},
|
||||
'h0 h1 measure (opt)': {
|
||||
'deterministic': False,
|
||||
'counts': {'00': shots / 4, '01': shots / 4,
|
||||
'10': shots / 4, '11': shots / 4},
|
||||
'statevector': np.array([0.5, 0.5, 0.5, 0.5])},
|
||||
'bell measure (opt)': {
|
||||
'deterministic': False,
|
||||
'counts': {'00': shots / 2, '11': shots / 2},
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)])}
|
||||
}
|
||||
|
||||
for name in expected_data:
|
||||
# Check counts:
|
||||
counts = result.get_counts(name)
|
||||
expected_counts = expected_data[name]['counts']
|
||||
if expected_data[name].get('deterministic', False):
|
||||
self.assertEqual(counts, expected_counts,
|
||||
msg=name + ' counts')
|
||||
else:
|
||||
threshold = 0.04 * shots
|
||||
self.assertDictAlmostEqual(counts, expected_counts,
|
||||
threshold, msg=name + 'counts')
|
||||
# Check snapshot
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
self.assertEqual(len(snapshots['0']), 1,
|
||||
msg=name + ' snapshot length')
|
||||
state = format_statevector(snapshots['0'][0])
|
||||
expected_state = expected_data[name]['statevector']
|
||||
fidelity = np.abs(expected_state.dot(state.conj())) ** 2
|
||||
self.assertAlmostEqual(fidelity, 1.0, places=10,
|
||||
msg=name + ' snapshot fidelity')
|
||||
|
||||
def test_qobj_measure_opt_flag(self):
|
||||
filename = self._get_resource_path('qobj/cpp_measure_opt_flag.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
shots = qobj.config.shots
|
||||
sampled_measurements = {
|
||||
'measure (sampled)': True,
|
||||
'trivial (sampled)': True,
|
||||
'reset1 (shots)': False,
|
||||
'reset2 (shots)': False,
|
||||
'reset3 (shots)': False,
|
||||
'gate1 (shots)': False,
|
||||
'gate2 (shots)': False,
|
||||
'gate3 (shots)': False,
|
||||
'gate4 (shots)': False
|
||||
}
|
||||
|
||||
for name in sampled_measurements:
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
# Check snapshot keys
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
# Check number of snapshots
|
||||
# there should be 1 for measurement sampling optimization
|
||||
# and there should be >1 for each shot being simulated.
|
||||
num_snapshots = len(snapshots['0'])
|
||||
if sampled_measurements[name] is True:
|
||||
self.assertEqual(num_snapshots, 1,
|
||||
msg=name + ' snapshot length')
|
||||
else:
|
||||
self.assertEqual(num_snapshots, shots,
|
||||
msg=name + ' snapshot length')
|
||||
|
||||
def test_qobj_reset(self):
|
||||
filename = self._get_resource_path('qobj/cpp_reset.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
expected_data = {
|
||||
'reset': {'statevector': np.array([1, 0])},
|
||||
'x reset': {'statevector': np.array([1, 0])},
|
||||
'y reset': {'statevector': np.array([1, 0])},
|
||||
'h reset': {'statevector': np.array([1, 0])}
|
||||
}
|
||||
for name in expected_data:
|
||||
# Check snapshot is |0> state
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
self.assertEqual(len(snapshots['0']), 1,
|
||||
msg=name + ' snapshot length')
|
||||
state = format_statevector(snapshots['0'][0])
|
||||
expected_state = expected_data[name]['statevector']
|
||||
fidelity = np.abs(expected_state.dot(state.conj())) ** 2
|
||||
self.assertAlmostEqual(fidelity, 1.0, places=10,
|
||||
msg=name + ' snapshot fidelity')
|
||||
|
||||
def test_qobj_save_load(self):
|
||||
filename = self._get_resource_path('qobj/cpp_save_load.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
|
||||
snapshots = result.data('save_command')['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0', '1', '10', '11'},
|
||||
msg='snapshot keys')
|
||||
state0 = format_statevector(snapshots['0'][0])
|
||||
state10 = format_statevector(snapshots['10'][0])
|
||||
state1 = format_statevector(snapshots['1'][0])
|
||||
state11 = format_statevector(snapshots['11'][0])
|
||||
|
||||
expected_state0 = np.array([1, 0])
|
||||
expected_state10 = np.array([1 / np.sqrt(2), 1 / np.sqrt(2)])
|
||||
|
||||
fidelity0 = np.abs(expected_state0.dot(state0.conj())) ** 2
|
||||
fidelity1 = np.abs(expected_state0.dot(state1.conj())) ** 2
|
||||
fidelity10 = np.abs(expected_state10.dot(state10.conj())) ** 2
|
||||
fidelity11 = np.abs(expected_state10.dot(state11.conj())) ** 2
|
||||
self.assertAlmostEqual(fidelity0, 1.0, places=10, msg='snapshot 0')
|
||||
self.assertAlmostEqual(fidelity10, 1.0, places=10, msg='snapshot 0')
|
||||
self.assertAlmostEqual(fidelity1, 1.0, places=10, msg='snapshot 0')
|
||||
self.assertAlmostEqual(fidelity11, 1.0, places=10, msg='snapshot 0')
|
||||
|
||||
def test_qobj_single_qubit_gates(self):
|
||||
filename = self._get_resource_path('qobj/cpp_single_qubit_gates.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
expected_data = {
|
||||
'snapshot': {
|
||||
'statevector': np.array([1, 0])},
|
||||
'id(U)': {
|
||||
'statevector': np.array([1, 0])},
|
||||
'id(u3)': {
|
||||
'statevector': np.array([1, 0])},
|
||||
'id(u1)': {
|
||||
'statevector': np.array([1, 0])},
|
||||
'id(direct)': {
|
||||
'statevector': np.array([1, 0])},
|
||||
'x(U)': {
|
||||
'statevector': np.array([0, 1])},
|
||||
'x(u3)': {
|
||||
'statevector': np.array([0, 1])},
|
||||
'x(direct)': {
|
||||
'statevector': np.array([0, 1])},
|
||||
'y(U)': {
|
||||
'statevector': np.array([0, 1j])},
|
||||
'y(u3)': {
|
||||
'statevector': np.array([0, 1j])},
|
||||
'y(direct)': {
|
||||
'statevector': np.array([0, 1j])},
|
||||
'h(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2)])},
|
||||
'h(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2)])},
|
||||
'h(u2)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2)])},
|
||||
'h(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2)])},
|
||||
'h(direct) z(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1 / np.sqrt(2)])},
|
||||
'h(direct) z(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1 / np.sqrt(2)])},
|
||||
'h(direct) z(u1)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1 / np.sqrt(2)])},
|
||||
'h(direct) z(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1 / np.sqrt(2)])},
|
||||
'h(direct) s(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])},
|
||||
'h(direct) s(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])},
|
||||
'h(direct) s(u1)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])},
|
||||
'h(direct) s(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])},
|
||||
'h(direct) sdg(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1j / np.sqrt(2)])},
|
||||
'h(direct) sdg(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1j / np.sqrt(2)])},
|
||||
'h(direct) sdg(u1)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1j / np.sqrt(2)])},
|
||||
'h(direct) sdg(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), -1j / np.sqrt(2)])},
|
||||
'h(direct) t(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 + 0.5j])},
|
||||
'h(direct) t(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 + 0.5j])},
|
||||
'h(direct) t(u1)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 + 0.5j])},
|
||||
'h(direct) t(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 + 0.5j])},
|
||||
'h(direct) tdg(U)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 - 0.5j])},
|
||||
'h(direct) tdg(u3)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 - 0.5j])},
|
||||
'h(direct) tdg(u1)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 - 0.5j])},
|
||||
'h(direct) tdg(direct)': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0.5 - 0.5j])}
|
||||
}
|
||||
|
||||
for name in expected_data:
|
||||
# Check snapshot
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
self.assertEqual(len(snapshots['0']), 1,
|
||||
msg=name + ' snapshot length')
|
||||
state = format_statevector(snapshots['0'][0])
|
||||
expected_state = expected_data[name]['statevector']
|
||||
inner_product = expected_state.dot(state.conj())
|
||||
self.assertAlmostEqual(inner_product, 1.0, places=10,
|
||||
msg=name + ' snapshot fidelity')
|
||||
|
||||
def test_qobj_two_qubit_gates(self):
|
||||
filename = self._get_resource_path('qobj/cpp_two_qubit_gates.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
expected_data = {
|
||||
'h0 CX01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)])},
|
||||
'h0 CX10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0, 0])},
|
||||
'h1 CX01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1 / np.sqrt(2), 0])},
|
||||
'h1 CX10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)])},
|
||||
'h0 cx01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)])},
|
||||
'h0 cx10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0, 0])},
|
||||
'h1 cx01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1 / np.sqrt(2), 0])},
|
||||
'h1 cx10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)])},
|
||||
'h0 cz01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0, 0])},
|
||||
'h0 cz10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1 / np.sqrt(2), 0, 0])},
|
||||
'h1 cz01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1 / np.sqrt(2), 0])},
|
||||
'h1 cz10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1 / np.sqrt(2), 0])},
|
||||
'h0 h1 cz01': {'statevector': np.array([0.5, 0.5, 0.5, -0.5])},
|
||||
'h0 h1 cz10': {'statevector': np.array([0.5, 0.5, 0.5, -0.5])},
|
||||
'h0 rzz01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2), 0, 0])},
|
||||
'h0 rzz10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 1j / np.sqrt(2), 0, 0])},
|
||||
'h1 rzz01': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1j / np.sqrt(2), 0])},
|
||||
'h1 rzz10': {
|
||||
'statevector': np.array([1 / np.sqrt(2), 0, 1j / np.sqrt(2), 0])},
|
||||
'h0 h1 rzz01': {'statevector': np.array([0.5, 0.5j, 0.5j, 0.5])},
|
||||
'h0 h1 rzz10': {'statevector': np.array([0.5, 0.5j, 0.5j, 0.5])}
|
||||
}
|
||||
|
||||
for name in expected_data:
|
||||
# Check snapshot
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
self.assertEqual(len(snapshots['0']), 1,
|
||||
msg=name + ' snapshot length')
|
||||
state = format_statevector(snapshots['0'][0])
|
||||
expected_state = expected_data[name]['statevector']
|
||||
fidelity = state_fidelity(expected_state, state)
|
||||
self.assertAlmostEqual(fidelity, 1.0, places=10,
|
||||
msg=name + ' snapshot fidelity')
|
||||
|
||||
def test_conditionals(self):
|
||||
filename = self._get_resource_path('qobj/cpp_conditionals.json')
|
||||
with open(filename, 'r') as file:
|
||||
qobj = Qobj.from_dict(json.load(file))
|
||||
result = self.backend.run(qobj).result()
|
||||
expected_data = {
|
||||
'single creg (c0=0)': {
|
||||
'statevector': np.array([1, 0, 0, 0])},
|
||||
'single creg (c0=1)': {
|
||||
'statevector': np.array([0, 0, 0, 1])},
|
||||
'two creg (c1=0)': {
|
||||
'statevector': np.array([1, 0, 0, 0])},
|
||||
'two creg (c1=1)': {
|
||||
'statevector': np.array([0, 0, 0, 1])}
|
||||
}
|
||||
|
||||
for name in expected_data:
|
||||
# Check snapshot
|
||||
snapshots = result.data(name)['snapshots']['statevector']
|
||||
self.assertEqual(set(snapshots), {'0'},
|
||||
msg=name + ' snapshot keys')
|
||||
self.assertEqual(len(snapshots['0']), 1,
|
||||
msg=name + ' snapshot length')
|
||||
state = format_statevector(snapshots['0'][0])
|
||||
expected_state = expected_data[name]['statevector']
|
||||
fidelity = np.abs(expected_state.dot(state.conj())) ** 2
|
||||
self.assertAlmostEqual(fidelity, 1.0, places=10,
|
||||
msg=name + ' snapshot fidelity')
|
||||
|
||||
def test_memory(self):
|
||||
qr = QuantumRegister(4, 'qr')
|
||||
cr0 = ClassicalRegister(2, 'cr0')
|
||||
cr1 = ClassicalRegister(2, 'cr1')
|
||||
circ = QuantumCircuit(qr, cr0, cr1)
|
||||
circ.h(qr[0])
|
||||
circ.cx(qr[0], qr[1])
|
||||
circ.x(qr[3])
|
||||
circ.measure(qr[0], cr0[0])
|
||||
circ.measure(qr[1], cr0[1])
|
||||
circ.measure(qr[2], cr1[0])
|
||||
circ.measure(qr[3], cr1[1])
|
||||
|
||||
shots = 50
|
||||
qobj = compile(circ, backend=self.backend, shots=shots, memory=True)
|
||||
result = self.backend.run(qobj).result()
|
||||
memory = result.get_memory()
|
||||
self.assertEqual(len(memory), shots)
|
||||
for mem in memory:
|
||||
self.assertIn(mem, ['10 00', '10 11'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
|
@ -1,57 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018, IBM.
|
||||
#
|
||||
# This source code is licensed under the Apache License, Version 2.0 found in
|
||||
# the LICENSE.txt file in the root directory of this source tree.
|
||||
|
||||
|
||||
"""Tests for all builtinsimulators simulators."""
|
||||
|
||||
from qiskit import BasicAer, LegacySimulators
|
||||
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
|
||||
from qiskit import compile # pylint: disable=redefined-builtin
|
||||
from qiskit.qobj import QobjHeader
|
||||
|
||||
from ..common import QiskitTestCase
|
||||
|
||||
|
||||
class TestTerraSimulators(QiskitTestCase):
|
||||
"""Tests for all the Terra simulators."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
qr = QuantumRegister(1)
|
||||
cr = ClassicalRegister(1)
|
||||
self.qc1 = QuantumCircuit(qr, cr, name='circuit0')
|
||||
self.qc1.h(qr[0])
|
||||
|
||||
def test_qobj_headers_in_result(self):
|
||||
"""Test that the qobj headers are passed onto the results."""
|
||||
custom_qobj_header = {'x': 1, 'y': [1, 2, 3], 'z': {'a': 4}}
|
||||
|
||||
for provider in (BasicAer, LegacySimulators):
|
||||
for backend in provider.backends():
|
||||
with self.subTest(provider=provider, backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
# Update the Qobj header.
|
||||
qobj.header = QobjHeader.from_dict(custom_qobj_header)
|
||||
# Update the Qobj.experiment header.
|
||||
qobj.experiments[0].header.some_field = 'extra info'
|
||||
|
||||
result = backend.run(qobj).result()
|
||||
self.assertEqual(result.header.to_dict(), custom_qobj_header)
|
||||
self.assertEqual(result.results[0].header.some_field,
|
||||
'extra info')
|
||||
|
||||
def test_job_qobj(self):
|
||||
"""Test job.qobj()."""
|
||||
for provider in (BasicAer, LegacySimulators):
|
||||
for backend in provider.backends():
|
||||
with self.subTest(provider=provider, backend=backend):
|
||||
qobj = compile(self.qc1, backend)
|
||||
|
||||
job = backend.run(qobj)
|
||||
self.assertEqual(job.qobj(), qobj)
|
|
@ -9,12 +9,10 @@
|
|||
"""Test backend name resolution for functionality, via groups, deprecations and
|
||||
aliases."""
|
||||
|
||||
from qiskit import IBMQ, BasicAer, LegacySimulators
|
||||
from qiskit.providers.legacysimulators import QasmSimulator
|
||||
from qiskit import IBMQ, BasicAer
|
||||
from qiskit.providers.exceptions import QiskitBackendNotFoundError
|
||||
from .common import (QiskitTestCase,
|
||||
is_cpp_simulator_available,
|
||||
requires_cpp_simulator,
|
||||
requires_qe_access)
|
||||
|
||||
|
||||
|
@ -26,23 +24,22 @@ class TestBackendNameResolution(QiskitTestCase):
|
|||
def test_deprecated(self):
|
||||
"""Test that deprecated names map the same backends as the new names.
|
||||
"""
|
||||
for provider in (BasicAer, LegacySimulators):
|
||||
deprecated_names = provider._deprecated_backend_names()
|
||||
deprecated_names = BasicAer._deprecated_backend_names()
|
||||
|
||||
for oldname, newname in deprecated_names.items():
|
||||
if newname in ('qasm_simulator',
|
||||
'statevector_simulator') and not is_cpp_simulator_available():
|
||||
continue
|
||||
for oldname, newname in deprecated_names.items():
|
||||
if newname in ('qasm_simulator',
|
||||
'statevector_simulator') and not is_cpp_simulator_available():
|
||||
continue
|
||||
|
||||
with self.subTest(provider=provider, oldname=oldname, newname=newname):
|
||||
try:
|
||||
resolved_newname = _get_first_available_backend(provider, newname)
|
||||
real_backend = provider.get_backend(resolved_newname)
|
||||
except QiskitBackendNotFoundError:
|
||||
# The real name of the backend might not exist
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(provider.backends(oldname)[0], real_backend)
|
||||
with self.subTest(oldname=oldname, newname=newname):
|
||||
try:
|
||||
resolved_newname = _get_first_available_backend(BasicAer, newname)
|
||||
real_backend = BasicAer.get_backend(resolved_newname)
|
||||
except QiskitBackendNotFoundError:
|
||||
# The real name of the backend might not exist
|
||||
pass
|
||||
else:
|
||||
self.assertEqual(BasicAer.backends(oldname)[0], real_backend)
|
||||
|
||||
@requires_qe_access
|
||||
def test_aliases(self, qe_token, qe_url):
|
||||
|
@ -72,29 +69,6 @@ class TestBackendNameResolution(QiskitTestCase):
|
|||
"""Test backends() return an empty list if name is unknown."""
|
||||
self.assertEqual(BasicAer.backends("bad_name"), [])
|
||||
|
||||
def test_deprecated_cpp_simulator_return_no_backend(self):
|
||||
"""Test backends("local_qasm_simulator_cpp") does not return C++
|
||||
simulator if it is not installed"""
|
||||
name = "local_qasm_simulator_cpp"
|
||||
backends = LegacySimulators.backends(name)
|
||||
if is_cpp_simulator_available():
|
||||
self.assertEqual(len(backends), 1)
|
||||
self.assertIsInstance(backends[0] if backends else None, QasmSimulator)
|
||||
else:
|
||||
self.assertEqual(len(backends), 0)
|
||||
|
||||
|
||||
class TestSimulatorBackendNames(QiskitTestCase):
|
||||
"""
|
||||
Test deprecated names from providers.
|
||||
"""
|
||||
@requires_cpp_simulator
|
||||
def test_legacy_deprecated(self):
|
||||
"""test deprecated legacy simulators backends are resolved correctly"""
|
||||
old_name = 'local_qiskit_simulator'
|
||||
new_backend = LegacySimulators.get_backend(old_name)
|
||||
self.assertIsInstance(new_backend, QasmSimulator)
|
||||
|
||||
|
||||
def _get_first_available_backend(provider, backend_names):
|
||||
"""Gets the first available backend."""
|
||||
|
|
|
@ -14,8 +14,8 @@ import unittest
|
|||
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
|
||||
from qiskit import QiskitError
|
||||
# pylint: disable=redefined-builtin
|
||||
from qiskit import compile, LegacySimulators, BasicAer
|
||||
from .common import QiskitTestCase, requires_cpp_simulator
|
||||
from qiskit import compile, BasicAer
|
||||
from .common import QiskitTestCase
|
||||
|
||||
|
||||
class TestQobjIdentifiers(QiskitTestCase):
|
||||
|
@ -41,20 +41,8 @@ class TestQobjIdentifiers(QiskitTestCase):
|
|||
self.assertIn(self.cr_name, map(lambda x: x[0], exp.header.clbit_labels))
|
||||
self.assertIn(self.cr_name, c_qasm)
|
||||
|
||||
@requires_cpp_simulator
|
||||
def test_builtin_clifford_simulator(self):
|
||||
backend = LegacySimulators.get_backend('clifford_simulator')
|
||||
qobj = compile(self.circuits, backend=backend)
|
||||
exp = qobj.experiments[0]
|
||||
c_qasm = exp.header.compiled_circuit_qasm
|
||||
self.assertIn(self.qr_name, map(lambda x: x[0], exp.header.qubit_labels))
|
||||
self.assertIn(self.qr_name, c_qasm)
|
||||
self.assertIn(self.cr_name, map(lambda x: x[0], exp.header.clbit_labels))
|
||||
self.assertIn(self.cr_name, c_qasm)
|
||||
|
||||
@requires_cpp_simulator
|
||||
def test_builtin_qasm_simulator(self):
|
||||
backend = LegacySimulators.get_backend('qasm_simulator')
|
||||
backend = BasicAer.get_backend('qasm_simulator')
|
||||
qobj = compile(self.circuits, backend=backend)
|
||||
exp = qobj.experiments[0]
|
||||
c_qasm = exp.header.compiled_circuit_qasm
|
||||
|
|
|
@ -15,8 +15,7 @@ import unittest
|
|||
import nbformat
|
||||
from nbconvert.preprocessors import ExecutePreprocessor
|
||||
from qiskit.tools.visualization._matplotlib import HAS_MATPLOTLIB
|
||||
from ...common import (Path, QiskitTestCase, requires_qe_access,
|
||||
requires_cpp_simulator, slow_test)
|
||||
from ...common import (Path, QiskitTestCase, requires_qe_access, slow_test)
|
||||
|
||||
|
||||
# Timeout (in seconds) for a single notebook.
|
||||
|
@ -54,7 +53,6 @@ class TestJupyter(QiskitTestCase):
|
|||
execute_preprocessor.preprocess(
|
||||
notebook, {'metadata': {'path': self.execution_path}})
|
||||
|
||||
@requires_cpp_simulator
|
||||
def test_jupyter_jobs_pbars(self):
|
||||
"""Test Jupyter progress bars and job status functionality"""
|
||||
self._execute_notebook(self._get_resource_path(
|
||||
|
|
|
@ -478,7 +478,7 @@ class TestCompiler(QiskitTestCase):
|
|||
|
||||
Uses the mapper. Pass if results are correct.
|
||||
"""
|
||||
backend = qiskit.LegacySimulators.get_backend('qasm_simulator')
|
||||
backend = qiskit.Aer.get_backend('qasm_simulator')
|
||||
coupling_map = [[0, 1], [0, 8], [1, 2], [1, 9], [2, 3], [2, 10],
|
||||
[3, 4], [3, 11], [4, 5], [4, 12], [5, 6], [5, 13],
|
||||
[6, 7], [6, 14], [7, 15], [8, 9], [9, 10], [10, 11],
|
||||
|
|
Loading…
Reference in New Issue