-
Notifications
You must be signed in to change notification settings - Fork 50
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
Update Noisy Circuits Documentation and Simulation #456
Draft
IsaacP1234
wants to merge
7
commits into
QuantumSavory:master
Choose a base branch
from
IsaacP1234:noisy_update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed20e6a
new apply_branches and docs
IsaacP1234 f8f0258
fix applybranches, fix keep
IsaacP1234 6212a21
removed uneeded operator determinism
IsaacP1234 9c9550a
removing applybranches code repetition
IsaacP1234 34b7588
flow chart code
IsaacP1234 7f9dcff
tests for new applybranches method
IsaacP1234 709baed
spelling
IsaacP1234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,29 @@ | |
[(applywstatus!(copy(state),op)...,1,0)] | ||
end | ||
|
||
function applybranches(::NondeterministicOperatorTrait, state, op::T; max_order=1) where {T<:Union{sMZ,sMX,sMY}} | ||
s = copy(state) | ||
|
||
if T===sMZ | ||
d, anticom, res = projectZ!(s, op.qubit) | ||
elseif T===sMX | ||
d, anticom, res = projectX!(s, op.qubit) | ||
elseif T===sMY | ||
d, anticom, res = projectY!(s, op.qubit) | ||
else | ||
error("not reachable") | ||
end | ||
|
||
if isnothing(res) | ||
tab(stabilizerview(s)).phases[anticom] = 0x0 | ||
s1 = copy(s) | ||
tab(stabilizerview(s)).phases[anticom] = 0x2 | ||
s2 = s | ||
return [(s1, continue_stat, .5, 0), (s2, continue_stat, .5, 0)] | ||
else | ||
return [(s, continue_stat, 1, 0)] end | ||
end | ||
|
||
function applybranches(::NondeterministicOperatorTrait, state, op; max_order=1) | ||
throw(ArgumentError(lazy""" | ||
You are trying to apply a non-deterministic operator $(typeof(op)) in a perturbative expansion, but this particular operator does not have a `applybranches` method defined for it. | ||
|
@@ -45,9 +68,12 @@ | |
|
||
function petrajectory_keep(state, circuit; branch_weight=1.0, current_order=0, max_order=1) # TODO a lot of repetition with petrajectory - dry out | ||
A = Accumulator{Tuple{typeof(state),CircuitStatus},typeof(branch_weight)} | ||
dict = A() | ||
if size(circuit)[1] == 0 | ||
return A() | ||
DataStructures.inc!(dict, (state,continue_stat), branch_weight) | ||
return dict | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this new behavior also need a test (potentially the same test as the one for the new functionality above) |
||
end | ||
|
||
next_op = circuit[1] | ||
rest_of_circuit = circuit[2:end] | ||
|
||
|
@@ -67,7 +93,8 @@ | |
end | ||
|
||
"""Run a perturbative expansion to a given order. This is the main public function for the perturbative expansion approach. | ||
|
||
Currently only has defined behavior for Clifford operators(AbstractCliffordOperator) and single-qubit X, Y and Z measurements(sMX, sMY, sMZ) | ||
If using the measurements, set keepstates to true. When keepstates is false, will return 0 for true success probability. | ||
See also: [`pftrajectories`](@ref), [`mctrajectories`](@ref)""" | ||
function petrajectories(initialstate, circuit; branch_weight=1.0, max_order=1, keepstates::Bool=false) | ||
if keepstates | ||
|
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
Oops, something went wrong.
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.
there is a lot of code repetition in
applybranches
forsMY
andsMX
andsMZ
. There is a private function calledproject_cond!
(you can see it being used inprojectX! projectY! projectZ!
) that should let you remove a ton of the code repetition.Or even more simply, you can do something like
op::T, ...) where {T<:Union{sMZ,sMX,sMY}}
in the type signature and then do