Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellyGarion committed Dec 10, 2024
1 parent 389ad33 commit 85cdf63
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 34 deletions.
6 changes: 3 additions & 3 deletions test/benchmarks/circuit_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from qiskit.quantum_info import random_clifford
from qiskit import QuantumRegister, QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.circuit.library import EfficientSU2, QuantumVolume
from qiskit.circuit.library import efficient_su2, quantum_volume
from .utils import dtc_unitary, multi_control_circuit

SEED = 12345
Expand Down Expand Up @@ -112,7 +112,7 @@ def time_QV100_build(self, circuit_size, num_qubits):
"""Measures an SDKs ability to build a 100Q
QV circit from scratch.
"""
return QuantumVolume(circuit_size, num_qubits, seed=SEED)
return quantum_volume(circuit_size, num_qubits, seed=SEED)

def time_DTC100_set_build(self, circuit_size, num_qubits):
"""Measures an SDKs ability to build a set
Expand Down Expand Up @@ -154,7 +154,7 @@ def time_param_circSU2_100_build(self, num_qubits):
over 100Q utilizing 4 repetitions. This will yield a
circuit with 1000 parameters
"""
out = EfficientSU2(num_qubits, reps=4, entanglement="circular", flatten=True)
out = efficient_su2(num_qubits, reps=4, entanglement="circular")
out._build()
return out

Expand Down
4 changes: 2 additions & 2 deletions test/benchmarks/utility_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os

from qiskit import QuantumCircuit
from qiskit.circuit.library import EfficientSU2
from qiskit.circuit.library import efficient_su2
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler import CouplingMap
Expand Down Expand Up @@ -48,7 +48,7 @@ def setup(self, basis_gate):
self.qaoa_qasm = os.path.join(qasm_dir, "qaoa_barabasi_albert_N100_3reps.qasm")
self.qaoa_qc = QuantumCircuit.from_qasm_file(self.qaoa_qasm)
self.qv_qc = build_qv_model_circuit(50, 50, SEED)
self.circSU2 = EfficientSU2(100, reps=3, entanglement="circular")
self.circSU2 = efficient_su2(100, reps=3, entanglement="circular")
self.bv_100 = bv_all_ones(100)
self.bv_like_100 = trivial_bvlike_circuit(100)

Expand Down
8 changes: 4 additions & 4 deletions test/python/quantum_info/operators/symplectic/test_pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
CYGate,
CZGate,
ECRGate,
EfficientSU2,
efficient_su2,
HGate,
IGate,
SdgGate,
Expand Down Expand Up @@ -515,7 +515,7 @@ def test_circuit_with_bit(self):

def test_apply_layout_with_transpile(self):
"""Test the apply_layout method with a transpiler layout."""
psi = EfficientSU2(4, reps=4, entanglement="circular")
psi = efficient_su2(4, reps=4, entanglement="circular")
op = Pauli("IZZZ")
backend = GenericBackendV2(num_qubits=7)
transpiled_psi = transpile(psi, backend, optimization_level=3, seed_transpiler=12345)
Expand All @@ -530,7 +530,7 @@ def test_apply_layout_with_transpile(self):

def test_apply_layout_consistency(self):
"""Test that the Pauli apply_layout() is consistent with the SparsePauliOp apply_layout()."""
psi = EfficientSU2(4, reps=4, entanglement="circular")
psi = efficient_su2(4, reps=4, entanglement="circular")
op = Pauli("IZZZ")
sparse_op = SparsePauliOp(op)
backend = GenericBackendV2(num_qubits=7)
Expand All @@ -541,7 +541,7 @@ def test_apply_layout_consistency(self):

def test_permute_pauli_estimator_example(self):
"""Test using the apply_layout method with an estimator workflow."""
psi = EfficientSU2(4, reps=4, entanglement="circular")
psi = efficient_su2(4, reps=4, entanglement="circular")
op = Pauli("XXXI")
backend = GenericBackendV2(num_qubits=7, seed=0)
backend.set_options(seed_simulator=123)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from qiskit import QiskitError
from qiskit.circuit import Parameter, ParameterExpression, ParameterVector
from qiskit.circuit.library import EfficientSU2
from qiskit.circuit.library import efficient_su2
from qiskit.circuit.parametertable import ParameterView
from qiskit.compiler.transpiler import transpile
from qiskit.primitives import BackendEstimator
Expand Down Expand Up @@ -1148,7 +1148,7 @@ def test_paulis_setter_absorbs_phase_2(self):

def test_apply_layout_with_transpile(self):
"""Test the apply_layout method with a transpiler layout."""
psi = EfficientSU2(4, reps=4, entanglement="circular")
psi = efficient_su2(4, reps=4, entanglement="circular")
op = SparsePauliOp.from_list([("IIII", 1), ("IZZZ", 2), ("XXXI", 3)])
backend = GenericBackendV2(num_qubits=7)
transpiled_psi = transpile(psi, backend, optimization_level=3, seed_transpiler=12345)
Expand All @@ -1163,7 +1163,7 @@ def test_apply_layout_with_transpile(self):

