2

I'm looking at this MBQC tutorial where there's an example that shows that a MB and CB single qubit rotations give the same result.

CB version :

dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev)
def RZ(theta, input_state):
    # Prepare the input state
    qml.QubitStateVector(input_state, wires=0)
    # Perform the Rz rotation
    qml.RZ(theta, wires=0)
    # Return the density matrix of the output state
    return qml.density_matrix(wires=[0])

MB version :

mbqc_dev = qml.device("default.qubit", wires=2)
@qml.qnode(mbqc_dev)
def RZ_MBQC(theta, input_state):
    # Prepare the input state
    qml.QubitStateVector(input_state, wires=0)   
    # Prepare the cluster state
    qml.Hadamard(wires=1)
    qml.CZ(wires=[0, 1])
    # Measure the first qubit an correct the state
    qml.RZ(theta, wires=0)
    qml.Hadamard(wires=0)
    m = qml.measure(wires=[0])   
    qml.cond(m == 1, qml.PauliX)(wires=1)
    qml.Hadamard(wires=1)
    # Return the density matrix of the output state
    return qml.density_matrix(wires=[1])

The problem is that RZ_MBQC uses qml.RZ(theta) just like the normal (CB) version. This doesn't seem right...the whole point to me is to implement RZ without using the circuit version...am I missing something?

Martin Vesely
  • 13,891
  • 4
  • 28
  • 65
unknown
  • 2,052
  • 1
  • 7
  • 16

2 Answers2

3

What an interesting observation

I work on the PennyLane team so hopefully I can help you. While indeed, the demo does use RZ in the MBQC part, it is not a gate that mandatorily needs to be added in the circuit. Being in the measurement part, the only thing we would have to do is to adapt the base with respect to what we measure (which we can control at the hardware level). The fact that we have put it inside the circuit is because in the example we are measuring in computational base and we are making the transformation inside the circuit. I hope this clarifies your doubt :)

  • It would help if the "primitives" or "allowed operations" in MBQC are clearly defined. Ideally there would be a way to translate a CB algorithm to an MB version automatically ; the MB version would consist of MB allowed operations exclusively. – unknown Jan 30 '23 at 16:52
3

Good question - let me give it a shot. First of all, note that the application of a single-qubit gate before a measurement in the computational basis is mathematically the same as doing a projective measurement in some corresponding rotated basis. This means that we can group these series of operations, i.e. the single-qubit operations plus the measurement in the computational basis, into one - namely one measurement in some basis. The implementation in PennyLane makes use of this equivalence, but you should still see the $M_z \circ H \circ R_z(\theta)$ as one (MB allowed) operation - a measurement in a rotated basis. We can simply abstract away the experimental implementation of such a measurement - be it shooting a laser at a trapped ion, sending a microwave to a superconducting circuit, or measuring the phase of light with homodyne detection. This means that the $M_z \circ H \circ R_z(\theta)$ sequence is still MB allowed as "the ability to measure in arbitrary bases" was assumed.

Now you might wonder, why can't we do an $R_z$ measurement directly to implement an $R_z$ gate? The reason is that we want the final state to be used later. If we simply measure it, we collapse the precious quantum state. This state might already carry information from a preceding calculation, so that should be avoided. To do so, we "consume" qubits to concurrently apply unitary gates and propagate the information further down the cluster state.

I hope this helps!

Buskruid
  • 33
  • 3
  • I do see this pattern for the sequence of operations in the tutorial examples. Still, some things are not clear to me on how I would write code with only MB-allowed operations. Take a simple example of an X gate; this is not a rotation : $X=[[0,1],[1,0]]$ so $det(X)=-1$...how would this be done in MB? – unknown Feb 05 '23 at 16:29
  • 1
    Ah! Every single-qubit gate can be written as a rotation around some axis. For the $X$ gate in particular, it's useful to know about the relation $e^{i\theta A} = I \cos \theta + iA \sin \theta$ if $A^2=I$ that is discussed here. Note that the global phase is not relevant. – Buskruid Feb 06 '23 at 07:34
  • Since the global phase is not relevant for quantum states, it also means that if a matrix $A$ is a rotation, it doesn't necessarily imply that $det(A) = 1$ but rather $|det(A)| = 1$! – Buskruid Feb 06 '23 at 07:42