Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
nzy committed Mar 12, 2024
1 parent 9c0e638 commit de65d30
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/inferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ function syndrome_inference(cl::CliffordNetwork{T}, syn::Dict{Int,Bool}, p::Vect
end
tn = generate_tensor_network(cl, ps, qs)
mp = marginals(tn)
return result = Dict([k => mp[[cl.mapped_qubits[k]]] for k in 1:n])
return Dict([k => mp[[cl.mapped_qubits[k]]] for k in 1:n])
end
34 changes: 33 additions & 1 deletion test/errorcorrect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,41 @@ end

ps_ec_phy = TensorQEC.pauli_string_map_iter(correction_pauli_string(qubit_num, syn_dict, pinf), qc)
@show ps_ec_phy
apply!(reg, Yao.YaoBlocks.Optimise.to_basictypes(ps_ec_phy))
apply!(reg, ps_ec_phy)

@test measure_syndrome!(reg, st) == [1,1,1,1,1,1,1,1]
apply!(reg, qc')
@test fidelity(density_matrix(reg, [9]),density_matrix(regcopy, [9])) 1.0
end


@testset "syndrome inference and error correct for [[7,1,3]]" begin
qubit_num = 7
pauli_string = PauliString{qubit_num}[]
push!(pauli_string, TensorQEC.paulistring(qubit_num, 2, (1,3,5,7)))
push!(pauli_string, TensorQEC.paulistring(qubit_num, 2, (2,3,6,7)))
push!(pauli_string, TensorQEC.paulistring(qubit_num, 2, (3,4,5,6,)))
push!(pauli_string, TensorQEC.paulistring(qubit_num, 4, (1,3,5,7)))
push!(pauli_string, TensorQEC.paulistring(qubit_num, 4, (2,3,6,7)))
push!(pauli_string, TensorQEC.paulistring(qubit_num, 4, (3,4,5,6,)))
qc, data_qubits, code = TensorQEC.encode_stabilizers(pauli_string)
reg = join(zero_state(6),rand_state(1))
regcopy = copy(reg)
apply!(reg, qc)
apply!(reg, put(qubit_num, 4=>X))

measure_outcome=measure_syndrome!(reg, pauli_string)
syn_dict=TensorQEC.generate_syndrome_dict(code,syndrome_transform(code, measure_outcome))

cl = clifford_network(qc)
p = fill([0.85,0.05,0.05,0.05],qubit_num)
pinf = syndrome_inference(cl, syn_dict, p)

ps_ec_phy = TensorQEC.pauli_string_map_iter(correction_pauli_string(qubit_num, syn_dict, pinf), qc)
@show ps_ec_phy
apply!(reg, ps_ec_phy)

@test measure_syndrome!(reg, pauli_string) == [1,1,1,1,1,1]
apply!(reg, qc')
@test fidelity(density_matrix(reg, [qubit_num]),density_matrix(regcopy, [qubit_num])) 1.0
end

0 comments on commit de65d30

Please sign in to comment.