def test_permute_sparse_pauli_op_estimator_example(self):
"""Test using the apply_layout method with an estimator workflow."""
psi = EfficientSU2(4, reps=4, entanglement="circular")
psi = efficient_su2(4, reps=4, entanglement="circular")
op = SparsePauliOp.from_list([("IIII", 1), ("IZZZ", 2), ("XXXI", 3)])
backend = GenericBackendV2(num_qubits=7, seed=0)
backend.set_options(seed_simulator=123)
Expand Down
13 changes: 7 additions & 6 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@

from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit.circuit import Qubit, Gate, ControlFlowOp, ForLoopOp
from qiskit.circuit.library import quantum_volume
from qiskit.compiler import transpile
from qiskit.transpiler import CouplingMap, Layout, PassManager, TranspilerError, Target
from qiskit.circuit.library import U2Gate, U3Gate, QuantumVolume, CXGate, CZGate, XGate
from qiskit.circuit.library import U2Gate, U3Gate, quantum_volume, CXGate, CZGate, XGate
from qiskit.transpiler.passes import (
ALAPScheduleAnalysis,
PadDynamicalDecoupling,
RemoveResetInZeroState,
)
from qiskit.providers.fake_provider import Fake5QV1, Fake20QV1, GenericBackendV2
from qiskit.converters import circuit_to_dag
from qiskit.circuit.library import GraphState
from qiskit.circuit.library import GraphStateGate
from qiskit.quantum_info import random_unitary
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.transpiler.preset_passmanagers import level0, level1, level2, level3
Expand Down Expand Up @@ -269,7 +268,7 @@ def test_unroll_only_if_not_gates_in_basis(self):
basis_gates=["id", "u1", "u2", "u3", "cx"],
seed=42,
)
qv_circuit = QuantumVolume(3)
qv_circuit = quantum_volume(3)
gates_in_basis_true_count = 0
consolidate_blocks_count = 0

Expand Down Expand Up @@ -1046,9 +1045,11 @@ def test_all_levels_use_trivial_if_perfect(self, level):
rows = [x[0] for x in backend.coupling_map]
cols = [x[1] for x in backend.coupling_map]

