Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding h, p and u to basic aer #10673

Merged
merged 7 commits into from
Sep 8, 2023
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
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.