In her lab, Alice can initialize her two auxiliary qubits (on wires 1 and 2) to , and she hopes to create a logical qubit that would help protect the message of her first qubit (wire 0). In other words, if her message is , she wants to encode the message into the state .

Once the qubits pass through the noisy communication channel and Bob receives them, he will have to decode the message, so that the first qubit (wire 0) again takes on the value Alice tried sending, . In this case, we are assuming that either none of the qubits experienced a bit-flip error, or a maximum of one of them did.

In this exercise, you are asked to code the quantum circuit Alice needs to use to encode the qubit into a logical qubit and then. After the bit flip errors, you must also write down the procedure Bob uses to decode Alice's message.

Hint

Look at the theory part! Remember that you can use the qml.CNOT and qml.Toffoli gates to build the encoding and decoding circuits. If you get stuck, use a simple example to help you go through the circuit!

dev = qml.device("default.mixed", wires=3)

@qml.qnode(dev)
def bitflip_code_expval(p):
"""A circuit that uses two auxiliary qubits to encode the message of the first qubit, puts them through a simple noisy channel with a chance of a bit-flip error occuring, then decodes it and measures the expectation value of the original message.
Args:
p (float): Probability of one bit-flip error occuring in the noisy channel for each wire.

Returns:
(float): Expectation value of the message qubit.
"""
# Using two auxiliary qubits on wires 1 and 2, encode the message on wire 0 into a logical qubit
##################
# YOUR CODE HERE #
##################
# Put all wires through a noisy channel, where each wire has a probability p that a bit-flip error will occur
qml.BitFlip(p, wires=0)
qml.BitFlip(p, wires=1)
qml.BitFlip(p, wires=2)
# Decode the message after the noisy channel
##################
# YOUR CODE HERE #
##################
# Measure the expectation value of the message
return qml.expval(qml.PauliZ([0]))

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Understand the effects of different types of qubit errors.
  • Know how to perform simple quantum error correction to mitigate for bit- and phase-flip errors.