Closed ProThicc closed 5 days ago
add_control
is an internal method with several undocumented assumptions, and not part of the public interface. It's dangerous to call on arbitrary gates, and is the problem here (well, the real real problem is data-model awkwardness between Instruction.name
and the Python object type, but there are mitigations for that in Qiskit).
Replace use of add_control
with the proper Gate.control
(so UGate(...).control(1, ctrl_state='0')
or the like), and hopefully you'll find it works better.
Indeed. The following code works:
from qiskit_aer import AerSimulator
from qiskit import transpile, QuantumCircuit
from qiskit.circuit.library import UGate
qc = QuantumCircuit(4)
qca_U = UGate(-1.945632646294958, 1.5120405041931422, 2.4393357222229826).control(num_ctrl_qubits=2, ctrl_state='00', label = 'qca_u')
qca_U_red = UGate(-1.945632646294958, 1.5120405041931422, 2.4393357222229826).control(num_ctrl_qubits=1, ctrl_state='0', label = 'qca_u_red')
qc.append(qca_U, [0,2,1])
qc.append(qca_U_red, [0,1])
sim = AerSimulator()
qcd = transpile(qc, sim, optimization_level=3, basis_gates=['barrier', 'save_statevector', 'delay','sx','cz','x','rz'])
Environment
What is happening?
I am trying to transpile a circuit with CCU and CU gates with different rotation angles. In the qiskit 11.4 version the transpiler was able to optimize and transpile the circuit with the basis gate set ['sx','cz','x','rz','barrier', 'save_statevector', 'delay'], But for the current version of qiskit, the transpiler throws an error for the particular gate set.
SympifyError: sympy2symengine: Cannot convert 'None' (of type <class 'NoneType'>) to a symengine type.
How can we reproduce the issue?
What should happen?
Any suggestions?
Noticed this when there is a CU gate in the circuit (It works well when there are CCU gates). Also for the basis gate set ['ccx','ccz','cu','cx','u','mcphase','x', 'cx', 'save_statevector','delay', 'barrier'] it transpiles properly