我正在尝试在Cirq / Tensorflow Quantum中实现受控旋转门。
https://cirq.readthedocs.io/en/stable/gates.html上的readthedocs.io 指出:
“可以通过使用Gate.control()将门转换为受控版本。通常,这将返回ControlledGate的实例。但是,对于某些特殊情况,其中门的受控版本也是已知门,这将返回该门的实例。例如,cirq.X.control()返回一个cirq.CNOT门。操作具有类似的功能Operation。受控_by(),例如cirq.X(q0).control_by(q1)。”
我已经实施
cirq.rx(theta_0).on(q[0]).controlled_by(q[3])
我收到以下错误:
~/.local/lib/python3.6/site-packages/cirq/google/serializable_gate_set.py in
serialize_op(self, op, msg, arg_function_language)
193 return proto_msg
194 raise ValueError(‘Cannot serialize op {!r} of type {}’.format(
—> 195 gate_op, gate_type))
196
197 def deserialize_dict(self,
ValueError: Cannot serialize op cirq.ControlledOperation(controls=(cirq.GridQubit(0, 3),), sub_operation=cirq.rx(sympy.Symbol(‘theta_0’)).on(cirq.GridQubit(0, 0)), control_values=((1,),)) of type
我将量子位和符号初始化为:
q = cirq.GridQubit.rect(1, 4)
symbol_names = x_0, x_1, x_2, x_3, theta_0, theta_1, z_2, z_3
我确实将电路与各种电路一起使用。
我的问题:如何在Cirq / Tensorflow Quantum中正确实施受控Rx?
PS我找不到Google Cirq的标签
后续行动:这如何推广到受控Ry和受控Rz的类似情况?
对于Ry,我还没有发现分解,也没有找到CRy。