-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
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,57 @@ | ||
using QuantumClifford.Experimental.NoisyCircuits | ||
|
||
function test_syndromemeas() | ||
@testset "Syndrome Measurements" begin | ||
codeˢᵗᵉᵃⁿᵉ = S"Z__Z_ZZ | ||
_Z_ZZ_Z | ||
__Z_ZZZ | ||
X__X_XX | ||
_X_XX_X | ||
__X_XXX"; | ||
function get_check(code,index) # TODO a fairly ugly piece of code that should just be part of the library | ||
s,n = size(code) | ||
@assert index<=s | ||
op = code[index] | ||
anc = n+1 | ||
circuit = AbstractOperation[] | ||
measurement = nothing | ||
resetgate = nothing | ||
for qubit in 1:n | ||
if op[qubit] == (false, true) # it is a Z | ||
if isnothing(measurement) || measurement==sMZ | ||
resetgate = Reset(S"-Z",[anc]) | ||
measurement = sMZ | ||
else | ||
error("can not do mixed syndromes") | ||
end | ||
push!(circuit, sCNOT(qubit, anc)) | ||
elseif op[qubit] == (true, false) # it is a X | ||
if isnothing(measurement) || measurement==sMX | ||
resetgate = Reset(S"-X",[anc]) | ||
measurement = sMX | ||
else | ||
error("can not do mixed syndromes") | ||
end | ||
push!(circuit, sCNOT(anc, qubit)) | ||
elseif op[qubit] == (true, true) # it is a Y | ||
error("can not do Y syndromes") | ||
end | ||
end | ||
push!(circuit,measurement(anc,index)) | ||
circuit = AbstractOperation[resetgate,circuit...] | ||
end | ||
function get_all_checks(code) | ||
s,n = size(code) | ||
vcat([get_check(code,i) for i in 1:s]...) | ||
end | ||
# test the code is correct | ||
state = Register(MixedDestabilizer(codeˢᵗᵉᵃⁿᵉ ⊗ S"Z"),zeros(Bool,6)) | ||
full_circuit = get_all_checks(codeˢᵗᵉᵃⁿᵉ) | ||
for _ in 1:100 | ||
err = random_pauli(7;realphase=true) | ||
@test mctrajectory!(apply!(copy(state),(err ⊗ P"I")),full_circuit)[1].bits == comm(err*codeˢᵗᵉᵃⁿᵉ, err) | ||
end | ||
end | ||
end | ||
|
||
test_syndromemeas() |
7c47653
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.
@JuliaRegistrator register
Release Notes:
Register
now works withtraceout!
andproject*rand!
.7c47653
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.
Registration pull request created: JuliaRegistries/General/66438
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: