pub struct MatchingDecoder { /* private fields */ }Expand description
Exact minimum-weight perfect matching decoder compiled from a graphlike detector error model.
The decoding graph is the union-find decoder’s: detectors are vertices, a
two-detector mechanism an internal edge and a one-detector mechanism a
boundary edge, each weighted ln((1-p)/p) clamped at zero, with mechanisms
sharing one detector set collapsed to the most probable. Weights are
quantized to 2^-23 of the largest edge weight, and the matching is exact
for the quantized weights: each shot’s correction has the minimum total
weight of any edge set whose boundary is the shot’s defects, the open
boundary absorbing any number of chain ends. Decoding uses no randomness,
so equal inputs give equal outputs on any thread count. The algorithm is
described in the decoding section of docs/architecture/qec-programs.md.
Implementations§
Source§impl MatchingDecoder
impl MatchingDecoder
Sourcepub fn from_model(model: &DetectorErrorModel) -> Result<Self>
pub fn from_model(model: &DetectorErrorModel) -> Result<Self>
Compile a decoder from a graphlike detector error model.
§Errors
As super::UnionFindDecoder::from_model: a mechanism flipping more
than two detectors is rejected with a pointer to
DetectorErrorModel::decompose_graphlike, and probabilities must
lie in [0, 1).
pub fn num_detectors(&self) -> usize
pub fn num_observables(&self) -> usize
Sourcepub fn decode_packed(&self, detectors: &PackedShots) -> Result<PackedShots>
pub fn decode_packed(&self, detectors: &PackedShots) -> Result<PackedShots>
Decode packed detector samples into predicted observable flips.
Layouts and bit order as super::UnionFindDecoder::decode_packed.
§Errors
The input measurement count must equal the model’s detector count, and a shot with an odd number of defects in a detector component without a boundary edge rejects the batch, naming the first such shot.
Sourcepub fn logical_error_rate(
&self,
detectors: &PackedShots,
observables: &PackedShots,
) -> Result<f64>
pub fn logical_error_rate( &self, detectors: &PackedShots, observables: &PackedShots, ) -> Result<f64>
Decode detectors and return the fraction of shots whose predicted
flips differ from observables in any observable; 0.0 for no shots.
§Errors
As Self::decode_packed, and observables must hold one bit per
observable for the same shot count.
Trait Implementations§
Source§impl Clone for MatchingDecoder
impl Clone for MatchingDecoder
Auto Trait Implementations§
impl Freeze for MatchingDecoder
impl RefUnwindSafe for MatchingDecoder
impl Send for MatchingDecoder
impl Sync for MatchingDecoder
impl Unpin for MatchingDecoder
impl UnsafeUnpin for MatchingDecoder
impl UnwindSafe for MatchingDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more