-
Notifications
You must be signed in to change notification settings - Fork 0
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
Cirq compiles to unexpected gateset #201
Comments
# benchmarks/scripts/test_gateset.py
from common import cirq_compile, qiskit_compile, get_native_rep
qasm_path = "../qasm_circuits/qasm2/benchpress/qaoa_barabasi_albert_N10_3reps_basis_rz_rx_ry_cx.qasm"
with open(qasm_path) as f:
qasm_str = f.read()
cirq_rep = get_native_rep(qasm_str, "cirq")
qiskit_rep = get_native_rep(qasm_str, "qiskit")
# CIRQ
print("cirq pre-compiled", set(type(op.gate).__name__ for op in cirq_rep.all_operations()))
print("cirq post-compiled", set(type(op.gate).__name__ for op in cirq_compile(cirq_rep).all_operations()))
# QISKIT
print("qiskit pre-compiled", set(qiskit_rep.count_ops().keys()))
print("qiskit post-compiled", set(qiskit_compile(qiskit_rep).count_ops().keys()))
This looks nontrivial from the |
So I tried just eliminating the ![]() I manually triggered a re-run of the benchmarking workflow here, so we will see what it does to the results: https://github.com/unitaryfund/ucc/actions/runs/13016680357 |
Okay that definitely isn't the right move, because if you take away the target gateset, cirq appears to just not do anything to the circuits: 376f647#diff-b2990d4889b9c2640e4b91506d546a9b721e63dbc2b50dc1a4565c19302f1170 |
Reverted to use the CZ target gateset in the dev branch |
Following the discussion above, I agree with @natestemen that
Digging a bit deeper, Looking across the
It looks like IonQ is the closest to the If we want an apples to apples gateset comparison, I think we'd need to implement this ourselves, and could start from the IonQTargets as examples. This will of course add performance implications since we aren't using a cirq provided implementation, but its a start. I'll start looking into those steps. |
Status update -- I tested with |
Describe the bug
We compile all circuits with several other quantum compilers to benchmark UCC. To make the logging more straightfoward, we defined multiple compile helper functions to wrap the complexity into a unified interface [links to compile functions for Qiskit, Cirq, PyTKET)
Although by default, all the compile functions used in our UCC benchmarks should target the same gateset for proper comparison, @natestemen has observed the cirq_compile function compiling to a different gateset -- including the PhasedXZ and CZPow gates.
To Reproduce
Steps to reproduce the behavior:
@natestemen please add your repro script/snippet in this issue
Expected behavior
The
cirq_compile
d circuit should return {Cirq.rx, Cirq.rx, Cirq.rz, Cirq.cx,, OpType.H}),Additional context
My guess is that the target gateset selected here is incorrect,
ucc/benchmarks/scripts/common.py
Lines 104 to 105 in d6abe58
and we may need to
gateset
accepted bycirq.optimize_for_target_gateset
.The text was updated successfully, but these errors were encountered: