-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 505c19f
Showing
66 changed files
with
2,468,234 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Specify a minimum CMake version | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
# Specify the project details | ||
project(MyPackage | ||
VERSION 0.0.1 | ||
DESCRIPTION "QASMTrans" | ||
LANGUAGES C CXX) | ||
|
||
|
||
# Set C++ and CUDA standards | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# adding debug symbols | ||
set(CMAKE_BUILD_TYPE Debug) | ||
# set(CMAKE_CXX_FLAGS_DEBUG "-g -pg" | ||
# set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg") | ||
|
||
|
||
|
||
if(APPLE) | ||
message("Running on Apple platform") | ||
# Additional configuration for Apple platforms | ||
else() | ||
message("Not running on Apple platform") | ||
# Configuration for non-Apple platforms | ||
set(CMAKE_C_COMPILER cc) | ||
set(CMAKE_CXX_COMPILER CC) | ||
set(CMAKE_CUDA_HOST_COMPILER mpicxx) | ||
|
||
|
||
# Set the nvshmem home directory | ||
list(APPEND CMAKE_PREFIX_PATH $ENV{HOME}/qasmtrans) | ||
# set(CMAKE_CUDA_FLAGS_RELEASE "-O3") | ||
endif() | ||
|
||
|
||
# Enable highest optimization for release build | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3") | ||
|
||
# Include directories | ||
include_directories(${PROJECT_SOURCE_DIR}/header) | ||
include_directories(${PROJECT_SOURCE_DIR}/parser) | ||
include_directories(${PROJECT_SOURCE_DIR}/dump) | ||
include_directories(${PROJECT_SOURCE_DIR}/passes) | ||
|
||
# # # Subdirectories | ||
# add_subdirectory(qasm) | ||
|
||
set(SOURCE_FILE "qasmtrans.cpp") | ||
|
||
add_executable(qasmtrans src/qasmtrans.cpp) | ||
target_compile_features(qasmtrans PRIVATE cxx_std_17) |
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,24 @@ | ||
QASMTrans, Pacific Northwest National Laboratory, 08/05/2023, Richland, WA, USA. | ||
|
||
Copyright <2023> Battelle Memorial Institute | ||
|
||
BSD-II | ||
Redistribution and use in source and binary forms, with or | ||
without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or other | ||
materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,9 @@ | ||
# For systems without CMake | ||
CC = g++ | ||
FLAGS = -O3 -std=c++17 | ||
INC = -I./header -I./parser -I./passes -I./dump | ||
|
||
all: qasmtrans | ||
|
||
qasmtrans: src/qasmtrans.cpp #dump/dump_qasm.hpp parser/lexer.hpp parser/parser_util.hpp parser/qasm_parser.hpp parser/qasm_parser_expr.hpp passes/transpiler.hpp passes/decompose.hpp passes/remapping.hpp passes/routing_mapping.hpp | ||
$(CC) $(FLAGS) $(INC) src/qasmtrans.cpp -o $@ |
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,22 @@ | ||
This material was prepared as an account of work sponsored by an agency of | ||
the United States Government. Neither the United States Government nor the | ||
United States Department of Energy, nor Battelle, nor any of their employees, | ||
nor any jurisdiction or organization that has cooperated in the development | ||
of these materials, makes any warranty, express or implied, or assumes any | ||
legal liability or responsibility for the accuracy, completeness, or usefulness | ||
or any information, apparatus, product, software, or process disclosed, or | ||
represents that its use would not infringe privately owned rights. | ||
|
||
Reference herein to any specific commercial product, process, or service by | ||
trade name, trademark, manufacturer, or otherwise does not necessarily constitute | ||
or imply its endorsement, recommendation, or favoring by the United States | ||
Government or any agency thereof, or Battelle Memorial Institute. The views and | ||
opinions of authors expressed herein do not necessarily state or reflect those | ||
of the United States Government or any agency thereof. | ||
|
||
PACIFIC NORTHWEST NATIONAL LABORATORY | ||
operated by | ||
BATTELLE | ||
for the | ||
UNITED STATES DEPARTMENT OF ENERGY | ||
under Contract DE-AC05-76RL01830 |
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,118 @@ | ||
# QASMTrans | ||
QASMTrans is a quantum transpiler for effectively parsing and translating general OpenQASM[1] circuits to | ||
circuits compiled for a particular NISQ device (e.g., from IBMQ, Rigetti, IonQ, Quantinuum), addressing | ||
the contraints of basis gates and qubit topology. QASMTrans is purely developed in C++ without external | ||
library dependency, facilitate deployment across platforms. It is specially designed for emerging deep | ||
circuits, such as those from HHL, QPE, quantum simulation, etc. QASMTrans is easy to extend for adding | ||
new optimization passes and backend devices (see [extension](qasmtrans_passes/README.md)). | ||
|
||
|
||
## Installation | ||
To install the software, follow the steps below: | ||
|
||
```bash | ||
git clone https://github.com/pnnl/qasmtrans.git | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
## Execution | ||
To run the transpiler, use the command below: | ||
|
||
```bash | ||
./qasmtrans -i ../data/test_benchmark/bv10.qasm -m ibmq -b ibmq_toronto -v 1 | ||
``` | ||
|
||
## Options | ||
QASMTrans command-line options: | ||
|
||
- `-i`: Input qasm file, e.g. `data/test_benchmark/bv10.qasm` | ||
|
||
- `-o`: Specify the output file location, the default path is `data/output_qasm_file/{circuit}_{mode}.qasm`. | ||
|
||
- `-b`: Sepcify basis gate set {x, y, z} (Future support) | ||
|
||
- `-q`: Take a qasm circuit string as input (Future support) | ||
|
||
- `-m`: Set the mode that determines the specific basis gate set for a vendor: | ||
- `ibmq` : The basis gates for IBMQ here is [rz,sx,x,cx] (default) | ||
- `ionq`: The basis gates for IonQ here is [rx(gpi),ry(gpi2),rz(gz),rxx(ms)] | ||
- `quantinuum` : The basis gates for Quantinuum here is [U(b8;,d5;),rz,zz] | ||
- `rigetti` : The basis gates for Rigetti here is [rx,ry,cz] | ||
|
||
- `-c`: Specify the backend device with certain topology. The path is "data/devices/" | ||
|
||
IBMQ Machines (Heavy-hexagon): | ||
|
||
- `ibmq_toronto (27 qubits)` (default option) | ||
- `ibmq_jakarta (7 qubits)` | ||
- `ibmq_guadalupe (16 qubits)` | ||
- `ibm_cairo (27 qubits)` | ||
- `ibm_brisbane (127 qubits)` | ||
|
||
Rigetti Machine (Ring): | ||
- `aspen_m3 (80 qubits)` | ||
|
||
Quantinuum Machine (All-to-all connected): | ||
- `h1_2 (12 qubits)` | ||
- `h1_1 (20 qubits)` | ||
|
||
Dummy Machines (All-to-all connected): | ||
|
||
- `dummy_ibmq12 (12 qubits)` | ||
- `dummy_ibmq14 (14 qubits)` | ||
- `dummy_ibmq15 (15 qubits)` | ||
- `dummy_ibmq16 (16 qubits)` | ||
- `dummy_ibmq30 (30 qubits)` | ||
|
||
- `-limited`: Limit the number of qubits used (i.e., avoid using all physical qubits of the device). Due to more limited topology, more gates can be introduced. This option is | ||
particularly useful for numerical simulation on a classical system, given less qubits. | ||
|
||
- `-v`: Set the verbose level for debugging: | ||
- 0 : No output (default) | ||
- 1 : Output device_name, gate_ops, transpilation time, output file location | ||
- 2 : Detailed information, including initial_mapping, transpilation time for different steps during the routing/mapping pass | ||
|
||
## Data Structure | ||
The central data structure are: | ||
|
||
`Circuit`: each transpilation pass takes in a circuit object and applies the logic of the pass to the circuit: | ||
- `n_qubits`: The total number of qubits in the circuit. | ||
- `gates`: A vector storing the gates (or quantum operations) applied within the circuit. | ||
|
||
`Gate`: basic data structure for a gate: | ||
- `op_name`: This attribute specifies the type of gate. Examples include 'CX' (CNOT gate), 'Rz' (Pauli-Z rotation gate), etc. | ||
- `ctrl`: This defines the control qubit for controlled operations. | ||
- `qubit`: This represents the target qubit upon which the gate operation is applied. | ||
- `theta/lambda/phi/gama`: These are parameters representing the rotation angle (where applicable) for the gate operation. | ||
|
||
## External Files: | ||
QASMTrans includes two external source header files: | ||
- [lexer.hpp](https://github.com/ArashPartow/lexertk): Lexertk, a simple to use, easy to integrate and extremely fast lexicographical generator. | ||
- [json.hpp](https://github.com/nlohmann/json): a C++ json operation library. | ||
|
||
## Developers: | ||
Fei Hua, Pacific Northwest National Laboratory (Main) | ||
Meng Wang, Pacific Northwest National Laboratory | ||
Ang Li, Pacific Northwest National Laboratory | ||
|
||
Thanks to Gushu Li (University of Pennsylvania) for sharing the Python source code of Sabre[2]). | ||
|
||
## References | ||
- [1] Cross, A.W., Bishop, L.S., Smolin, J.A., & Gambetta, J.M. (2017). Open quantum assembly language. arXiv preprint [arXiv:1707.03429](https://arxiv.org/abs/1707.03429). | ||
- [2] Li, G., Ding, Y., & Xie, Y. (2019). Tackling the qubit mapping problem for NISQ-era quantum devices. In Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems (pp. 1001-1014).(https://dl.acm.org/doi/abs/10.1145/3297858.3304023) | ||
|
||
## Acknowledgments | ||
IPID: 32821-E, IR: PNNL-SA-188499, Export Control: EAR99 | ||
|
||
This software is supported by the U.S. Department of Energy, Office of Science, National Quantum Information Science Research Centers, | ||
Co-design Center for Quantum Advantage (C2QA) under contract number DE-SC0012704. The software is also supported by the U.S. | ||
Department of Energy, Office of Science, National Quantum Information Science Research Centers, Quantum Science Center (QSC). This research used | ||
resources of the Oak Ridge Leadership Computing Facility, which is a DOE Office of Science User Facility supported under Contract | ||
DE-AC05-00OR22725. This research used resources of the National Energy Research Scientific Computing Center (NERSC), a U.S. Department of Energy | ||
Office of Science User Facility located at Lawrence Berkeley National Laboratory, operated under Contract No. DE-AC02-05CH11231. The Pacific | ||
Northwest National Laboratory is operated by Battelle for the U.S. Department of Energy under Contract DE-AC05-76RL01830. | ||
|
||
|
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.