Skip to content

Commit

Permalink
Merge pull request #150 from unitaryfund/148-mismatched-headers-in-da…
Browse files Browse the repository at this point in the history
…tafiles

148 mismatched headers in datafiles
  • Loading branch information
Misty-W authored Dec 19, 2024
2 parents 2ff1529 + d17274e commit 47ff0ae
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 36 deletions.
Binary file modified benchmarks/avg_compiler_benchmarks_over_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmarks/latest_compiler_benchmarks_by_circuit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions benchmarks/results/expval_2024-11-27_12-41-04.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.2.0
compiler,expval,absoluate_error,relative_error,ideal
uncompiled,4.553649124439119e-18,1.0605990171102696e-16,0.9588328094519584,1.1061355083546608e-16
ucc,-8.890457814381136e-18,1.1950400864984722e-16,1.0803740386890337,1.1061355083546608e-16
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-10-01_20-15-41.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.0
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor
prep_select_N25_ghz_basis_rz_rx_ry_h_cx.qasm,cirq,84.21347093582153,9744.0,9712.0,0.011913710262347265,1.0032948929159802
prep_select_N25_ghz_basis_rz_rx_ry_h_cx.qasm,pytket,0.32483482360839844,9744.0,9712.0,3.0886309594857133,1.0032948929159802
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-10-10_13-40-14.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.0
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor
prep_select,cirq,88.19603204727173,9744.0,9712.0,0.011375737316370756,1.0032948929159802
prep_select,pytket,0.37027907371520996,9744.0,9712.0,2.7095641210543726,1.0032948929159802
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-11-14_10-37-34.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.0
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor,compiled_ratio
prep_select,cirq,29.340710878372192,9744.0,9712.0,0.03419463478833211,1.0032948929159802,0.9967159277504105
prep_select,pytket,0.07207107543945312,9744.0,9712.0,13.920909141405108,1.0032948929159802,0.9967159277504105
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-11-14_12-22-50.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.0
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor,compiled_ratio
prep_select,cirq,29.483647346496582,9744.0,9712.0,0.03402885949370838,1.0032948929159802,0.9967159277504105
prep_select,pytket,0.06683492660522461,9744.0,9712.0,15.011535792388388,1.0032948929159802,0.9967159277504105
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-11-15_09-49-13.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.0
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor,compiled_ratio
prep_select,cirq,30.072205781936646,9744.0,9712.0,0.03336286337594249,1.0032948929159802,0.9967159277504105
prep_select,pytket,0.06765508651733398,9744.0,9712.0,14.829555981114959,1.0032948929159802,0.9967159277504105
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-11-18_14-10-12.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.1
circuit_name,compiler,compile_time,raw_multiq_gates,compiled_multiq_gates,gate_reduction_per_s,reduction_factor,compiled_ratio
prep_select,cirq,29.770545721054077,9744.0,9712.0,0.03370092380289953,1.0032948929159802,0.9967159277504105
prep_select,pytket,0.06841206550598145,9744.0,9712.0,14.66546705607448,1.0032948929159802,0.9967159277504105
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/results/gates_2024-12-10.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.35.0, ucc=0.1.1
# Compiler versions: qiskit=1.2.0, cirq=1.4.1, pytket=1.36.0, ucc=0.1.1
compiler,circuit_name,raw_multiq_gates,compile_time,compiled_multiq_gates
pytket,qaoa_barabasi_albert,1176,0.02424311637878418,1176
ucc,qaoa_barabasi_albert,1176,0.7855277061462402,1176
Expand Down
1 change: 1 addition & 0 deletions benchmarks/results/gates_2024-12-16.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiler versions: qiskit=1.3.0, cirq=1.4.1, pytket=1.36.0, ucc=0.2.0
compiler,circuit_name,raw_multiq_gates,compile_time,compiled_multiq_gates
qiskit,qaoa_barabasi_albert,1176,0.167680025100708,1176
pytket,qaoa_barabasi_albert,1176,0.02307295799255371,1176
Expand Down
26 changes: 26 additions & 0 deletions benchmarks/results/gates_2024-12-17_01.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Compiler versions: qiskit=1.3.1, cirq=1.4.1, pytket=1.37.0, ucc=0.2.0
compiler,circuit_name,raw_multiq_gates,compile_time,compiled_multiq_gates
qiskit,qaoa_barabasi_albert,1176,0.170257568359375,1176
pytket,qaoa_barabasi_albert,1176,0.024066686630249023,1176
ucc,qaoa_barabasi_albert,1176,0.662384033203125,1176
cirq,qaoa_barabasi_albert,1176,7.607674598693848,1176
qiskit,qft,10050,0.5757827758789062,3244
ucc,qft,10050,2.978692054748535,2740
pytket,qft,10050,0.2667355537414551,5890
ucc,square_heisenberg,2160,0.32622742652893066,540
qiskit,square_heisenberg,2160,0.33164215087890625,540
pytket,square_heisenberg,2160,0.12695860862731934,2160
cirq,square_heisenberg,2160,10.92936086654663,540
qiskit,prep_select,9744,1.4016923904418945,9708
ucc,prep_select,9744,6.8074164390563965,9702
ucc,qcnn,388,0.1621549129486084,388
qiskit,qcnn,388,0.08431315422058105,388
pytket,qcnn,388,0.023919105529785156,388
cirq,qft,10050,51.99950361251831,4648
pytket,prep_select,9744,0.31447267532348633,9712
cirq,qcnn,388,3.7303075790405273,388
cirq,prep_select,9744,73.60758924484253,9712
qiskit,qv,15000,5.245306968688965,14856
ucc,qv,15000,4.708544015884399,14856
pytket,qv,15000,4.425266981124878,15000
cirq,qv,15000,189.65349411964417,14856
44 changes: 12 additions & 32 deletions benchmarks/scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,45 +155,25 @@ def save_results(results_log, benchmark_name="gates", folder="../results", appen
append: Whether to append to an existing file created on the same date (if True) or overwrite (if False). Default is False.
"""
df = pd.DataFrame(results_log)
# This will store results run during the same date and hour in the same file
current_date = datetime.now().strftime("%Y-%m-%d_%H")

# Ensure the folder exists
os.makedirs(folder, exist_ok=True)

# Create the filename based on the current date
file_name = f"{benchmark_name}_{current_date}.csv"
file_path = os.path.join(folder, file_name)

header = get_header(df)

def prepend_header_if_missing(file_path, header):
"""Check if the file has a header, and prepend it if not."""
if os.path.exists(file_path):
with open(file_path, "r+") as f:
content = f.read()
if not content.startswith("# Compiler versions:"):
# Prepend the header and write back
f.seek(0)
f.write(f"{header}\n{content}")
else:
# Create a new file with the header
with open(file_path, "w") as f:
f.write(f"{header}\n")

# Ensure the header is present in the file
prepend_header_if_missing(file_path, header)

# Write results to the file
if append:
# Append results without adding column headers again
df.to_csv(file_path, mode="a", header=False, index=False)
else:
# Overwrite or create the file
df.to_csv(file_path, mode="w", header=True, index=False)
version_header = get_header(df)
# Check if the file exists
file_exists = os.path.exists(file_path)

print(f"Results saved to {file_path}")
# Open the file in the appropriate mode
with open(file_path, "a" if append else "w") as f:
# If the file is new or being overwritten, write the version header
if not file_exists or not append:
f.write(f"{version_header}\n")

# Always write the DataFrame
df.to_csv(f, header=not file_exists or not append, index=False)

print(f"Results saved to {file_path}")

# Read the QASM files passed as command-line arguments
def get_qasm_files():
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/scripts/plot_avg_benchmarks_over_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
print(file)
# Note, this will combine results from the same date
date_label = str(file).split('_')[1].split('.')[0]
df = pd.read_csv(file) # Load the CSV file into a DataFrame
df = pd.read_csv(file, header=1) # Load the CSV file into a DataFrame
df['date'] = date_label
df['reduction_factor'] = df['raw_multiq_gates'] / df['compiled_multiq_gates']
df['gate_reduction_per_s'] = df['reduction_factor'] / df['compile_time']
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/scripts/plot_latest_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
date_label = str(file).split('_')[1].split('.')[0]

# Load the CSV file into a DataFrame
df = pd.read_csv(file)
df = pd.read_csv(file, header=1)

# Add the extracted date as a new column in the dataframe
df['date'] = date_label
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
with open("VERSION.txt", "r") as f:
__version__ = f.read().strip()

with open("ucc/_version.py", "w") as f:
f.write(f"__version__ = '{__version__}'\n")
# Read the requirements from the requirements.txt file
with open("requirements.txt", "r") as req_file:
requirements = req_file.read().splitlines()
Expand Down
2 changes: 1 addition & 1 deletion ucc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .transpilers import UCCTranspiler
from .compile import compile, supported_circuit_formats

__version__ = "0.1.1"
from ucc._version import __version__
1 change: 1 addition & 0 deletions ucc/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.2.0'

0 comments on commit 47ff0ae

Please sign in to comment.