From 7ac6afc611cec5082cd0058364da4d655029cf00 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Mon, 21 Aug 2023 06:10:25 +0900 Subject: [PATCH 1/5] Adding h, u and p to the BasicAer --- qiskit/providers/basicaer/basicaertools.py | 8 +++++++- qiskit/providers/basicaer/qasm_simulator.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qiskit/providers/basicaer/basicaertools.py b/qiskit/providers/basicaer/basicaertools.py index dfba59e7c36f..768febaecc75 100644 --- a/qiskit/providers/basicaer/basicaertools.py +++ b/qiskit/providers/basicaer/basicaertools.py @@ -23,7 +23,7 @@ from qiskit.exceptions import QiskitError # Single qubit gates supported by ``single_gate_params``. -SINGLE_QUBIT_GATES = ("U", "u1", "u2", "u3", "rz", "sx", "x") +SINGLE_QUBIT_GATES = ("U", "u", "h", "p", "u1", "u2", "u3", "rz", "sx", "x") def single_gate_matrix(gate: str, params: Optional[List[float]] = None): @@ -45,6 +45,12 @@ def single_gate_matrix(gate: str, params: Optional[List[float]] = None): 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": diff --git a/qiskit/providers/basicaer/qasm_simulator.py b/qiskit/providers/basicaer/qasm_simulator.py index f6557866dec6..06095e163aaa 100644 --- a/qiskit/providers/basicaer/qasm_simulator.py +++ b/qiskit/providers/basicaer/qasm_simulator.py @@ -70,8 +70,23 @@ class QasmSimulatorPy(BackendV1): "max_shots": 0, "coupling_map": None, "description": "A python simulator for qasm experiments", - "basis_gates": ["u1", "u2", "u3", "rz", "sx", "x", "cx", "id", "unitary"], + "basis_gates": ["h", "u", "p", "u1", "u2", "u3", "rz", "sx", "x", "cx", "id", "unitary"], "gates": [ + { + "name": "h", + "parameters": [], + "qasm_def": "gate h q { UU(pi/2,0,pi) q; }", + }, + { + "name": "p", + "parameters": ["lambda"], + "qasm_def": "gate p(lambda) q { U(0,0,lambda) q; }", + }, + { + "name": "u", + "parameters": ["theta", "phi", "lambda"], + "qasm_def": "gate u(theta,phi,lambda) q { U(theta,phi,lambda) q; }", + }, { "name": "u1", "parameters": ["lambda"], From 62518faf1f8d59ff9f5e30a1ca1de16ac0cf66c1 Mon Sep 17 00:00:00 2001 From: Jay Gambetta Date: Mon, 21 Aug 2023 06:11:18 +0900 Subject: [PATCH 2/5] typo --- qiskit/providers/basicaer/qasm_simulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/providers/basicaer/qasm_simulator.py b/qiskit/providers/basicaer/qasm_simulator.py index 06095e163aaa..555d79fdb080 100644 --- a/qiskit/providers/basicaer/qasm_simulator.py +++ b/qiskit/providers/basicaer/qasm_simulator.py @@ -75,7 +75,7 @@ class QasmSimulatorPy(BackendV1): { "name": "h", "parameters": [], - "qasm_def": "gate h q { UU(pi/2,0,pi) q; }", + "qasm_def": "gate h q { U(pi/2,0,pi) q; }", }, { "name": "p", From 248867869e5e9eced01bed72e7692a3d40df8b43 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 22 Aug 2023 10:57:12 +0200 Subject: [PATCH 3/5] reno --- releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml diff --git a/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml new file mode 100644 index 000000000000..152472ee282f --- /dev/null +++ b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The `QasmSimulator` python-based simulator included in :class:`qiskit.providers.basicaer` + now includes `h`, `p`, and `u` in its basis gate set. From 100065a6668e73b0c807e6626a5c7128dac3db3b Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 22 Aug 2023 13:18:35 +0200 Subject: [PATCH 4/5] reno --- releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml index 152472ee282f..8f8c9db518f1 100644 --- a/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml +++ b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml @@ -2,4 +2,4 @@ features: - | The `QasmSimulator` python-based simulator included in :class:`qiskit.providers.basicaer` - now includes `h`, `p`, and `u` in its basis gate set. + now includes `h` (:class:`.HGate`), `p` (:class:`.PhaseGate`), and `u` (:class:`.UGate`) in its basis gate set. From 06ef9899e8f64a7d1881226f79621d6f7e8114cc Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Thu, 24 Aug 2023 11:39:38 +0200 Subject: [PATCH 5/5] Update releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml --- releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml index 8f8c9db518f1..530836dbe597 100644 --- a/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml +++ b/releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml @@ -1,5 +1,5 @@ --- -features: +upgrade: - | The `QasmSimulator` python-based simulator included in :class:`qiskit.providers.basicaer` now includes `h` (:class:`.HGate`), `p` (:class:`.PhaseGate`), and `u` (:class:`.UGate`) in its basis gate set.