def box_from_tk(tk_gate): name = tk_gate.op.type.name if name == 'Rx': return Rx(tk_gate.op.params[0] / 2) if name == 'Rz': return Rz(tk_gate.op.params[0] / 2) if name == 'CRz': return CRz(tk_gate.op.params[0] / 2) for gate in GATES: if name == gate.name: return gate raise NotImplementedError
def layer(thetas): hadamards = Id(0).tensor(*(n_qubits * [H])) rotations = Id(n_qubits).then(*( Id(i) @ CRz(thetas[i]) @ Id(n_qubits - 2 - i) for i in range(n_qubits - 1))) return hadamards >> rotations