-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add noisy channel: thermal relaxation #1766
Conversation
Updating my master branch
I added the first case of the ThermalRelaxationError channel, it is still needed the second case when T_2 > T_1 but at this point I need help!
Codecov Report
@@ Coverage Diff @@
## master #1766 +/- ##
=======================================
Coverage 98.98% 98.98%
=======================================
Files 218 218
Lines 16375 16428 +53
=======================================
+ Hits 16208 16261 +53
Misses 167 167
Continue to review full report at Codecov.
|
Thanks @alejomonbar for this nice contribution! 🙂 Let us know if you have any questions, or when this PR is ready for review, and someone from the team will be on hand to help. |
Thank you @josh146. Indeed, I have some questions. For the case of T2 > T1, the usual approach is to map the Choi matrix into a Kraus operator. I'm wondering if I should create that mapping function as it is made for example in Qiskit and if that's the case, where! |
Thank you for opening this PR, I'll check the different documents and come back to you asap for the case T2 > T1! |
@alejomonbar I checked the different documents about thermal relaxation. As PennyLane has no Choi representation of quantum channel, we indeed need to construct the kraus matrices from the Choi matrix given in the paper. Therefore for the case where dephasing is more prevalent than relaxation (T2>T1), you will need indeed need this transformation. For the moment you can create this function directly in Thank you again for your contribution and feel free to ask any question. Let me know when the PR will be ready for review! |
Thank you, I will look at that and come back when I implement it! |
Adding documentation of the two cases when T2 <= T1 and T2 > T1. It's left to make the test of this noisy model.
I add a test for the ThermaRelaxationError and improve the Kraus operators for T2 > T1. Now, I don't use the Choi matrix and extract the eigenvalues and eigenvectors, instead, I use the parametric representation of those eigenvalues and eigenvectors.
@antalszava I improve the code and now it gives results for both cases, T2 <= T1 and T2 > T1, the second case needs the Choi-matrix eigenvalues and eigenvectors, I put the parametric representation of those values. Let me know if you have any comments. Also, I added a test for the new ThermalRelaxation error. |
@alejomonbar Thank you, I'll give a look to the PR today and will give some advice! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution, before I can give a full review you have different points to work on:
- Codefactor: in the folder
channel.py
minor things like trailinng white spaces and too many statements should be solved easily. - You can
pip install black
and runblack -l 100 your_file.py
on all the changed files. - For docstrings and documentation, there probably some small errors of formatting.
- Some tests are failing, like
test_kraus_matrices_sum_identity
did you check it locally? Maybe there is small mistake in the Kraus operators or you need to adapt the test for the case. Same for the new tests are failing as well, do they pass locally for you?
Thank you @rmoyard , I tried it but I have a problem when trying to run the test I got the following message, |
Does it appear in the environment if you write |
Yes, it does with version |
@alejomonbar Could you give me your system information? |
No, I cannot |
I solve the problems with the tests that were causing errors.
@rmoyard Thank you. Now, all the tests pass, let me know if you have any questions about what I did |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alejomonbar You have to do multiple things to pass all the CI checks:
- Codefactor: trailing whitespaces issues
- Codefactor: unecessary else after return
- Codecov: you need to add tests for line 557/559/561, basically just test that the error messages are raised.
- Two issues with docstrings:
/github/workspace/pennylane/ops/channel.py:docstring of pennylane.ops.channel.ThermalRelaxationError:48: WARNING: Unexpected indentation. /github/workspace/pennylane/ops/channel.py:docstring of pennylane.ops.channel.ThermalRelaxationError:60: WARNING: Definition list ends without a blank line;
@rmoyard I have problems with |
Adding tests for the errors when the times t1, t2, and tg are negative.
@alejomonbar If you solve the two doc issues mentioned in my previous comment (line 48 unexpected indentation and line 60 blank line), the doc tests should pass. |
@alejomonbar Thank you for the work, I'll give a full review asap! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alejomonbar, it looks good overall. I've left some comments, let me know if you have some questions.
Co-authored-by: Romain <rmoyard@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, last comments for Code factor errors and also a dosctring. After that it should be all good 💯
Thank you @rmoyard Co-authored-by: Romain <rmoyard@gmail.com>
Add name
Before submitting
Please complete the following checklist when submitting a PR:
All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to the
test directory!
All new functions and code must be clearly commented and documented.
If you do make documentation changes, make sure that the docs build and
render correctly by running
make docs
.Ensure that the test suite passes, by running
make test
.Add a new entry to the
doc/releases/changelog-dev.md
file, summarizing thechange, and including a link back to the PR.
The PennyLane source code conforms to
PEP8 standards.
We check all of our code against Pylint.
To lint modified files, simply
pip install pylint
, and thenrun
pylint pennylane/path/to/file.py
.When all the above are checked, delete everything above the dashed
line and fill in the pull request template.
Context:
Adding a new noisy channel which gives the thermal relaxation channel as part of the #971 issue. I got the information from the supplementary of Quantum classifier with tailored quantum kernel. I still need to figure out how to get the second case when T2 > T1.
Description of the Change:
Benefits:
Possible Drawbacks:
Related GitHub Issues: