QecsimAdaptors module
TensorNetworkCodes.QecsimAdaptors
— ModuleAdaptors for using tensor-network codes within the Qecsim framework.
Code, QecsimTNCode
, and decoder, QecsimTNDecoder
, implementations are provided to be used with Qecsim error models for QEC simulations using the Qecsim App
module.
TensorNetworkCodes.QecsimAdaptors.QecsimTNCode
— TypeQecsimTNCode <: Qecsim.StabilizerCode
QecsimTNCode(code::TensorNetworkCode; distance=missing, label=nothing)
Qecsim stabilizer code implementation based on a tensor-network code.
Pauli operators such as stabilizers
and logicals
are converted to Qecsim's format on construction. These are available via Qecsim API methods of the same name. The Qecsim nkd
method returns calculated values for n
(number of physical qubits) and k
(number of logical qubits) and the given distance
for d
, if provided, otherwise missing
. The Qecsim label
method returns the given label
, if provided, otherwise the label is constructed from [n,k,d]
.
Public fields:
tn_code::TensorNetworkCode # the given tensor-network code
Examples
julia> using TensorNetworkCodes.QecsimAdaptors
julia> using Qecsim: label, nkd, validate
julia> tn_code = TensorNetworkCode(five_qubit_code());
julia> qs_code = QecsimTNCode(tn_code; distance=3);
julia> label(qs_code)
"QecsimTNCode: [5,1,3]"
julia> nkd(qs_code)
(5, 1, 3)
julia> validate(qs_code) # no error indicates success
TensorNetworkCodes.QecsimAdaptors.QecsimTNDecoder
— TypeQecsimTNDecoder <: Decoder
QecsimTNDecoder(chi::Union{Nothing,Integer}=nothing)
Qesim decoder implementation based on the TNDecode module. A null value of chi
corresponds to exact contraction, otherwise chi defines the bond dimension used in MPS/MPO contraction.
An ArgumentError
is thrown if chi is not null or positive. The Qecsim label
method returns a label constructed from chi
. The Qecsim decode
method expects the keyword argument p
for error probability, which defaults to 0.1
, and returns a DecodeResult
object with custom_values
containing the success probability. The success probability is defined as the ratio of the probability of the mostly-likely logical coset to the sum of the probabilities of all logical cosets, for example:
DecodeResult.custom_values = [[0.92]] # e.g. where 0.92 is the success probability
The success probability is added to custom_values
as a vector so that as Qecsim App.qec_run
aggregates success probabilities over many runs it extends the vector rather than simply summing over values.
Currently the TNDecode module only supports codes that can be laid out on a square lattice.
Examples
julia> using TensorNetworkCodes.QecsimAdaptors
julia> using Qecsim, Qecsim.GenericModels
julia> using Random:MersenneTwister # use RNG for reproducible example
julia> code = QecsimTNCode(rotated_surface_code(3); distance=3);
julia> error_model = DepolarizingErrorModel();
julia> decoder = QecsimTNDecoder(4);
julia> label(decoder)
"QecsimTNDecoder (chi=4)"
julia> result = qec_run_once(code, error_model, decoder, 0.1, MersenneTwister(11))
RunResult{Vector{Vector{Float64}}}(true, 1, Bool[0, 0], [[0.9249813981321253]])
julia> success_flag = result.success
true
julia> success_probability = result.custom_values[1][1]
0.9249813981321253