Repository: Qiskit/qiskit

Issue:
extend BasicSimulator with standard gates
As part of the discussion in https://github.com/Qiskit/qiskit/pull/10673, we resolved that every standard gate with a fixed amount of qubits can be in BasicSimulator.


Discussion:
I am interested in taking up this issue. I am new to open source contribution but excited to learn! Will start looking through previous details in [#10673](https://github.com/Qiskit/qiskit/pull/10673).
I've updated this post to refer to `BasicSimulator`, following the removal of `BasicAer` in 1.0.

Resolving patch:
diff --git a/qiskit/circuit/library/standard_gates/x.py b/qiskit/circuit/library/standard_gates/x.py
--- a/qiskit/circuit/library/standard_gates/x.py
+++ b/qiskit/circuit/library/standard_gates/x.py
@@ -107,7 +107,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
@@ -250,7 +250,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
@@ -444,7 +444,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
@@ -585,7 +585,7 @@ def __init__(
         Args:
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
         """
         from .sx import SXGate
 
@@ -785,7 +785,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
@@ -1029,7 +1029,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
@@ -1204,7 +1204,7 @@ def control(
             num_ctrl_qubits: number of control qubits.
             label: An optional label for the gate [Default: ``None``]
             ctrl_state: control state expressed as integer,
-                string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
+                string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
             annotated: indicates whether the controlled gate can be implemented
                 as an annotated gate.
 
diff --git a/qiskit/providers/basic_provider/basic_provider_tools.py b/qiskit/providers/basic_provider/basic_provider_tools.py
--- a/qiskit/providers/basic_provider/basic_provider_tools.py
+++ b/qiskit/providers/basic_provider/basic_provider_tools.py
@@ -23,7 +23,30 @@
 from qiskit.exceptions import QiskitError
 
 # Single qubit gates supported by ``single_gate_params``.
-SINGLE_QUBIT_GATES = ("U", "u", "h", "p", "u1", "u2", "u3", "rz", "sx", "x")
+SINGLE_QUBIT_GATES = {
+    "U": gates.UGate,
+    "u": gates.UGate,
+    "u1": gates.U1Gate,
+    "u2": gates.U2Gate,
+    "u3": gates.U3Gate,
+    "h": gates.HGate,
+    "p": gates.PhaseGate,
+    "s": gates.SGate,
+    "sdg": gates.SdgGate,
+    "sx": gates.SXGate,
+    "sxdg": gates.SXdgGate,
+    "t": gates.TGate,
+    "tdg": gates.TdgGate,
+    "x": gates.XGate,
+    "y": gates.YGate,
+    "z": gates.ZGate,
+    "id": gates.IGate,
+    "i": gates.IGate,
+    "r": gates.RGate,
+    "rx": gates.RXGate,
+    "ry": gates.RYGate,
+    "rz": gates.RZGate,
+}
 
 
 def single_gate_matrix(gate: str, params: list[float] | None = None) -> np.ndarray:
@@ -40,42 +63,55 @@ def single_gate_matrix(gate: str, params: list[float] | None = None) -> np.ndarr
     """
     if params is None:
         params = []
-
-    if gate == "U":
-        gc = gates.UGate
-    elif gate == "u3":
-        gc = gates.U3Gate
-    elif gate == "h":
-        gc = gates.HGate
-    elif gate == "u":
-        gc = gates.UGate
-    elif gate == "p":
-        gc = gates.PhaseGate
-    elif gate == "u2":
-        gc = gates.U2Gate
-    elif gate == "u1":
-        gc = gates.U1Gate
-    elif gate == "rz":
-        gc = gates.RZGate
-    elif gate == "id":
-        gc = gates.IGate
-    elif gate == "sx":
-        gc = gates.SXGate
-    elif gate == "x":
-        gc = gates.XGate
+    if gate in SINGLE_QUBIT_GATES:
+        gc = SINGLE_QUBIT_GATES[gate]
     else:
         raise QiskitError("Gate is not a valid basis gate for this simulator: %s" % gate)
 
     return gc(*params).to_matrix()
 
 
-# Cache CX matrix as no parameters.
-_CX_MATRIX = gates.CXGate().to_matrix()
-
-
-def cx_gate_matrix() -> np.ndarray:
-    """Get the matrix for a controlled-NOT gate."""
-    return _CX_MATRIX
+# Two qubit gates WITHOUT parameters: name -> matrix
+TWO_QUBIT_GATES = {
+    "CX": gates.CXGate().to_matrix(),
+    "cx": gates.CXGate().to_matrix(),
+    "ecr": gates.ECRGate().to_matrix(),
+    "cy": gates.CYGate().to_matrix(),
+    "cz": gates.CZGate().to_matrix(),
+    "swap": gates.SwapGate().to_matrix(),
+    "iswap": gates.iSwapGate().to_matrix(),
+    "ch": gates.CHGate().to_matrix(),
+    "cs": gates.CSGate().to_matrix(),
+    "csdg": gates.CSdgGate().to_matrix(),
+    "csx": gates.CSXGate().to_matrix(),
+    "dcx": gates.DCXGate().to_matrix(),
+}
+
+# Two qubit gates WITH parameters: name -> class
+TWO_QUBIT_GATES_WITH_PARAMETERS = {
+    "cp": gates.CPhaseGate,
+    "crx": gates.CRXGate,
+    "cry": gates.CRYGate,
+    "crz": gates.CRZGate,
+    "cu": gates.CUGate,
+    "cu1": gates.CU1Gate,
+    "cu3": gates.CU3Gate,
+    "rxx": gates.RXXGate,
+    "ryy": gates.RYYGate,
+    "rzz": gates.RZZGate,
+    "rzx": gates.RZXGate,
+    "xx_minus_yy": gates.XXMinusYYGate,
+    "xx_plus_yy": gates.XXPlusYYGate,
+}
+
+
+# Three qubit gates: name -> matrix
+THREE_QUBIT_GATES = {
+    "ccx": gates.CCXGate().to_matrix(),
+    "ccz": gates.CCZGate().to_matrix(),
+    "rccx": gates.RCCXGate().to_matrix(),
+    "cswap": gates.CSwapGate().to_matrix(),
+}
 
 
 def einsum_matmul_index(gate_indices: list[int], number_of_qubits: int) -> str:
diff --git a/qiskit/providers/basic_provider/basic_simulator.py b/qiskit/providers/basic_provider/basic_simulator.py
--- a/qiskit/providers/basic_provider/basic_simulator.py
+++ b/qiskit/providers/basic_provider/basic_simulator.py
@@ -40,7 +40,7 @@
 
 from qiskit.circuit import QuantumCircuit
 from qiskit.circuit.library import UnitaryGate
-from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping
+from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping, GlobalPhaseGate
 from qiskit.providers import Provider
 from qiskit.providers.backend import BackendV2
 from qiskit.providers.models import BackendConfiguration
@@ -51,8 +51,12 @@
 
 from .basic_provider_job import BasicProviderJob
 from .basic_provider_tools import single_gate_matrix
-from .basic_provider_tools import SINGLE_QUBIT_GATES
-from .basic_provider_tools import cx_gate_matrix
+from .basic_provider_tools import (
+    SINGLE_QUBIT_GATES,
+    TWO_QUBIT_GATES,
+    TWO_QUBIT_GATES_WITH_PARAMETERS,
+    THREE_QUBIT_GATES,
+)
 from .basic_provider_tools import einsum_vecmul_index
 from .exceptions import BasicProviderError
 
@@ -138,21 +142,59 @@ def _build_basic_target(self) -> Target:
             num_qubits=None,
         )
         basis_gates = [
+            "ccx",
+            "ccz",
+            "ch",
+            "cp",
+            "crx",
+            "cry",
+            "crz",
+            "cs",
+            "csdg",
+            "cswap",
+            "csx",
+            "cu",
+            "cu1",
+            "cu3",
+            "cx",
+            "cy",
+            "cz",
+            "dcx",
+            "delay",
+            "ecr",
+            "global_phase",
             "h",
-            "u",
+            "id",
+            "iswap",
+            "measure",
             "p",
+            "r",
+            "rccx",
+            "reset",
+            "rx",
+            "rxx",
+            "ry",
+            "ryy",
+            "rz",
+            "rzx",
+            "rzz",
+            "s",
+            "sdg",
+            "swap",
+            "sx",
+            "sxdg",
+            "t",
+            "tdg",
+            "u",
             "u1",
             "u2",
             "u3",
-            "rz",
-            "sx",
-            "x",
-            "cx",
-            "id",
             "unitary",
-            "measure",
-            "delay",
-            "reset",
+            "x",
+            "xx_minus_yy",
+            "xx_plus_yy",
+            "y",
+            "z",
         ]
         inst_mapping = get_standard_gate_name_mapping()
         for name in basis_gates:
@@ -617,24 +659,41 @@ def run_experiment(self, experiment: QasmQobjExperiment) -> dict[str, ...]:
                             value >>= 1
                         if value != int(operation.conditional.val, 16):
                             continue
-                # Check if single  gate
                 if operation.name == "unitary":
                     qubits = operation.qubits
                     gate = operation.params[0]
                     self._add_unitary(gate, qubits)
+                elif operation.name in ("id", "u0", "delay"):
+                    pass
+                elif operation.name == "global_phase":
+                    params = getattr(operation, "params", None)
+                    gate = GlobalPhaseGate(*params).to_matrix()
+                    self._add_unitary(gate, [])
+                # Check if single qubit gate
                 elif operation.name in SINGLE_QUBIT_GATES:
                     params = getattr(operation, "params", None)
                     qubit = operation.qubits[0]
                     gate = single_gate_matrix(operation.name, params)
                     self._add_unitary(gate, [qubit])
-                # Check if CX gate
+                elif operation.name in TWO_QUBIT_GATES_WITH_PARAMETERS:
+                    params = getattr(operation, "params", None)
+                    qubit0 = operation.qubits[0]
+                    qubit1 = operation.qubits[1]
+                    gate = TWO_QUBIT_GATES_WITH_PARAMETERS[operation.name](*params).to_matrix()
+                    self._add_unitary(gate, [qubit0, qubit1])
                 elif operation.name in ("id", "u0"):
                     pass
-                elif operation.name in ("CX", "cx"):
+                elif operation.name in TWO_QUBIT_GATES:
                     qubit0 = operation.qubits[0]
                     qubit1 = operation.qubits[1]
-                    gate = cx_gate_matrix()
+                    gate = TWO_QUBIT_GATES[operation.name]
                     self._add_unitary(gate, [qubit0, qubit1])
+                elif operation.name in THREE_QUBIT_GATES:
+                    qubit0 = operation.qubits[0]
+                    qubit1 = operation.qubits[1]
+                    qubit2 = operation.qubits[2]
+                    gate = THREE_QUBIT_GATES[operation.name]
+                    self._add_unitary(gate, [qubit0, qubit1, qubit2])
                 # Check if reset
                 elif operation.name == "reset":
                     qubit = operation.qubits[0]


Test patch:
diff --git a/test/python/providers/basic_provider/test_standard_library.py b/test/python/providers/basic_provider/test_standard_library.py
new file mode 100644
--- /dev/null
+++ b/test/python/providers/basic_provider/test_standard_library.py
@@ -0,0 +1,531 @@
+# This code is part of Qiskit.
+#
+# (C) Copyright IBM 2017, 2024.
+#
+# This code is licensed under the Apache License, Version 2.0. You may
+# obtain a copy of this license in the LICENSE.txt file in the root directory
+# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
+#
+# Any modifications or derivative works of this code must retain this
+# copyright notice, and modified files need to carry a notice indicating
+# that they have been altered from the originals.
+
+# pylint: disable=missing-function-docstring, missing-module-docstring
+
+import unittest
+
+from qiskit import QuantumCircuit
+from qiskit.providers.basic_provider import BasicSimulator
+import qiskit.circuit.library.standard_gates as lib
+from test import QiskitTestCase  # pylint: disable=wrong-import-order
+
+
+class TestStandardGates(QiskitTestCase):
+    """Standard gates support in BasicSimulator, up to 3 qubits"""
+
+    def setUp(self):
+        super().setUp()
+        self.seed = 43
+        self.shots = 1
+        self.circuit = QuantumCircuit(4)
+
+    def test_barrier(self):
+        self.circuit.barrier(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_barrier_none(self):
+        self.circuit.barrier()
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_unitary(self):
+        matrix = [[0, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 0], [0, 1, 0, 0]]
+        self.circuit.unitary(matrix, [0, 1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_u(self):
+        self.circuit.u(0.5, 1.5, 1.5, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_u1(self):
+        self.circuit.append(lib.U1Gate(0.5), [1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_u2(self):
+        self.circuit.append(lib.U2Gate(0.5, 0.5), [1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_u3(self):
+        self.circuit.append(lib.U3Gate(0.5, 0.5, 0.5), [1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ccx(self):
+        self.circuit.ccx(0, 1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ccz(self):
+        self.circuit.ccz(0, 1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ch(self):
+        self.circuit.ch(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cp(self):
+        self.circuit.cp(0, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_crx(self):
+        self.circuit.crx(1, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cry(self):
+        self.circuit.cry(1, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_crz(self):
+        self.circuit.crz(1, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cswap(self):
+        self.circuit.cswap(0, 1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cu1(self):
+        self.circuit.append(lib.CU1Gate(1), [1, 2])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cu3(self):
+        self.circuit.append(lib.CU3Gate(1, 2, 3), [1, 2])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cx(self):
+        self.circuit.cx(1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ecr(self):
+        self.circuit.ecr(1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cy(self):
+        self.circuit.cy(1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cz(self):
+        self.circuit.cz(1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_h(self):
+        self.circuit.h(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_id(self):
+        self.circuit.id(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rx(self):
+        self.circuit.rx(1, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ry(self):
+        self.circuit.ry(1, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rz(self):
+        self.circuit.rz(1, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rxx(self):
+        self.circuit.rxx(1, 1, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rzx(self):
+        self.circuit.rzx(1, 1, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_ryy(self):
+        self.circuit.ryy(1, 1, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rzz(self):
+        self.circuit.rzz(1, 1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_s(self):
+        self.circuit.s(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_sdg(self):
+        self.circuit.sdg(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_sx(self):
+        self.circuit.sx(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_sxdg(self):
+        self.circuit.sxdg(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_swap(self):
+        self.circuit.swap(1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_iswap(self):
+        self.circuit.iswap(1, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_p(self):
+        self.circuit.p(1, 0)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_r(self):
+        self.circuit.r(0.5, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_t(self):
+        self.circuit.t(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_tdg(self):
+        self.circuit.tdg(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_x(self):
+        self.circuit.x(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_y(self):
+        self.circuit.y(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_z(self):
+        self.circuit.z(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cs(self):
+        self.circuit.cs(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_csdg(self):
+        self.circuit.csdg(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_csx(self):
+        self.circuit.csx(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_cu(self):
+        self.circuit.cu(0.5, 0.5, 0.5, 0.5, 0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_dcx(self):
+        self.circuit.dcx(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_delay(self):
+        self.circuit.delay(0, 1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_reset(self):
+        self.circuit.reset(1)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_rcx(self):
+        self.circuit.rccx(0, 1, 2)
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_global_phase(self):
+        qc = self.circuit
+        qc.append(lib.GlobalPhaseGate(0.1), [])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_xx_minus_yy(self):
+        self.circuit.append(lib.XXMinusYYGate(0.1, 0.2), [0, 1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+    def test_xx_plus_yy(self):
+        self.circuit.append(lib.XXPlusYYGate(0.1, 0.2), [0, 1])
+        self.circuit.measure_all()
+        result = (
+            BasicSimulator().run(self.circuit, shots=self.shots, seed_simulator=self.seed).result()
+        )
+        self.assertEqual(result.success, True)
+
+
+class TestStandardGatesTarget(QiskitTestCase):
+    """Standard gates, up to 3 qubits, as a target"""
+
+    def test_target(self):
+        target = BasicSimulator().target
+        expected = {
+            "cz",
+            "u3",
+            "p",
+            "cswap",
+            "z",
+            "cu1",
+            "ecr",
+            "reset",
+            "ch",
+            "cy",
+            "dcx",
+            "crx",
+            "sx",
+            "unitary",
+            "csdg",
+            "rzz",
+            "measure",
+            "swap",
+            "csx",
+            "y",
+            "s",
+            "xx_plus_yy",
+            "cs",
+            "h",
+            "t",
+            "u",
+            "rxx",
+            "cu",
+            "rzx",
+            "ry",
+            "rx",
+            "cu3",
+            "tdg",
+            "u2",
+            "xx_minus_yy",
+            "global_phase",
+            "u1",
+            "id",
+            "cx",
+            "cp",
+            "rz",
+            "sxdg",
+            "x",
+            "ryy",
+            "sdg",
+            "ccz",
+            "delay",
+            "crz",
+            "iswap",
+            "ccx",
+            "cry",
+            "rccx",
+            "r",
+        }
+        self.assertEqual(set(target.operation_names), expected)
+
+
+if __name__ == "__main__":
+    unittest.main(verbosity=2)
diff --git a/test/python/transpiler/test_passmanager_config.py b/test/python/transpiler/test_passmanager_config.py
--- a/test/python/transpiler/test_passmanager_config.py
+++ b/test/python/transpiler/test_passmanager_config.py
@@ -93,39 +93,77 @@ def test_str(self):
         pm_config.inst_map = None
         str_out = str(pm_config)
         expected = """Pass Manager Config:
-	initial_layout: None
-	basis_gates: ['h', 'u', 'p', 'u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary', 'measure', 'delay', 'reset']
-	inst_map: None
-	coupling_map: None
-	layout_method: None
-	routing_method: None
-	translation_method: None
-	scheduling_method: None
-	instruction_durations: 
-	backend_properties: None
-	approximation_degree: None
-	seed_transpiler: None
-	timing_constraints: None
-	unitary_synthesis_method: default
-	unitary_synthesis_plugin_config: None
-	target: Target: Basic Target
-	Number of qubits: None
-	Instructions:
-		h
-		u
-		p
-		u1
-		u2
-		u3
-		rz
-		sx
-		x
-		cx
-		id
-		unitary
-		measure
-		delay
-		reset
-	
+\tinitial_layout: None
+\tbasis_gates: ['ccx', 'ccz', 'ch', 'cp', 'crx', 'cry', 'crz', 'cs', 'csdg', 'cswap', 'csx', 'cu', 'cu1', 'cu3', 'cx', 'cy', 'cz', 'dcx', 'delay', 'ecr', 'global_phase', 'h', 'id', 'iswap', 'measure', 'p', 'r', 'rccx', 'reset', 'rx', 'rxx', 'ry', 'ryy', 'rz', 'rzx', 'rzz', 's', 'sdg', 'swap', 'sx', 'sxdg', 't', 'tdg', 'u', 'u1', 'u2', 'u3', 'unitary', 'x', 'xx_minus_yy', 'xx_plus_yy', 'y', 'z']
+\tinst_map: None
+\tcoupling_map: None
+\tlayout_method: None
+\trouting_method: None
+\ttranslation_method: None
+\tscheduling_method: None
+\tinstruction_durations:\u0020
+\tbackend_properties: None
+\tapproximation_degree: None
+\tseed_transpiler: None
+\ttiming_constraints: None
+\tunitary_synthesis_method: default
+\tunitary_synthesis_plugin_config: None
+\ttarget: Target: Basic Target
+\tNumber of qubits: None
+\tInstructions:
+\t\tccx
+\t\tccz
+\t\tch
+\t\tcp
+\t\tcrx
+\t\tcry
+\t\tcrz
+\t\tcs
+\t\tcsdg
+\t\tcswap
+\t\tcsx
+\t\tcu
+\t\tcu1
+\t\tcu3
+\t\tcx
+\t\tcy
+\t\tcz
+\t\tdcx
+\t\tdelay
+\t\tecr
+\t\tglobal_phase
+\t\th
+\t\tid
+\t\tiswap
+\t\tmeasure
+\t\tp
+\t\tr
+\t\trccx
+\t\treset
+\t\trx
+\t\trxx
+\t\try
+\t\tryy
+\t\trz
+\t\trzx
+\t\trzz
+\t\ts
+\t\tsdg
+\t\tswap
+\t\tsx
+\t\tsxdg
+\t\tt
+\t\ttdg
+\t\tu
+\t\tu1
+\t\tu2
+\t\tu3
+\t\tunitary
+\t\tx
+\t\txx_minus_yy
+\t\txx_plus_yy
+\t\ty
+\t\tz
+\t
 """
         self.assertEqual(str_out, expected)