Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lurking qiskit.tools usage #11625

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiskit/passmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
A single flow controller always takes a single IR object, and returns a single
IR object. Parallelism for multiple input objects is supported by the
:class:`BasePassManager` by broadcasting the flow controller via
the :func:`qiskit.tools.parallel_map` function.
the :func:`.parallel_map` function.


Examples
Expand Down
2 changes: 1 addition & 1 deletion qiskit/utils/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def parallel_map( # pylint: disable=dangerous-default-value
.. code-block:: python

import time
from qiskit.tools.parallel import parallel_map
from qiskit.utils import parallel_map
def func(_):
time.sleep(0.1)
return 0
Expand Down
4 changes: 0 additions & 4 deletions qiskit/visualization/gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,13 +1141,9 @@ def plot_circuit_layout(circuit, backend, view="virtual", qubit_coordinates=None
.. plot::
:include-source:

import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeVigoV2
from qiskit.visualization import plot_circuit_layout
from qiskit.tools.monitor import job_monitor
from qiskit.providers.fake_provider import FakeVigoV2
import matplotlib.pyplot as plt

ghz = QuantumCircuit(3, 3)
ghz.h(0)
Expand Down
7 changes: 1 addition & 6 deletions test/benchmarks/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
import itertools
import math

from qiskit import QuantumRegister, QuantumCircuit
from qiskit import QuantumRegister, QuantumCircuit, transpile
from qiskit.converters import circuit_to_dag
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.passes import SabreSwap

try:
from qiskit.compiler import transpile
except ImportError:
from qiskit.transpiler import transpile


def build_model_circuit(qreg, circuit=None):
"""Create quantum fourier transform circuit on quantum register qreg."""
Expand Down
30 changes: 5 additions & 25 deletions test/benchmarks/random_circuit_hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,9 @@

import copy

from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, transpile
from qiskit.quantum_info.random import random_unitary
from qiskit.quantum_info.synthesis import OneQubitEulerDecomposer
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister

try:
from qiskit.compiler import transpile

TRANSPILER_SEED_KEYWORD = "seed_transpiler"
except ImportError:
from qiskit.transpiler import transpile

TRANSPILER_SEED_KEYWORD = "seed_mapper"
try:
from qiskit.quantum_info.random import random_unitary

HAS_RANDOM_UNITARY = True
except ImportError:
from qiskit.tools.qi.qi import random_unitary_matrix

HAS_RANDOM_UNITARY = False


# Make a random circuit on a ring
Expand All @@ -55,11 +39,7 @@ def make_circuit_ring(nq, depth, seed):
k = i * 2 + offset + j % 2 # j%2 makes alternating rounds overlap
qc.cx(q[k % nq], q[(k + 1) % nq])
for i in range(nq): # round of single-qubit unitaries
if HAS_RANDOM_UNITARY:
u = random_unitary(2, seed).data
else:
u = random_unitary_matrix(2) # pylint: disable=used-before-assignment # noqa

u = random_unitary(2, seed).data
angles = decomposer.angles(u)
qc.u3(angles[0], angles[1], angles[2], q[i])

Expand Down Expand Up @@ -106,7 +86,7 @@ def time_ibmq_backend_transpile(self, _):
self.circuit,
basis_gates=["u1", "u2", "u3", "cx", "id"],
coupling_map=coupling_map,
**{TRANSPILER_SEED_KEYWORD: self.seed},
seed_transpiler=self.seed,
)

def track_depth_ibmq_backend_transpile(self, _):
Expand Down Expand Up @@ -135,5 +115,5 @@ def track_depth_ibmq_backend_transpile(self, _):
self.circuit,
basis_gates=["u1", "u2", "u3", "cx", "id"],
coupling_map=coupling_map,
**{TRANSPILER_SEED_KEYWORD: self.seed},
seed_transpiler=self.seed,
).depth()
14 changes: 3 additions & 11 deletions test/benchmarks/randomized_benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
import os
import numpy as np
from qiskit_experiments.library import StandardRB

try:
from qiskit.compiler import transpile

TRANSPILER_SEED_KEYWORD = "seed_transpiler"
except ImportError:
from qiskit.transpiler import transpile

TRANSPILER_SEED_KEYWORD = "seed_mapper"
from qiskit import transpile


def build_rb_circuit(qubits, length_vector, num_samples=1, seed=None):
Expand Down Expand Up @@ -102,7 +94,7 @@ def time_ibmq_backend_transpile(self, __):
basis_gates=["u1", "u2", "u3", "cx", "id"],
coupling_map=coupling_map,
optimization_level=0,
**{TRANSPILER_SEED_KEYWORD: self.seed},
seed_transpiler=self.seed,
)

def time_ibmq_backend_transpile_single_thread(self, __):
Expand Down Expand Up @@ -135,5 +127,5 @@ def time_ibmq_backend_transpile_single_thread(self, __):
basis_gates=["u1", "u2", "u3", "cx", "id"],
coupling_map=coupling_map,
optimization_level=0,
**{TRANSPILER_SEED_KEYWORD: self.seed},
seed_transpiler=self.seed,
)