abdullahkhalids / qecft

The book A Methods Focused Guide to Quantum Error Correction and Fault-Tolerant Quantum Computation
Other
17 stars 6 forks source link

Implementation of color codes #14

Closed victor-onofre closed 1 year ago

victor-onofre commented 1 year ago

The first dirty version of the function only works for a code of distance 3. I will work on the following list of to-do's:

abdullahkhalids commented 1 year ago

Great work. You have a solid base on which to improve upon. The rest is mostly just adding the correct if conditions in the right places.

abdullahkhalids commented 1 year ago

This new_odd business is not elegant. Please note that if $N = 5,9,...$ then $N-1$ is divisible by 4. You should use this condition instead.

victor-onofre commented 1 year ago

The solution is so simple with the condition N-1 being divisible by 4. I don't know how I didn't see it

victor-onofre commented 1 year ago

@abdullahkhalids I think the way I have constructed the cat states for the 8 qubits stabilizers is correct. It follows the structure of your example but with the appropriate indices of the ancilla qubits

abdullahkhalids commented 1 year ago

Hey! I took a look. Registers are correctly made. There seems to be one small error. First, please note that you can look at the circuits easily by doing

_color_codes_syndrome_measurements(5).draw('text', 'colorcirc.text')

Then open colorcirc.text in a text editor with horizontal scrolling.

In lines 164 and 175, it should be face instead of i.

number = qubit_number.index(faces[face][j])

Please fix this. And we should be done.

But I will make one suggestion. In python, its not elegant to do for face in range(len(faces)):. The better way is for face, f in enumerate(faces). Then face is the list item, and f is the index of that list item. This means, instead of writing

    for face in range(len(faces)):
        if len(faces[face]) == 4:
            circ.append('H', (0, 1, 1, face, 0))
            for j in range(len(faces[i])):
                number = qubit_number.index(faces[face][j])

you write

    for face, f in enumerate(faces):
        if len(face) == 4:
            circ.append('H', (0, 1, 1, f, 0))
            for j in range(4): # you already know face is length 4
                number = qubit_number.index(face[j])
                ...

See how much easier it is to read.

abdullahkhalids commented 1 year ago

Thank you. I have accepted the pull request.