microsoft / QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing
MIT License
4.53k stars 1.21k forks source link

Add error-free arbitrary state transmission demo to QEC_BitFlipCode kata #859

Open CarlosLaraFP opened 1 year ago

CarlosLaraFP commented 1 year ago

The first 6 tasks in QEC_BitFlipCode.ipynb have learners implement the operations required for the single-qubit bit flip QEC code.

We can enhance the learning experience by tying together these operations into an end-to-end demo.

This demo includes the following steps:

  1. Encode an arbitrary state.
  2. Introduce a noise channel that flips a single qubit randomly.
  3. Detect random single-qubit error.
  4. Correct random single-qubit error.
  5. Verify error-free state transmission.
  6. Verify initial state was not disturbed (probability amplitudes did not change).

The demo code would be placed immediately following Task 6 (screenshot attached below).

TestBitFlipQEC

Please let me know your thoughts and whether to proceed with a PR.

@tcNickolas, @anpaz, @ricardo-espinoza, @Manvi-Agrawal

Manvi-Agrawal commented 1 year ago

@CarlosLaraM, I like the demo suggested by you. But I am not sure if we should add a demo task in the kata. Are you open to the possibility of creating a tutorial for QEC_BitFlipCode?

As a general rule of thumb , kata offers only programming exercises on a topic and some reference material (links, lecture notes, etc); while a tutorial offers the theory and demos on some topic, complimented by some exercises.

For some topics like Grover's Algorithm, Deutsch Jozsa algorithm, we initially started with a kata and then created a tutorial to make it easy for learner to follow along.

For more details, you can refer structure of kata/tutorial.

@tcNickolas thoughts?

CarlosLaraFP commented 1 year ago

@Manvi-Agrawal I love your idea of creating a tutorial for QEC_BitFlipCode, and it definitely makes sense to add the demo(s) there.

What do you think about giving the tutorial a broader name (i.e. QuantumErrorCorrection) so that we can include additional QEC codes (phase flip, Shor, Steane)?

Manvi-Agrawal commented 1 year ago

@CarlosLaraM , the idea of naming tutorial as "Quantum Error Correction" sounds good to me since it would allow us to include additional QEC codes in future

It would be helpful if you could share a short structure of the QEC tutorial before raising the PR. More specifically a highlight of different demos and exercises that would be added in PR.

@tcNickolas thoughts?

CarlosLaraFP commented 1 year ago

@Manvi-Agrawal, this is the proposed structure of the QEC tutorial:

Bit Flip Code

Sign Flip Code

Shor code

Steane code

These tasks will be accompanied by theory markup cells as needed.

My plan is to split the work over several small PRs, completing one section at a time (or perhaps 1-2 tasks at a time). Small batches will minimize the time spent in code review and deliver value to learners incrementally.

Thoughts?

Manvi-Agrawal commented 1 year ago

@CarlosLaraM , thanks for your plan. Sounds good to me. I would like to wait for @tcNickolas's thoughts on this approach.

tcNickolas commented 1 year ago

I would really like to take a look at https://github.com/microsoft/QuantumKatas/pull/418 before we start working on a new variant of QEC tutorial, and to spend some time figuring out the best way to move forward with the broader QEC tutorials. For example, we have noise simulator in the QDK that can be used to explore error correction - it would be interesting to think how we can incorporate it into these tutorials.

Returning to the question that spawned this thread, we're absolutely free to add end-to-end tasks to the katas, as well as bits of theory. For example, BB84 kata is something mid-way between a pure kata and a tutorial - the protocol is simple enough that it doesn't need extensive theory, so we added some bits of theory and E2E tasks instead of doing a separate tutorial. (For Deutsch-Jozsa algorithm, I did a tutorial after the kata because I really wanted to spend time on the classical solution and especially on the concept of oracles that is a major thing to learn.)

To summarize: I think it's a good idea to add an E2E task to the QEC_BitFlipCode kata, similar to task 2.6 in KeyDistribution_BB84: comments highlighting each step and // ... to fill each step, no automatic test but a %simulate cell to run that task in the notebook and an @Test annotation to run it in the VS/VS Code environment.

tcNickolas commented 1 year ago

@CarlosLaraFP Are you planning to make the pull request to add the E2E task following the structure of the code in your screenshot? I think it's the best next step here, let me know!