Skip to content

Commit

Permalink
Adding h, p and u to basic aer (#10673)
Browse files Browse the repository at this point in the history
* Adding h, u and p to the BasicAer

* typo

* reno

* reno

* Update releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml

---------

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
  • Loading branch information
jaygambetta and 1ucian0 authored Sep 8, 2023
1 parent c20356b commit cd507ad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion qiskit/providers/basicaer/basicaertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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":
Expand Down
17 changes: 16 additions & 1 deletion qiskit/providers/basicaer/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 { U(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"],
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/h_basic_aer-3fc5e6776f0de9c1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
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.

0 comments on commit cd507ad

Please sign in to comment.