adjacency_matrix = np.zeros((20, 20))
num_qubits = 20
adjacency_matrix = np.zeros((num_qubits, num_qubits))
qc = QuantumCircuit(num_qubits)
adjacency_matrix[rows, cols] = 1
qc = GraphState(adjacency_matrix)
qc.append(GraphStateGate(adjacency_matrix), range(num_qubits))
qc.measure_all()
expected = {
0: Qubit(QuantumRegister(20, "q"), 0),
Expand Down
6 changes: 3 additions & 3 deletions test/python/transpiler/test_sabre_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from qiskit import QuantumRegister, QuantumCircuit
from qiskit.circuit.classical import expr, types
from qiskit.circuit.library import EfficientSU2, QuantumVolume
from qiskit.circuit.library import efficient_su2, quantum_volume
from qiskit.transpiler import CouplingMap, AnalysisPass, PassManager
from qiskit.transpiler.passes import SabreLayout, DenseLayout, StochasticSwap, Unroll3qOrMore
from qiskit.transpiler.exceptions import TranspilerError
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_release_valve_routes_multiple(self):
Regression test of #13081.
"""
qv = QuantumVolume(500, seed=42)
qv = quantum_volume(500, seed=42)
qv.measure_all()
qc = Unroll3qOrMore()(qv)

Expand Down Expand Up @@ -476,7 +476,7 @@ class TestSabrePreLayout(QiskitTestCase):

def setUp(self):
super().setUp()
circuit = EfficientSU2(16, entanglement="circular", reps=6, flatten=True)
circuit = efficient_su2(16, entanglement="circular", reps=6)
circuit.assign_parameters([math.pi / 2] * len(circuit.parameters), inplace=True)
circuit.measure_all()
self.circuit = circuit
Expand Down
4 changes: 2 additions & 2 deletions test/python/transpiler/test_unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from qiskit import transpile
from qiskit.providers.fake_provider import Fake5QV1, GenericBackendV2
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.library import QuantumVolume
from qiskit.circuit.library import quantum_volume
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.transpiler.passes import UnitarySynthesis
from qiskit.quantum_info.operators import Operator
Expand Down Expand Up @@ -558,7 +558,7 @@ def test_two_qubit_pulse_optimal_none_no_raise(self):

def test_qv_natural(self):
"""check that quantum volume circuit compiles for natural direction"""
qv64 = QuantumVolume(5, seed=15)
qv64 = quantum_volume(5, seed=15)

def construct_passmanager(basis_gates, coupling_map, synthesis_fidelity, pulse_optimize):
seed = 2
Expand Down
16 changes: 11 additions & 5 deletions test/python/transpiler/test_vf2_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from qiskit.converters import circuit_to_dag
from qiskit.providers.fake_provider import Fake5QV1, Fake127QPulseV1, GenericBackendV2
from qiskit.circuit import Measure
from qiskit.circuit.library import GraphState, CXGate, XGate, HGate
from qiskit.circuit.library import GraphStateGate, CXGate, XGate, HGate
from qiskit.transpiler import PassManager, AnalysisPass
from qiskit.transpiler.target import InstructionProperties
from qiskit.transpiler.preset_passmanagers.common import generate_embed_passmanager
Expand Down Expand Up @@ -293,9 +293,12 @@ class TestVF2LayoutLattice(LayoutTestCase):
cmap25 = CouplingMap.from_hexagonal_lattice(25, 25, bidirectional=False)

def graph_state_from_pygraph(self, graph):
"""Creates a GraphState circuit from a PyGraph"""
"""Creates a GraphStateGate circuit from a PyGraph"""
adjacency_matrix = rustworkx.adjacency_matrix(graph)
return GraphState(adjacency_matrix).decompose()
num_qubits = adjacency_matrix.shape[0]
qc = QuantumCircuit(num_qubits)
qc.append(GraphStateGate(adjacency_matrix), range(num_qubits))
return qc.decompose()

def test_hexagonal_lattice_graph_20_in_25(self):
"""A 20x20 interaction map in 25x25 coupling map"""
Expand Down Expand Up @@ -509,10 +512,13 @@ def test_perfect_fit_Manhattan(self):
rows = [x[0] for x in MANHATTAN_CMAP]
cols = [x[1] for x in MANHATTAN_CMAP]

adj_matrix = numpy.zeros((65, 65))
num_qubits = 65
adj_matrix = numpy.zeros((num_qubits, num_qubits))
adj_matrix[rows, cols] = 1
circuit = QuantumCircuit(num_qubits)

circuit = GraphState(adj_matrix).decompose()
circuit.append(GraphStateGate(adj_matrix), range(num_qubits))
circuit = circuit.decompose()
circuit.measure_all()

dag = circuit_to_dag(circuit)
Expand Down
4 changes: 2 additions & 2 deletions test/python/visualization/test_circuit_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
CPhaseGate,
HamiltonianGate,
Isometry,
iqp,
)
from qiskit.circuit import Parameter, Qubit, Clbit
from qiskit.circuit.library import IQP
from qiskit.quantum_info.random import random_unitary
from qiskit.utils import optionals
from .visualization import QiskitVisualizationTestCase
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_big_gates(self):
filename = self._get_resource_path("test_latex_big_gates.tex")
qr = QuantumRegister(6, "q")
circuit = QuantumCircuit(qr)
circuit.append(IQP([[6, 5, 3], [5, 4, 5], [3, 5, 1]]), [0, 1, 2])
circuit.append(iqp([[6, 5, 3], [5, 4, 5], [3, 5, 1]]), [0, 1, 2])

desired_vector = [
1 / math.sqrt(16) * complex(0, 1),
Expand Down
6 changes: 2 additions & 4 deletions test/visual/mpl/circuit/test_circuit_matplotlib_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@
CPhaseGate,
HamiltonianGate,
Isometry,
iqp,
)
from qiskit.circuit.library import MCXVChain
from qiskit.circuit.annotated_operation import (
AnnotatedOperation,
InverseModifier,
ControlModifier,
PowerModifier,
)
from qiskit.circuit import Parameter, Qubit, Clbit, IfElseOp, SwitchCaseOp
from qiskit.circuit.library import IQP
from qiskit.circuit.classical import expr, types
from qiskit.quantum_info import random_clifford
from qiskit.quantum_info.random import random_unitary
Expand Down Expand Up @@ -543,7 +542,7 @@ def test_big_gates(self):
"""Test large gates with params"""
qr = QuantumRegister(6, "q")
circuit = QuantumCircuit(qr)
circuit.append(IQP([[6, 5, 3], [5, 4, 5], [3, 5, 1]]), [0, 1, 2])
circuit.append(iqp([[6, 5, 3], [5, 4, 5], [3, 5, 1]]), [0, 1, 2])

desired_vector = [
1 / math.sqrt(16) * complex(0, 1),
Expand Down Expand Up @@ -585,7 +584,6 @@ def test_cnot(self):
circuit.ccx(0, 1, 2)
circuit.append(XGate().control(3, ctrl_state="010"), [qr[2], qr[3], qr[0], qr[1]])
circuit.append(MCXGate(num_ctrl_qubits=3, ctrl_state="101"), [qr[0], qr[1], qr[2], qr[4]])
circuit.append(MCXVChain(3, dirty_ancillas=True), [qr[0], qr[1], qr[2], qr[3], qr[5]])

fname = "cnot.png"
self.circuit_drawer(circuit, output="mpl", filename=fname)
Expand Down

0 comments on commit 85cdf63

Please sign in to comment.