Skip to content

Commit

Permalink
remove some name maps
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Nov 2, 2023
1 parent e31ff65 commit 1c8ad83
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 197 deletions.
9 changes: 8 additions & 1 deletion qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def __init__(
self._options_properties = {}
self._target = None
self._mapping = NAME_MAPPING
self._add_delay = False
self._filter_faulty = False

# Set options from backend_options dictionary
if backend_options is not None:
Expand Down Expand Up @@ -352,7 +354,12 @@ def max_circuits(self):
@property
def target(self):
self._target = convert_to_target(
self.configuration(), self.properties(), self.defaults(), self._mapping
self.configuration(),
self.properties(),
self.defaults(),
self._mapping,
add_delay=self._add_delay,
filter_faulty=self._filter_faulty,
)
return self._target

Expand Down
205 changes: 9 additions & 196 deletions qiskit_aer/backends/name_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
Qiskit Aer simulator name mapping for Target object
"""
from qiskit.circuit import ControlledGate, Parameter
from qiskit.circuit.parameterexpression import ParameterValueType
from qiskit.circuit.reset import Reset
from qiskit.circuit.library import (
SXGate,
MCPhaseGate,
MCXGate,
MCU1Gate,
RZGate,
RXGate,
U2Gate,
Expand All @@ -32,6 +34,12 @@
RGate,
MCXGrayCode,
RYGate,
CZGate,
ECRGate,
UnitaryGate,
UCGate,
Initialize,
DiagonalGate,
)
from qiskit.circuit.controlflow import (
IfElseOp,
Expand Down Expand Up @@ -73,209 +81,23 @@
from ..noise.errors import ReadoutError
from ..noise.noise_model import QuantumErrorLocation


class MCSXGate(ControlledGate):
"""mcsx gate"""

def __init__(self, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcsx",
1 + num_ctrl_qubits,
[],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=SXGate(),
)


class MCYGate(ControlledGate):
"""mcy gate"""

def __init__(self, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcy",
1 + num_ctrl_qubits,
[],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=YGate(),
)


class MCZGate(ControlledGate):
"""mcz gate"""

def __init__(self, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcz",
1 + num_ctrl_qubits,
[],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=ZGate(),
)


class MCRXGate(ControlledGate):
"""mcrx gate"""

def __init__(self, theta, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcrx",
1 + num_ctrl_qubits,
[theta],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=RXGate(theta),
)


class MCRYGate(ControlledGate):
"""mcry gate"""

def __init__(self, theta, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcry",
1 + num_ctrl_qubits,
[theta],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=RYGate(theta),
)


class MCRZGate(ControlledGate):
"""mcrz gate"""

def __init__(self, theta, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcrz",
1 + num_ctrl_qubits,
[theta],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=RZGate(theta),
)


class MCRGate(ControlledGate):
"""mcr gate"""

def __init__(self, theta, phi, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcr",
1 + num_ctrl_qubits,
[theta, phi],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=RGate(theta, phi),
)


class MCU1Gate(ControlledGate):
"""mcu1 gate"""

def __init__(self, theta, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcu1",
1 + num_ctrl_qubits,
[theta],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=U1Gate(theta),
)


class MCU2Gate(ControlledGate):
"""mcu2 gate"""

def __init__(self, theta, lam, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcu2",
1 + num_ctrl_qubits,
[theta, lam],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=U2Gate(theta, lam),
)


class MCU3Gate(ControlledGate):
"""mcu3 gate"""

def __init__(self, theta, lam, phi, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcu3",
1 + num_ctrl_qubits,
[theta, phi, lam],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=U3Gate(theta, phi, lam),
)


class MCUGate(ControlledGate):
"""mcu gate"""

def __init__(self, theta, lam, phi, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcu",
1 + num_ctrl_qubits,
[theta, phi, lam],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=U3Gate(theta, phi, lam),
)


class MCSwapGate(ControlledGate):
"""mcswap gate"""

def __init__(self, num_ctrl_qubits, ctrl_state=None):
super().__init__(
"mcswap",
2 + num_ctrl_qubits,
[],
None,
num_ctrl_qubits,
ctrl_state=ctrl_state,
base_gate=SwapGate(),
)


PHI = Parameter("phi")
LAM = Parameter("lam")
NAME_MAPPING = {
"mcsx": MCSXGate,
"mcp": MCPhaseGate,
"mcphase": MCPhaseGate,
"initialize": Initialize,
"quantum_channel": QuantumChannel,
"initialize": Initialize,
"save_expval": SaveExpectationValue,
"diagonal": DiagonalGate,
"save_amplitudes": SaveAmplitudes,
"roerror": ReadoutError,
"mcrx": MCRXGate,
"kraus": Kraus,
"save_statevector_dict": SaveStatevectorDict,
"mcx": MCXGate,
"mcu1": MCU1Gate,
"mcu2": MCU2Gate,
"mcu3": MCU3Gate,
"save_superop": SaveSuperOp,
"multiplexer": UCGate,
"mcy": MCYGate,
"superop": SuperOp,
"save_clifford": SaveClifford,
"save_matrix_product_state": SaveMatrixProductState,
Expand All @@ -288,30 +110,21 @@ def __init__(self, num_ctrl_qubits, ctrl_state=None):
"break_loop": BreakLoopOp,
"continue_loop": ContinueLoopOp,
"save_statevector": SaveStatevector,
"mcu": MCUGate,
"set_density_matrix": SetDensityMatrix,
"qerror_loc": QuantumErrorLocation,
"unitary": UnitaryGate,
"mcz": MCZGate,
"pauli": PauliGate,
"set_unitary": SetUnitary,
"save_state": SaveState,
"mcswap": MCSwapGate,
"set_matrix_product_state": SetMatrixProductState,
"save_unitary": SaveUnitary,
"mcr": MCRGate,
"mcx_gray": MCXGrayCode,
"mcrz": MCRZGate,
"set_superop": SetSuperOp,
"save_expval_var": SaveExpectationValueVariance,
"save_stabilizer": SaveStabilizer,
"set_statevector": SetStatevector,
"mcry": MCRYGate,
"set_stabilizer": SetStabilizer,
"save_amplitudes_sq": SaveAmplitudesSquared,
"save_probabilities_dict": SaveProbabilitiesDict,
"save_probs_ket": SaveProbabilitiesDict,
"save_probs": SaveProbabilities,
"cu2": U2Gate(PHI, LAM).control(),
"reset": Reset(),
}
5 changes: 5 additions & 0 deletions releasenotes/notes/fix_name_mapping-1cf7af45bafcb203.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Removed some name maps that causes error in Qiskit's controlled gate test
cases.

0 comments on commit 1c8ad83

Please sign in to comment.