PennyLane
Next

To attempt this challenge, please switch to a larger screen size.

Beginner
Error Correction

A Shor Thing

Challenge statement

This challenge is included in the QHack 2023 Flashback Badge Challenge event.

Quantum computational advantage — the ability of quantum computers to perform certain tasks faster than the best classical computers — has now been demonstrated in a number of cases. Arguably, the next big milestone in quantum computing is fault-tolerance for large-scale devices, allowing them to correct errors that crop up as a result of noisy interactions with the environment or between parts of the computer.

The early years of quantum error correction yielded several ground-breaking protocols, none more famous than Peter Shor's 9-qubit-code, pictured below.

In this challenge, you will implement Shor's code for an arbitrary initial state \vert \psi \rangle that is subject to an error.

Challenge code

In the code below, you are given a couple functions:

  • shor: a QNode that contains the operations required to define Shor's code given an initial state and an error occuring in the middle of the circuit. It must output the expectation value of the Pauli Z operator on each qubit. You must complete this function.
  • error: this function contains the error operator that will be introduced into the circuit you create with shor. The possible errors are Pauli X, Y, and Z errors (see error_dict in the code). To call this within shor, simply write error(error_key, qubit) and it will apply the error!

Here are some helpful resources:

  • Shor code
  • Quantum error correction

Input

As input to this problem, you are given:

  • state (list(float)): defines the initial one-qubit state \vert \psi \rangle. The remaining 8 qubits are initialized in the \vert 0 \rangle state.
  • error_key (int): an integer corresponding to a Pauli X, Y, or Z error. See error_dict.
  • qubit (int): an integer corresponding to which qubit the error will occur on.

Output

This code must output a list(float) corresponding to the expectation values of the Pauli Z operator on every qubit.

Test cases

The following public test cases are available to you. Note that there are additional hidden test cases that we use to verify that your code is valid in full generality.

test_input: [[0, 1], 0, 3] expected_output: [-1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0] test_input: [[0.5, 0.8660254038], 2, 1] expected_output: [-0.5, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0]

If your solution matches the correct one within the given tolerance specified in check (in this case it's a 1e-4 relative error tolerance), the output will be "Success!". Otherwise, you will receive an "Incorrect" prompt.

Good luck!

Good luck!

Loading...