Skip to content

Confidence

Confidence decoder wrappers used by MSD/QET table decoders.

ConfidenceDecoder

Bases: ABC


              flowchart TD
              bloqade.gemini.decoding.confidence.ConfidenceDecoder[ConfidenceDecoder]

              

              click bloqade.gemini.decoding.confidence.ConfidenceDecoder href "" "bloqade.gemini.decoding.confidence.ConfidenceDecoder"
            

Decoder interface for a correction plus a scalar confidence score.

decode_with_confidence abstractmethod

decode_with_confidence(
    detector_bits: NDArray[bool_],
) -> tuple[npt.NDArray[np.bool_], np.float64]

Decode one detector syndrome and return a confidence score.

Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/decoding/confidence.py
84
85
86
87
88
89
@abstractmethod
def decode_with_confidence(
    self,
    detector_bits: npt.NDArray[np.bool_],
) -> tuple[npt.NDArray[np.bool_], np.float64]:
    """Decode one detector syndrome and return a confidence score."""

GurobiDecoderWithConfidence

GurobiDecoderWithConfidence(*args: Any, **kwargs: Any)

Bases: GurobiDecoder, ConfidenceDecoder


              flowchart TD
              bloqade.gemini.decoding.confidence.GurobiDecoderWithConfidence[GurobiDecoderWithConfidence]
              bloqade.gemini.decoding.confidence.GurobiDecoder[GurobiDecoder]
              bloqade.gemini.decoding.confidence.ConfidenceDecoder[ConfidenceDecoder]

                              bloqade.gemini.decoding.confidence.GurobiDecoder --> bloqade.gemini.decoding.confidence.GurobiDecoderWithConfidence
                
                bloqade.gemini.decoding.confidence.ConfidenceDecoder --> bloqade.gemini.decoding.confidence.GurobiDecoderWithConfidence
                


              click bloqade.gemini.decoding.confidence.GurobiDecoderWithConfidence href "" "bloqade.gemini.decoding.confidence.GurobiDecoderWithConfidence"
              click bloqade.gemini.decoding.confidence.GurobiDecoder href "" "bloqade.gemini.decoding.confidence.GurobiDecoder"
              click bloqade.gemini.decoding.confidence.ConfidenceDecoder href "" "bloqade.gemini.decoding.confidence.ConfidenceDecoder"
            

Gurobi MLE decoder with logical-gap confidence.

Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/decoding/confidence.py
32
33
def __init__(self, *args: Any, **kwargs: Any) -> None:
    raise ImportError(_GUROBI_MISSING_MSG)

decode

decode(
    detector_bits: NDArray[bool_],
    verbose: bool = False,
    return_weights: bool = False,
) -> (
    npt.NDArray[np.bool_]
    | tuple[npt.NDArray[np.bool_], np.ndarray]
)

Decode detector bits after validating the detector-shot width.

Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/decoding/confidence.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def decode(
    self,
    detector_bits: npt.NDArray[np.bool_],
    verbose: bool = False,
    return_weights: bool = False,
) -> npt.NDArray[np.bool_] | tuple[npt.NDArray[np.bool_], np.ndarray]:
    """Decode detector bits after validating the detector-shot width."""

    validated_bits = _validate_detector_bits(
        detector_bits,
        self.num_detectors,
        allow_batch=True,
        method_name="decode",
    )
    return super().decode(
        validated_bits,
        verbose=verbose,
        return_weights=return_weights,
    )

decode_with_confidence

decode_with_confidence(
    detector_bits: NDArray[bool_],
) -> tuple[npt.NDArray[np.bool_], np.float64]

Decode a single shot and return the logical-gap confidence.

Source code in .venv/lib/python3.12/site-packages/bloqade/gemini/decoding/confidence.py
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
def decode_with_confidence(
    self,
    detector_bits: npt.NDArray[np.bool_],
) -> tuple[npt.NDArray[np.bool_], np.float64]:
    """Decode a single shot and return the logical-gap confidence."""

    validated_bits = _validate_detector_bits(
        detector_bits,
        self.num_detectors,
        allow_batch=False,
        method_name="decode_with_confidence",
    )
    decoded_obs, logical_gap = self._decode_with_logical_gap(validated_bits)
    logical_gap_arr = np.asarray(logical_gap, dtype=np.float64).reshape(-1)
    return decoded_obs.astype(np.bool_), np.float64(logical_gap_arr[0])