You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using .control(2) method on a custom Gate() produces an error.
Error output:
File "/opt/anaconda3/lib/python3.8/site-packages/qiskit/circuit/gate.py", line 119, in control
return add_control(self, num_ctrl_qubits, label, ctrl_state)
File "/opt/anaconda3/lib/python3.8/site-packages/qiskit/circuit/add_control.py", line 59, in add_control
cgate = control(operation, num_ctrl_qubits=num_ctrl_qubits, label=label, ctrl_state=ctrl_state)
File "/opt/anaconda3/lib/python3.8/site-packages/qiskit/circuit/add_control.py", line 113, in control
unrolled_gate = _unroll_gate(operation, basis_gates=basis)
File "/opt/anaconda3/lib/python3.8/site-packages/qiskit/circuit/add_control.py", line 268, in _unroll_gate
opqc = dag_to_circuit(unroller.run(dag))
File "/opt/anaconda3/lib/python3.8/site-packages/qiskit/transpiler/passes/basis/unroller.py", line 76, in run
raise QiskitError(
qiskit.exceptions.QiskitError: "Error decomposing node of instruction 'A': 'NoneType' object has no attribute 'global_phase'. Unable to define instruction 'A' in the given basis."
Steps to reproduce the problem
Code:
gateA = Gate(name='A', num_qubits=1, params=[])
ccA = gateA.control(2)
What is the expected behavior?
I expected that qiskit would allow the to-be-defined gate A to be added to the circuit, since I do not explicitly call "unroll." If I define the gate using 'ControlledGate' directly, where base_gate=gateA as init param, there's no error and I can add it to the circuit.
Suggested solutions
Waiting for developers to reply --possible this is a technical limitation of the way qiskit is implemented.
The text was updated successfully, but these errors were encountered:
There's an effort currently underway (see, e.g., #7087) which includes an aim to decouple gates-as-circuit elements from gates-as-definitions. This bug belongs to that same class of issues.
Information
What is the current behavior?
Using .control(2) method on a custom Gate() produces an error.
Error output:
Steps to reproduce the problem
Code:
What is the expected behavior?
I expected that qiskit would allow the to-be-defined gate A to be added to the circuit, since I do not explicitly call "unroll." If I define the gate using 'ControlledGate' directly, where base_gate=gateA as init param, there's no error and I can add it to the circuit.
Suggested solutions
Waiting for developers to reply --possible this is a technical limitation of the way qiskit is implemented.
The text was updated successfully, but these errors were encountered: