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

Re-organize files so QASM circuits live in a different directory than… #128

Merged
merged 19 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7c31f0d
Delete old testing notebooks
jordandsullivan Dec 6, 2024
8fec3e6
Delete redundant ucc_compile.py file
jordandsullivan Dec 6, 2024
be7a81e
Re-organize files so QASM circuits live in a different directory than…
jordandsullivan Dec 7, 2024
ede7041
Merge branch '101-clean-up-unnecessary-files' of https://github.com/u…
jordandsullivan Dec 10, 2024
1707a1c
Merge branch 'main' of https://github.com/unitaryfund/ucc into 45-sep…
jordandsullivan Dec 11, 2024
03ee51f
Merge branch 'main' of https://github.com/unitaryfund/ucc into 45-sep…
jordandsullivan Dec 11, 2024
d266bf5
Merge branch 'main' of https://github.com/unitaryfund/ucc into 45-sep…
jordandsullivan Dec 11, 2024
ce66799
Delete benchmarks/results/gates_2024-12-06.csv
jordandsullivan Dec 12, 2024
529b2a0
Correct filepath
jordandsullivan Dec 12, 2024
4b478e3
Merge branch '45-separate-qasm-benchmark-files' of https://github.com…
jordandsullivan Dec 12, 2024
2984e8b
Update benchmark results
actions-user Dec 12, 2024
d70c7ad
Update QASM circuits folder name to new location
jordandsullivan Dec 16, 2024
79db120
Delete benchmarks/results/gates_2024-12-12.csv
jordandsullivan Dec 16, 2024
81d4f3e
Delete unnecessary __init__ in QASM folder
jordandsullivan Dec 16, 2024
252ff16
Merge branch '45-separate-qasm-benchmark-files' of https://github.com…
jordandsullivan Dec 16, 2024
24fa29b
Update benchmark results
actions-user Dec 16, 2024
e3c3be6
Merge branch 'main' into 45-separate-qasm-benchmark-files
jordandsullivan Dec 16, 2024
f353960
Merge branch 'main' of https://github.com/unitaryfund/ucc into 45-sep…
jordandsullivan Dec 17, 2024
df923b4
Update QASM file reference in small test shell script
jordandsullivan Dec 17, 2024
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
1 change: 0 additions & 1 deletion benchmarks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .write_qasm import write_qasm
from .scripts import log_performance, save_results
2 changes: 0 additions & 2 deletions benchmarks/circuits/__init__.py

This file was deleted.

141 changes: 0 additions & 141 deletions benchmarks/generate_qasm.ipynb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted this to a script (see below).

This file was deleted.

25 changes: 25 additions & 0 deletions benchmarks/results/gates_2024-12-16.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
compiler,circuit_name,raw_multiq_gates,compile_time,compiled_multiq_gates
qiskit,qaoa_barabasi_albert,1176,0.18260502815246582,1176
pytket,qaoa_barabasi_albert,1176,0.022324562072753906,1176
ucc,qaoa_barabasi_albert,1176,0.7321248054504395,1176
cirq,qaoa_barabasi_albert,1176,7.504948854446411,1176
qiskit,qft,10050,0.5772039890289307,3244
ucc,qft,10050,2.8528826236724854,2740
pytket,qft,10050,0.27750396728515625,5890
ucc,square_heisenberg,2160,0.3288688659667969,540
qiskit,square_heisenberg,2160,0.2869715690612793,540
pytket,square_heisenberg,2160,0.12201833724975586,2160
cirq,square_heisenberg,2160,9.324482917785645,540
ucc,prep_select,9744,6.975432395935059,9702
qiskit,prep_select,9744,1.6321191787719727,9708
ucc,qcnn,388,0.1713879108428955,388
qiskit,qcnn,388,0.08201837539672852,388
cirq,qft,10050,50.458903789520264,4648
pytket,qcnn,388,0.03914165496826172,388
pytket,prep_select,9744,0.3006443977355957,9712
cirq,qcnn,388,2.2956674098968506,388
cirq,prep_select,9744,72.23616528511047,9712
pytket,qv,15000,4.486355781555176,15000
ucc,qv,15000,4.734463453292847,14856
qiskit,qv,15000,5.65778374671936,14856
cirq,qv,15000,190.9960744380951,14856
4 changes: 3 additions & 1 deletion benchmarks/scripts/__init__.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating imports because of moved modules and new script (vs. notebook) for generating the qasm code

Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .common import log_performance, save_results
from .common import log_performance, save_results
from .qiskit_circuits import qaoa_ising_ansatz, qcnn_circuit, VQE_ansatz, random_clifford_circuit
from .cirq_circuits import cirq_prep_select
55 changes: 55 additions & 0 deletions benchmarks/scripts/generate_qasm.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just converting the old notebook version to a script

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this file needs to be an executable?

