-
Notifications
You must be signed in to change notification settings - Fork 15
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
Added Superdense endcoding and decoding circuits to CircuitZoo #34
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e3330bb
Added Superdense endcoding and decoding circuits to CircuitZoo
ba2tro 576b241
fix issues
ba2tro e8062b4
Add test
ba2tro 5d2a940
Merge branch 'QuantumSavory:master' into sdcircuit
ba2tro 2605189
Merge remote-tracking branch 'Abhishek-1Bhatt/sdcircuit' into sdcircuit
ba2tro a5d1907
Add test file to runtests
ba2tro bceecfa
fix error and remove `Ket` from project_traceout! just for this pr
ba2tro f90a1ac
Merge branch 'master' into sdcircuit
ba2tro 1d8771d
cleanup
ba2tro de16311
Update test_circuitzoo_superdense.jl
ba2tro 167cad6
Update CircuitZoo.jl
ba2tro 0221409
Update runtests.jl
ba2tro 5e514cd
quantumopticsbase compat bound
Krastanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using QuantumSavory | ||
using QuantumSavory.CircuitZoo: SDEncode, SDDecode | ||
using Test | ||
|
||
## Set up an entangled bell pair | ||
ra = Register(1) | ||
rb = Register(1) | ||
|
||
initialize!(ra[1], Z1) | ||
initialize!(rb[1], Z1) | ||
|
||
apply!(ra[1], H) | ||
apply!((ra[1], rb[1]), CNOT) | ||
|
||
# Random 2 bit classical message | ||
message = Tuple(rand(0:1, 2)) | ||
|
||
# Use the circuits to encode and decode the message | ||
SDEncode()(ra, message) | ||
rec = SDDecode()(ra, rb) | ||
|
||
@test message == rec |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Everything works fine upto this line, but when we apply H to Bob's qubit, the result is the same as what we would get if we applied H to Alice's qubit on paper, i.e., something like
which gives us the random results.
But if we apply H to
regA[1]
, which is Alice's qubit here, it returns the correct results. I am not sure why it behaves this way, opposite to what we get when we solve it on paper, but it resolves the issue hereThere 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.
Could you elaborate a bit? What is the state before the wrong step, what is the step that seems to break things, and what is the state after that step (and what should it be)?
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.
For the final part of the decoder circuit, we want to apply H to the second qubit (Bob's qubit), and H is a 1 qubit operator. But under the hood our register stores a 4 element ket vector which (if the classical message is
1 1
) would be:To apply the symbolic H to the second qubit, we call the
apply!
method atQuantumSavory.jl/src/baseops/apply.jl
Line 12 in 09fe3aa
Here(
QuantumSavory.jl/src/baseops/apply.jl
Line 21 in 09fe3aa
state_indices
parameter of our ket determines whether the final operator would beI⊗H
(correct) orH⊗I
(wrong) given state_indices is 1 or 2 respectively. Since, Bob's qubit is the 2nd qubit of the subsystemstate_indices
is set to 2 and it finally hits theapply!
methods in QuantumOpticsBase.jl. So, because ofstate_indices
being 2, the final operator here (in QuantumOpticsBase.jl) becomesH⊗I
which gives us the wrong answer in my previous comment.So, [sorry for the huge description : ) ] to be short, the
embed
method here expects to be provided with the index where we want to put the identity operator(index 1) instead of the index of the qubit on which we're performing the single qubit operation(index 2), as described by its docstring hereHence, I think we have a bug in this line
QuantumSavory.jl/src/baseops/apply.jl
Line 21 in 09fe3aa
and
state_indices
should be a vector of all the indices of the state excluding the index of our qubit, so that embed could put identity for all those indices