Qiskit / qiskit-metapackage

Qiskit is an open-source SDK for working with quantum computers at the level of circuits, algorithms, and application modules.
https://qiskit.org
Apache License 2.0
3.03k stars 749 forks source link

Clearing up a RepetitionCode Tutorial Example #1025

Closed Phionx closed 1 year ago

Phionx commented 4 years ago

Did you find a doc bug or broken link that needs to be fixed?

Yes

https://qiskit.org/textbook/ch-quantum-hardware/error-correction-repetition-code.html

Example 3: 0 1 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 1. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

The following are the only two self-consistent options that correspond to a single code qubit being flipped on the end of the line before the second round of syndrome measurements.

Option 1

Example 3: 1 0 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 1. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

Option 2

Example 3: 0 1 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 0. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

Although subtle, this typo was confusing enough to derail me on a tangential exploration. After a bit of testing, using the code shown below:

from qiskit.ignis.verification.topological_codes import RepetitionCode
code = RepetitionCode(5,2)

raw_results = {'1':{'11110 0001 0000':3}}

results = code.process_results( raw_results )
print("Option 1:" + str(results))

raw_results = {'0':{'00001 0001 0000':3}}

results = code.process_results( raw_results )
print("Option 2:" + str(results))

which has the following output:

Option 1:{'1': {'1 0  0000 0001 0000': 3}}
Option 2:{'0': {'0 1  0000 0001 0000': 3}}.

I see that Option 1 and 2 are the only syndrome measurement results that might correspond to a single code qubit flip at the end of the line before the second round of syndrome measurements.

Add another Example

The convention of listing the first round of syndrome measurement results on the rightmost side of the strings found in raw_results also confused me. An added example clarifying this ordering convention would be very useful:

Example 4: 0 1 0001 0001 1000 represents a 𝑑=5 , 𝑇=2 repetition code with an encoded 1. As in example 2, perhaps an initial measurement error leads to the first 1, as subsequent rounds do not detect anything. The third 1, however, represents the flip of a code qubit at the left end of the line. This error sequence may give rise to the following syndrome measurement string: 01111 0000 0001, where we see that syndrome measurements are written from newest to oldest ( 𝑇_3 𝑇_2 𝑇_1), counter to the ordering of the above code qubit error sequence. Again, we are able to extract an extra ( 𝑇_3) syndrome measurement from the final readout measurement of all code qubits.

Since these examples were essential in demonstrating the functionality of the RepetitionCode package, I think this issues warrant a correction to the otherwise wonderful tutorial!

No.

Does existing documentation need to be updated with new content?

Example 3: 0 1 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 1. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

Option 1

Example 3: 1 0 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 1. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

Option 2

Example 3: 0 1 0000 0001 0000 represents a 𝑑=5 , 𝑇=2 repetition code with encoded 0. A code qubit on the end of the line is flipped before the second round of syndrome measurements. This is detected by only a single syndrome measurement, because it is on the end of the line. For the same reason, it also disturbs one of the logical readouts.

Add another Example

The convention of listing the first round of syndrome measurement results on the rightmost side of the strings found in raw_results also confused me. An added example clarifying this ordering convention would be very useful:

Example 4: 0 1 0001 0001 1000 represents a 𝑑=5 , 𝑇=2 repetition code with an encoded 1. As in example 2, perhaps an initial measurement error leads to the first 1, as subsequent rounds do not detect anything. The third 1, however, represents the flip of a code qubit at the left end of the line. This error sequence may give rise to the following syndrome measurement string: 01111 0000 0001, where we see that syndrome measurements are written from newest to oldest ( 𝑇_3 𝑇_2 𝑇_1), counter to the ordering of the above code qubit error sequence. Again, we are able to extract an extra ( 𝑇_3) syndrome measurement from the final readout measurement of all code qubits.

Phionx commented 4 years ago

@quantumjim I think this documentation issue may interest you.

jakelishman commented 1 year ago

Looking at the linked page, I believe this has been updated to match the provided Option 2 since this issue was opened. I'll close this as "completed" now, but please feel free to reopen on https://github.com/Qiskit/platypus if there's more.