diff --git a/benchmarks/scripts/common.py b/benchmarks/scripts/common.py index 1d6f4f3..83f9858 100644 --- a/benchmarks/scripts/common.py +++ b/benchmarks/scripts/common.py @@ -12,7 +12,6 @@ SequencePass, AutoRebase, FullPeepholeOptimise, - KAKDecomposition, ) from pytket.predicates import CompilationUnit import qiskit @@ -60,8 +59,8 @@ def get_compile_function(compiler_alias): match compiler_alias: case "ucc": return ucc_compile - case "pytket": - return pytket_compile + case "pytket-peep": + return pytket_peep_compile case "qiskit": return qiskit_compile case "cirq": @@ -79,26 +78,21 @@ def get_native_rep(qasm_string, compiler_alias): if compiler_alias == "ucc": # Qiskit used for UCC to get raw gate counts native_circuit = translate(qasm_string, "qiskit") + if compiler_alias == "pytket-peep": + native_circuit = translate(qasm_string, "pytket") else: native_circuit = translate(qasm_string, compiler_alias) return native_circuit -# PyTkets compilation -def pytket_compile(pytket_circuit, method="peephole"): +# Uses FullPeepholeOptimise +def pytket_peep_compile(pytket_circuit): compilation_unit = CompilationUnit(pytket_circuit) - if method == "peephole": - passes = [FullPeepholeOptimise()] - elif method == "kak": - passes = [KAKDecomposition()] - else: - raise ValueError("Invalid compilation method for PyTKET.") - - passes.append( - AutoRebase({OpType.Rx, OpType.Ry, OpType.Rz, OpType.CX, OpType.H}) - ) - + passes = [ + FullPeepholeOptimise(), + AutoRebase({OpType.Rx, OpType.Ry, OpType.Rz, OpType.CX, OpType.H}), + ] SequencePass(passes).apply(compilation_unit) return compilation_unit.circuit @@ -289,7 +283,7 @@ def count_multi_qubit_gates(circuit, compiler_alias): return count_multi_qubit_gates_qiskit(circuit) case "cirq": return count_multi_qubit_gates_cirq(circuit) - case "pytket": + case "pytket-peep": return count_multi_qubit_gates_pytket(circuit) case _: return "Unknown compiler alias." diff --git a/benchmarks/scripts/run_benchmarks.sh b/benchmarks/scripts/run_benchmarks.sh index ca86112..3650341 100755 --- a/benchmarks/scripts/run_benchmarks.sh +++ b/benchmarks/scripts/run_benchmarks.sh @@ -23,7 +23,7 @@ QASM_FILES=( ) # Define your list of compilers -COMPILERS=("ucc" "qiskit" "pytket" "cirq") +COMPILERS=("ucc" "qiskit" "pytket-peep" "pytket-kak" "cirq") # Default parallelism 4 (can be overridden by a command line argument) PARALLELISM="${1:-4}" @@ -38,7 +38,7 @@ for qasm_file in "${QASM_FILES[@]}"; do for compiler in "${COMPILERS[@]}"; do # Combine the common folder path with the QASM file full_qasm_file="${QASM_FOLDER}${qasm_file}" - + # Build the command, passing the results folder as an argument command="python3 $(dirname "$0")/benchmark_script.py \"$full_qasm_file\" \"$compiler\" \"$RESULTS_FOLDER\"" @@ -59,7 +59,7 @@ for qasm_file in "${QASM_EXPVAL_FILES[@]}"; do for compiler in "${COMPILERS[@]}"; do # Combine the common folder path with the QASM file full_qasm_file="${QASM_FOLDER}${qasm_file}" - + # Build the command, passing the results folder as an argument command="poetry run python $(dirname "$0")/expval_benchmark.py \"$full_qasm_file\" \"$compiler\" \"$RESULTS_FOLDER\" $LOG_EXPVAL" diff --git a/benchmarks/scripts/small_test.sh b/benchmarks/scripts/small_test.sh index 6a7d88b..ae975b4 100755 --- a/benchmarks/scripts/small_test.sh +++ b/benchmarks/scripts/small_test.sh @@ -1,5 +1,5 @@ QASM_FILE="qasm2/ucc/qcnn_N100_7layers_basis_rz_rx_ry_h_cx.qasm" -COMPILER="ucc" +COMPILER="pytket-peep" SCRIPT_DIR=$(dirname "$(realpath "$0")") RESULTS_FOLDER="$SCRIPT_DIR/../results/test_data" @@ -9,4 +9,4 @@ full_qasm_file="$QASM_FOLDER/$QASM_FILE" command="python3 \"$SCRIPT_DIR/benchmark_script.py\" \"$full_qasm_file\" \"$COMPILER\" \"$RESULTS_FOLDER\"" -eval $command \ No newline at end of file +eval $command