Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Change base gate U3 to U #1351

Merged
merged 5 commits into from
Oct 15, 2020
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/aqua/quantum_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, backend,
seed_simulator (int, optional): Random seed for simulators
max_credits (int, optional): Maximum credits to use
basis_gates (list[str], optional): List of basis gate names supported by the
target. Default: ['u1', 'u2', 'u3', 'cx', 'id']
target. Defaults to basis gates of the backend.
coupling_map (CouplingMap or list[list]): Coupling map (perhaps custom) to
target in mapping
initial_layout (Layout or dict or list, optional): Initial layout of qubits in mapping
Expand Down
4 changes: 2 additions & 2 deletions qiskit/aqua/utils/circuit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@


def convert_to_basis_gates(circuit):
""" unroll the circuit using the basis u1, u2, u3, cx gates """
unroller = Unroller(basis=['u1', 'u2', 'u3', 'cx'])
""" unroll the circuit using the basis ['u', 'cx'] """
unroller = Unroller(basis=['u', 'cx'])
return dag_to_circuit(unroller.run(circuit_to_dag(circuit)))


Expand Down
10 changes: 3 additions & 7 deletions qiskit/aqua/utils/controlled_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

""" controlled circuit """

import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.transpiler.passes import Unroller
Expand Down Expand Up @@ -103,7 +102,7 @@ def get_controlled_circuit(circuit, ctl_qubit, tgt_circuit=None, use_basis_gates
clbits.extend(creg)

# get all operations
unroller = Unroller(basis=['u1', 'u2', 'u3', 'cx'])
unroller = Unroller(basis=['u', 'p', 'cx'])
ops = dag_to_circuit(unroller.run(circuit_to_dag(circuit))).data

# process all basis gates to add control
Expand All @@ -112,12 +111,9 @@ def get_controlled_circuit(circuit, ctl_qubit, tgt_circuit=None, use_basis_gates
for op in ops:
if op[0].name == 'id':
apply_cu(qc, 0, 0, 0, ctl_qubit, op[1][0], use_basis_gates=use_basis_gates)
elif op[0].name == 'u1':
elif op[0].name == 'p':
apply_cp(qc, *op[0].params, ctl_qubit, op[1][0], use_basis_gates=use_basis_gates)
elif op[0].name == 'u2':
apply_cu(qc, np.pi / 2, *op[0].params,
ctl_qubit, op[1][0], use_basis_gates=use_basis_gates)
elif op[0].name == 'u3':
elif op[0].name == 'u':
apply_cu(qc, *op[0].params, ctl_qubit, op[1][0], use_basis_gates=use_basis_gates)
elif op[0].name == 'cx':
apply_ccx(qc, ctl_qubit, op[1][0], op[1][1], use_basis_gates=use_basis_gates)
Expand Down