# coding: utf-8

# ### Prepare & Select
# Prepare an N-qubit GHZ state and select the all ones state.

from write_qasm import write_qasm
from cirq_circuits import VQE_ansatz, cirq_prep_select
from qiskit_circuits import qcnn_circuit, qaoa_ising_ansatz
from numpy import log2, ceil


# ### Prepare & Select
num_qubits = 25
target_state="1" * num_qubits

circuit = cirq_prep_select(num_qubits, target_state=target_state)
filename = f"prep_select_N{num_qubits}_ghz"

write_qasm(circuit,
circuit_name=filename,
# basis_gates=['rz', 'rx', 'ry', 'h', 'cx']
)
jordandsullivan marked this conversation as resolved.
Show resolved Hide resolved

# ### QCNN circuit
num_qubits = 100
num_layers = int(ceil(log2(num_qubits)))

seed = 12345

circuit = qcnn_circuit(num_qubits, seed=seed)
filename = f"qcnn_N{num_qubits}_{num_layers}layers"

write_qasm(circuit,
circuit_name=filename,
basis_gates=['rz', 'rx', 'ry', 'h', 'cx'])

# ### Parameterized VQE ansatz
num_qubits = 50
num_layers = num_qubits * 2
num_layers = num_qubits * 2

circuit = VQE_ansatz(num_qubits, num_layers)
filename = f"VQE_ansatz_N{num_qubits}_{num_layers}layers"

write_qasm(circuit, circuit_name=filename, version='3')

# ### QAOA neighest neighbors Ising mode
num_qubits = 50
num_layers = num_qubits * 3

circuit = qaoa_ising_ansatz(num_qubits, num_layers)
filename = f"QAOA_Ising_ansatz_N{num_qubits}_{num_layers}layers"

write_qasm(circuit, circuit_name=filename, version='3')
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .circuits import qcnn_circuit, VQE_ansatz, qaoa_ising_ansatz
from .circuits import qcnn_circuit, VQE_ansatz, qaoa_ising_ansatz, random_clifford_circuit
2 changes: 1 addition & 1 deletion benchmarks/scripts/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RESULTS_FOLDER="$SCRIPT_DIR/../results"
mkdir -p "$RESULTS_FOLDER"

# Define the common folder path
QASM_FOLDER="$SCRIPT_DIR/../circuits/qasm2/"
QASM_FOLDER="$SCRIPT_DIR/../qasm_circuits/qasm2/"

# Define your list of QASM file names (without the common path)
QASM_FILES=(
Expand Down
8 changes: 5 additions & 3 deletions benchmarks/write_qasm.py → benchmarks/scripts/write_qasm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

from qbraid.transpiler import transpile as translate
from qbraid.programs.alias_manager import get_program_type_alias
from qiskit import transpile as qiskit_transpile
from os.path import join

def write_qasm(circuit, circuit_name, version='2', basis_gates=[]):

def write_qasm(circuit, circuit_name, version='2', basis_gates=[], folder="../qasm_circuits"):
qiskit_circuit = translate(circuit, 'qiskit')
if basis_gates:
decomp_circuit = qiskit_transpile(
Expand All @@ -17,7 +18,8 @@ def write_qasm(circuit, circuit_name, version='2', basis_gates=[]):
qasm_string = translate(decomp_circuit, 'qasm' + version)

# Write the string to a .qasm file
filename = f"./circuits/qasm{version}/ucc/{circuit_name}"

filename = join(folder, f"/qasm{version}/ucc/{circuit_name}")
if basis_gates:
filename += f"_basis_{'_'.join(basis_gates)}"

Expand Down
2 changes: 1 addition & 1 deletion ucc/tests/test_compile.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating import references for moved files. I could see an argument that it doesn't make sense to have the Qiskit and Cirq files inside the benchmarks/scripts module though

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from qiskit.quantum_info import Statevector
from qiskit.transpiler.passes import GatesInBasis

from benchmarks.circuits import qcnn_circuit, random_clifford_circuit
from benchmarks.scripts import qcnn_circuit, random_clifford_circuit
from ucc import compile
from ucc.transpilers.ucc_defaults import UCCDefault1

Expand Down