How does the final state of a quantum pass into the next quantum circuit as the initial state

Hi @gbc,

I’m sorry to hear that you have been confused for several days.
You can take a look at our documentation on Measurements, and more specifically on mid-circuit and conditional measurements. By using qml.measure and qml.cond you can apply certain gates depending on the output of the measurement.

Below is a code example showing three conditional measurements being applied to the circuit.

import pennylane as qml

dev = qml.device("lightning.qubit", wires=3)

@qml.qnode(dev)
def circuit(x, y):
    qml.Hadamard(0)
    m_0 = qml.measure(0)
    qml.cond(m_0, qml.RY)(x, wires=1)

    qml.Hadamard(2)
    m_1 = qml.measure(2)
    qml.cond(m_1 == 0, qml.RX)(y, wires=1)

    m_1 = qml.measure(4)
    qml.cond(m_1 == 0, qml.Hadamard)(wires=1)
    return qml.expval(qml.PauliZ(1))

qml.draw_mpl(circuit)(0.1, 0.2)

From the description of what you want to do you mentioned that you want to measure a quantum state and then plug it into a different circuit. While PennyLane allows you to measure qml.state(), this is not compatible with actual quantum hardware. You may instead use quantum teleportation, where you transfer a state from one qubit to another by using a pair of entangled qubits. You can learn more in our PennyLane demo on teleportation or in Module I.15 of the Xanadu Quantum Codebook.

I also recommend that you check our PennyLane tutorials on YouTube to learn more about the exciting world of quantum computing!