Add Quantum Teleportation algorithm#186
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 30 32 +2
Lines 1220 1244 +24
Branches 156 157 +1
=========================================
+ Hits 1220 1244 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| circ = Circuit() | ||
|
|
||
| # Prepare the state to teleport on qubit 0 | ||
| if state_prep_circ is not None: |
There was a problem hiding this comment.
state_prep_circ must be a circuit for a single qubit. Please add this assumption more explicitly to the docstring, and add a validation here that throws an error if it's not a single-qubit circuit.
There was a problem hiding this comment.
Also, add a unit test about the validation.
| Dict[str, float]: Probability of Bob's qubit in {"0": P(|0>), "1": P(|1>)}. | ||
| """ | ||
| probs = task.result().result_types[0].value | ||
| probs = np.round(probs, 10) |
There was a problem hiding this comment.
why is the rounding needed?
|
|
||
| # S†H maps |+i> to |0>, so successful teleportation => P(|0>) ~= 1 | ||
| phase_sensitive_circuit = ( | ||
| Circuit().add(teleportation_circuit.instructions).si(2).h(2).probability([2]) |
There was a problem hiding this comment.
This kind of bypasses quantum_teleportation_circuit circuit by adding more gates. I understand that you add it for easier assertion in the test. Please add comment on the reason why you are doing it.
| @@ -0,0 +1,7 @@ | |||
| Quantum teleportation transfers an arbitrary quantum state from one qubit to another using a shared entangled Bell pair and classical communication. This implementation uses the deferred measurement principle, replacing mid-circuit measurements and classical feedforward with coherent CNOT and CZ corrections, so the circuit runs on any gate-based simulator. | |||
There was a problem hiding this comment.
Would be more complete to mention that the circuit generator is only implemented for a 3 qubit case. And mention your qubit layout
Qubit layout: qubit 0: message qubit (Alice's input) qubit 1: Alice's half of Bell pair qubit 2: Bob's half of Bell pair (receives teleported state)
|
@DDDIGHE Thanks again for contributing! It's a nice and elegant demo. After an internal discussion, we found it too restrictive that the algorithm only works with a particular setting of a 3-qubit circuit. Compare to other algorithms, it would be great that it is generalized. Therefore, we decided that, while this is a good PR and a good demo, this PR is qualified for the event if it is generalized:
|
Issue #, if available: amazon-braket/amazon-braket-sdk-python#1194
Description of changes:
Added Quantum Teleportation algorithm implementation and a demonstration notebook. This includes the circuit construction using Bell pairs, qubit measurement, and correction operations, with examples verifying the teleportation fidelity on a local simulator.
Testing done:
Validated on LocalSimulator. Unit tests added covering the circuit construction and result verification.
Merge Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.