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
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:
importtensorflow_quantumastfqqbs=cirq.GridQubit.rect(4, 1)
circuit=cirq.Circuit(
cirq.X.controlled(num_controls=3).on(*qbs)
)
try:
layer([circuit])
exceptExceptionase:
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.