-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
register visit completed exploring measurements complete measurements start gates add reset
- Loading branch information
1 parent
6a87ac1
commit 1daf009
Showing
24 changed files
with
851 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
|
||
""" | ||
Module defining Cirq LLVM Module elements. | ||
""" | ||
|
||
import hashlib | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright (C) 2023 qBraid | ||
# | ||
# This file is part of the qBraid-SDK | ||
# | ||
# The qBraid-SDK is free software released under the GNU General Public License v3 | ||
# or later. You can redistribute and/or modify it under the terms of the GPL v3. | ||
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
# | ||
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3. | ||
|
||
""" | ||
Module mapping supported QASM gates/operations to pyqir functions. | ||
""" | ||
|
||
import pyqir | ||
|
||
|
||
def id_gate(builder, qubits): | ||
pyqir._native.x(builder, qubits) | ||
pyqir._native.x(builder, qubits) | ||
|
||
|
||
PYQIR_ONE_QUBIT_OP_MAP = { | ||
# Identity Gate | ||
"id": id_gate, | ||
# Single-Qubit Clifford Gates | ||
"h": pyqir._native.h, | ||
"x": pyqir._native.x, | ||
"y": pyqir._native.y, | ||
"z": pyqir._native.z, | ||
# Single-Qubit Non-Clifford Gates | ||
"s": pyqir._native.s, | ||
"t": pyqir._native.t, | ||
"sdg": pyqir._native.s_adj, | ||
"tdg": pyqir._native.t_adj, | ||
# Single-Qubit Rotation Gates | ||
"rx": pyqir._native.rx, | ||
"ry": pyqir._native.ry, | ||
"rz": pyqir._native.rz, | ||
|
||
# Classical Gates/Operations | ||
"measure": pyqir._native.mz, | ||
"reset": pyqir._native.reset, | ||
} | ||
|
||
PYQIR_TWO_QUBIT_OP_MAP = { | ||
"cx": pyqir._native.cx, | ||
"CX" : pyqir._native.cx, | ||
"cz": pyqir._native.cz, | ||
"swap": pyqir._native.swap, | ||
} | ||
|
||
PYQIR_THREE_QUBIT_OP_MAP = { | ||
"ccx": pyqir._native.ccx, | ||
} | ||
|
||
def map_qasm_op_to_pyqir_callable(op_name: str): | ||
try: | ||
return PYQIR_ONE_QUBIT_OP_MAP[op_name], 1 | ||
except KeyError: | ||
pass | ||
try: | ||
return PYQIR_TWO_QUBIT_OP_MAP[op_name], 2 | ||
except KeyError: | ||
pass | ||
try: | ||
return PYQIR_THREE_QUBIT_OP_MAP[op_name], 3 | ||
except KeyError: | ||
raise ValueError(f"Unsupported QASM operation: {op_name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Use this for qasm3 equivalent too. | ||
# custom gate definitions should be decomposed into the basic gates | ||
# supported by the QIR conversion. | ||
# The supported gates are defined in the opsets module. | ||
|
||
|
||
# can use this - | ||
# https://github.com/qBraid/qBraid/blob/eec41d1d4a2cbda0385191d041884fbe2965328e/qbraid/programs/qasm3.py#L108 | ||
|
||
|
||
# run simulations with both qasm3 and qir programs and compare the results for final tests | ||
|
||
|
||
# can use rigetti simulator for qir programs and qiskit for qasm3 programs |
Oops, something went wrong.