Information correction in Repetition Codes tutorial --> definition of measure_syndrome_bit function
URL to the relevant tutorial
Hi, the issue is related to the Repetition Codes Tutorial https://quantum.cloud.ibm.com/docs/en/tutorials/repetition-codes#tutorial-survey --> description of the measure_syndrome_bit function.
Select all that apply
- [ ] new content request
- [x] typo
- [ ] code bug
- [ ] out-of-date content
- [ ] broken link
- [ ] other
Describe the fix or the content request.
I think there's an error in the description of the measure_syndrome_bit function. In particular, the incriminated statement is
We reset our ancilla qubits after measuring the stabilizer so we can reuse them for repeated stabilizer measurements.
Given the previous initialization
qreg_data = QuantumRegister(3)
qreg_measure = QuantumRegister(2)
creg_data = ClassicalRegister(3, name="data")
creg_syndrome = ClassicalRegister(2, name="syndrome")
state_data = qreg_data[0]
ancillas_data = qreg_data[1:]
the description drives the reader to believe that the qubits to reset are qreg_data[1] and qreg_data[2]. This is incorrect, as the qubits to reset are the ones in qreg_measure. This is consistent with what the function actually does, since it involves
with circuit.if_test((creg_measure[0], 1)):
circuit.x(qreg_measure[0])
with circuit.if_test((creg_measure[1], 1)):
circuit.x(qreg_measure[1])
I therefore suggest to change "We reset our ancilla qubits..." with "We reset our measurement qubits".
I also suggest to rename creg_measure as creg_syndrome within the definition of the function to uniform it with the rest of the code.
P.s.: this is the first time I open an issue, I hope I did everything correctly :)
For new content requests - if the request is accepted, do you want to write the content?
I only want to review the material when it's finished
Thanks for raising this issue. I agree that this is confusing. The word ancilla is used to refer to more than one set of qubits. And those sets of qubits are also referred to by other names:
The code requires five qubits: three are used to encode the protected state, and the remaining two are used as stabilizer measurement ancillas.
qreg_data = QuantumRegister(3)
qreg_measure = QuantumRegister(2)
...
ancillas_data = qreg_data[1:]
The text clearly identifies qreg_measure as ancillas. And also, two of the qubits in qreg_data are associated with the word ancilla.
Your suggestion
"We reset our ancilla qubits..." with "We reset our measurement qubits".
would be an improvement. But I think rethinking the language used for these registers in the entire document would be even better--- elsewhere, the author does refer to the reset qubits as ancilla qubits.
I support your second point, naming the parameters in a function the same as the arguments in a call to the function. This should be done in all other functions, as well. If a function is called in different contexts in which a parameter has different meanings, then it's a good idea to choose appropriate names, which may be different from the arguments in the call. But that's not the case here. Furthermore, this is pedagogical, so there should be an extra emphasis on clarity.
@miamico @nathanearnestnoble, I volunteer to do this. I am unable to assign in this repository.
Thanks @jlapeyre ! I've assigned the issue to you. Please link a PR whenever ready for review
The renaming suggested in this issue is a good idea. But really, the names of variables and references to them is ambiguous. You could argue that the current name is better. I suggest choosing new names where appropriate in this first section of code. I started doing this, as well as adding one-line descriptive comments above some of them.
I already have done most of the suggestion above, it is in python script with comments that I will copy back into the notebook.
There are a few other small changes that fit naturally with the change proposed above.
Omit the discussion of stabilizers, which is more advanced than this tutorial. For example, the paper linked in the tutorial does not mention stabilizers until after a thorough discussion of background topics as well as the 3-qubit bit-flip code and the 9-qubit code. The same is true in Gottesman's recent book
If we were to keep this paragraph on stabilizers, some of the language would need to be cleaned up. For example: "discrete error set with support from the Pauli group". Using "support" here is not quite accurate, and "support from" is nonstandard.
A minor change: move cell 2 to just below cell 1. They are both for setup. Cell 2 is out of place after the introduction of the theory. You'd have to say. "In the following we will need 5 qubits". I think the need to know how many qubits is why it's in its current position.
I see a couple of other potential issues that should probably be opened in another issue:
I re-ran some of the code cells using the simulator with a noise model. I find something sort of similar to the results in the notebook. But I don't find clear evidence that the bit flip correction is helping much. We give at least a brief statement after the comparisons explaining the results or giving a good attempt.
Here is a draft of the renaming (and reorganizing a big) suggested above. It's not reviewable yet. So you don't need to look at it. But it's close to what I would propose.
Hi @jlapeyre, do you have any news? Would you like me to take a look at your proposed code and eventually fix issues to help?