Add Rabi Oscillations textbook notebook#188
Conversation
|
Thanks for updating the branch. Please let me know if any further changes or documentation updates are needed from my side. Thanks again for reviewing the notebook. |
|
Hi @friedsam , thanks for this contribution. This is a great idea for the textbook algorithm collection; it aligns with its educational direction (see Bell inequality). We are happy to add this if you could enrich it with 2-3 more demonstrations (in the same notebook is fine) that show how the effect of noise (T1, T2) can be simulated with Braket noisy circuits, and how the dynamics of off-resonant Rabi oscillation can be encoded with single qubit rotations, and maybe all of them combined. The circuits and the graphs will be more complex and will give the reader a good learning experience without going beyond the initial scope, i.e. Rabi oscillation. Also, happy to give more guidance on what part of the Braket Python SDK may be useful for this demo. What do you think? |
|
Hi Peter, thanks a lot for the detailed feedback — that’s very helpful! |
|
Wonderful! Thanks for the quick response. For noise simulation the Simulating_Noise_On_Amazon_Braket.ipynb notebook is a great place to start. Let us know if you hit any blocker. |
|
Thank you very much for the pointer to the Simulating_Noise_On_Amazon_Braket notebook — that’s very helpful. |
9934171 to
aaa7181
Compare
|
Thanks again for the guidance. I’ve now updated the notebook to include T1 and T2 noise models, combined T1+T2 noisy dynamics, off-resonant Rabi oscillations, and an off-resonant example with T1 and T2 noise. I also reran the unit tests and rebased onto the latest upstream main. Please let me know if you’d like any further adjustments. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #188 +/- ##
===========================================
- Coverage 100.00% 98.28% -1.72%
===========================================
Files 34 36 +2
Lines 1535 1574 +39
Branches 200 208 +8
===========================================
+ Hits 1535 1547 +12
- Misses 0 27 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
T1 is not generally measured under driven evolution, so I honestly am not sure I quite follow this part. If you still want to consider it as a time evolving system, then maybe it makes sense to start in the X basis and make an X-measurement?
Reply via ReviewNB
There was a problem hiding this comment.
Reworded this section to clarify that the single damping channel is a simple circuit-level amplitude-damping demonstration, not a full time-resolved T1 experiment.
There was a problem hiding this comment.
Okay, I understand the confusion now, and that is more helpful - maybe we can change the first sentence to something like "We first model our two level system undergoing a Rabi oscillation under T1 relaxation".
There was a problem hiding this comment.
Updated the wording in the T1 introduction accordingly.
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
You definitely don't need to repeat the probability generating function everytime if you have a singular processing function.
Reply via ReviewNB
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
This is nice, and it might be cool to show what the one-time application looks like versus a discretized evolution.
Reply via ReviewNB
There was a problem hiding this comment.
Added a direct comparison plot between single-channel damping and stepwise T1 evolution to highlight the difference.
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
Might make sense to even have a matrix here that shows detuning versus the driving frequency, and how that relates to X and Z rotations.
Reply via ReviewNB
There was a problem hiding this comment.
Added a table linking detuning and drive parameters to their corresponding X and Z rotations in the circuit model.
| @@ -0,0 +1,1042 @@ | |||
| { | |||
There was a problem hiding this comment.
There was a problem hiding this comment.
Removed the tracker section to keep the notebook focused on the core physical and circuit concepts.
|
Hi @friedsam, thank you for following up! I think overall the direction and content are much more suitable now. I have made some suggestions related to consolidating code and improving certain explanations, please let me know if you have any questions. |
|
Thanks again for the detailed feedback and suggestions — they were very helpful. I updated the notebook accordingly, including the code consolidation changes, revised explanations, updated plots, and the additional comparison/discussion sections. I also reran the notebook and unit tests after the updates, and everything now executes successfully. |
| @@ -0,0 +1,902 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #4. def rabi_demo_circuit(
This is great, and I think captures basically all of the logic - let's move this function into the rabi_oscillation file; could just name it as rabi_simulated_dynamics or something similar, and then expand on the description and arguments there. I'm also not sure why you allow for arbitrary arguments? Not necessary here.
I would also add a run method, that encapsulates the probability simulations you use to run the circuit, and allows for shots or no shots.
Reply via ReviewNB
There was a problem hiding this comment.
I moved the reusable helper logic into the rabi_oscillations source module as rabi_simulated_dynamics and added an excited_state_probability helper so the notebook no longer defines these locally.
| @@ -0,0 +1,902 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #49. def probability_of_one(circ: Circuit, device: LocalSimulator) -> float:
I would rename this function - excited_state_probability is fine. As it is used extensively throughout it can be the referenced function above.
Reply via ReviewNB
| @@ -0,0 +1,902 @@ | |||
| { | |||
There was a problem hiding this comment.
So, here the time delta is constant right? 0.1? Is the right way to think of the gamma <-> angle relation as a fixed gamma subdivided into more and more chunks? So in the single channel case, there is no angle / time relation, it just is just applied to one single chunk and that's why we don't see an angle variance.
I'm not sure I quite understand what the take away is here - could you clarify it a little bit? To show that a once-only-model is wrong? This is somewhat of a discretization problem, as in a time-based picture you would implement the stepwise damping strength could either be gamma * theta, or in a stepwise picture, dt * gamma over t/dt steps.
I guess this plot is showing the discretization error of N=1, over a large range of theta, versus increasing N (by fixing theta=0.1)? Could use a little more detail regardless.
Reply via ReviewNB
There was a problem hiding this comment.
I expanded this section to better distinguish the single-channel damping example from the stepwise approximation to relaxation during the driven evolution.
| @@ -0,0 +1,902 @@ | |||
| { | |||
There was a problem hiding this comment.
Let's put a similar note here - noting that we are adding T2 dephasing to our noise model.
Reply via ReviewNB
There was a problem hiding this comment.
I updated the T2 section with analogous clarification.
| @@ -0,0 +1,902 @@ | |||
| { | |||
There was a problem hiding this comment.
There was a problem hiding this comment.
Glad the table was helpful — I thought it would make the detuning picture more explicit at the circuit level.
|
Hi @friedsam , the current state looks much better - I think that last remaining big item is to update tests to improve coverage. Let me know if there are any issues with that. Thanks! |
|
I added tests for the new helper functions |
*Issue #, if available:*Originally prepared in relation to amazon-braket-sdk-python#1194
Description of changes:
This PR adds a Rabi Oscillations example to the Amazon Braket Algorithm Library.
The contribution includes:
Rabi_Oscillations.ipynbdemonstrating:shots=0No existing core functionality was modified.
Testing done:
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.