Open
Description
When a multi-qubit X gate is created by the .controlled
method, it maybe automatically promoted to cirq.TOFFOLI
gate which isn't supported by TFQ.
Minimal example:
import tensorflow_quantum as tfq
qbs = cirq.GridQubit.rect(4, 1)
circuit = cirq.Circuit(
cirq.X.controlled(num_controls=3).on(*qbs)
)
try:
layer([circuit])
except Exception as e:
print(f"Exception:\n{e}")
# Pinrt:
# Exception:
# Cannot serialize op cirq.TOFFOLI(cirq.GridQubit(1, 0), cirq.GridQubit(2, 0), cirq.GridQubit(3, 0)) of type <class 'cirq.ops.three_qubit_gates.CCXPowGate'>
Currently, the work-around is to use cirq.ControlledGate(sub_gate=cirq.X, num_controls=3).on(*qbs)
instead.
Similar problem happen to cirq.Z
as well, which is promoted to cirq.CCZ
.
Luckily, cirq.Y
works because cirq.CCY
does not exist.
Metadata
Metadata
Assignees
Labels
No labels