def circuit(a, b, c): qml.RX(a, wires=0) qml.RY(b, wires=1) qml.CNOT(wires=[1, 2]) qml.RX(c, wires=2) qml.CNOT(wires=[0, 1]) qml.RZ(c, wires=2) return qml.var(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)), qml.var(qml.PauliZ(2))
def classifier_circuit(in_data, x): qml.RX(in_data, wires=[0]) qml.CNOT(wires=[0, 1]) qml.RY(-1.6, wires=[0]) qml.RY(in_data, wires=[1]) qml.CNOT(wires=[1, 0]) qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) return qml.expval.PauliZ(0)
def circuit(x, y, z): qml.RX(x, [0]) qml.CNOT([0, 1]) qml.RY(-1.6, [0]) qml.RY(y, [1]) qml.CNOT([1, 0]) qml.RX(z, [0]) qml.CNOT([0, 1]) return qml.expval.PauliZ(0)
def circuit(x, y, z): qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) qml.RY(-1.6, wires=[0]) qml.RY(y, wires=[1]) qml.CNOT(wires=[1, 0]) qml.RX(z, wires=[0]) qml.CNOT(wires=[0, 1]) return qml.expval.PauliZ(0)
def test_obs_queue(self): """Check that peaking at the obs queue works correctly""" self.logTestName() # queue some gates queue = [] queue.append(qml.RX(0.543, wires=[0], do_queue=False)) queue.append(qml.CNOT(wires=[0, 1], do_queue=False)) dev = qml.device('default.qubit', wires=2) # outside of an execution context, error will be raised with self.assertRaisesRegex( ValueError, "Cannot access the observable value queue outside of the execution context!" ): dev.obs_queue # inside of the execute method, it works with self.assertLogs(level='INFO') as l: dev.execute(queue, [qml.expval(qml.PauliX(0, do_queue=False))]) self.assertEqual(len(l.output), 1) self.assertEqual(len(l.records), 1) self.assertIn('INFO:root:[<pennylane.ops.qubit.PauliX object', l.output[0])
def circuit(x, y, z): qml.RX(x, [0]) qml.RZ(y, [0]) qml.CNOT([0, 1]) qml.RY(y, [0]) qml.RX(z, [0]) return qml.expval.PauliY(0), qml.expval.PauliZ(1)
def circuit(x, y, z): qml.RX(x, wires=[0]) qml.RZ(y, wires=[0]) qml.CNOT(wires=[0, 1]) qml.RY(y, wires=[0]) qml.RX(z, wires=[0]) return qml.expval(qml.PauliY(0)), qml.expval(qml.PauliZ(1))
def circuit(x, target_observable=None): qml.RX(x[0], wires=0) qml.RY(x[1], wires=0) qml.RZ(x[2], wires=0) qml.CNOT(wires=[0, 1]) return qml.expval(qml.Hermitian(target_observable, wires=[0, 1]))
def qf(x): qml.RX(x, [0]) qml.CNOT([0, 1]) qml.RY(0.4, [0]) qml.RZ(-0.2, [1]) return qml.expval.PauliX(0), qml.expval.PauliZ(1)
def circuit2(weights): qml.QubitStateVector(np.array([1, 0, 1, 1]) / np.sqrt(3), [0, 1]) qml.Rot(weights[0], weights[1], 0.3, 0) qml.CNOT([0, 1]) return qml.expval.PauliZ(0), qml.expval.PauliY(1)
def circuit(x, y, z): qml.QubitStateVector(np.array([1, 0, 1, 1]) / np.sqrt(3), [0, 1]) qml.Rot(x, y, z, 0) qml.CNOT([0, 1]) return qml.expval.PauliZ(0), qml.expval.PauliY(1)
def qf(x): qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) qml.RY(0.4, wires=[0]) qml.RZ(-0.2, wires=[1]) return qml.expval(qml.PauliX(0)), qml.expval(qml.PauliZ(1))
def circuit_tfe(phi, theta): qml.RX(phi[0], wires=0) qml.RY(phi[1], wires=1) qml.CNOT(wires=[0, 1]) qml.PhaseShift(theta[0], wires=0) return qml.expval(qml.PauliZ(0))
def ansatz(x, y, z): qml.QubitStateVector(np.array([1, 0, 1, 1])/np.sqrt(3), wires=[0, 1]) qml.Rot(x, y, z, wires=0) qml.CNOT(wires=[0, 1]) return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))
def qf(x): qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 2]) return qml.expval(qml.PauliZ(0))
def circuit(x, y, z): qml.RZ(z, wires=[0]) qml.RY(y, wires=[0]) qml.RX(x, wires=[0]) qml.CNOT(wires=[0, 1]) return qml.expval.PauliZ(wires=1)
def qf(x): qml.RX(x, [0]) qml.CNOT([0, 2]) return qml.expval.PauliZ(0)
def qf(x): qml.RX(x, [0]) qml.CNOT([0, 1]) return qml.expval.PauliZ(0), qml.expval.PauliZ( 1), qml.expval.PauliX(0)
def circuit1(weights, x=0.3): qml.QubitStateVector(np.array([1, 0, 1, 1]) / np.sqrt(3), wires=[0, 1]) qml.Rot(weights[0], weights[1], x, wires=0) qml.CNOT(wires=[0, 1]) return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))