DEMSampler#

class cuquantum.stabilizer.DEMSampler(
dem: Any,
max_shots: int,
options: Options | None = None,
stream: int | Stream | None = None,
*,
package: Literal['numpy', 'cupy'] = 'cupy',
seed: int | None = None,
)[source]#

High-level sampler that takes a stim.DetectorErrorModel directly.

Parses the DEM into a binary matrix and probability array, then delegates to BitMatrixSparseSampler.

Methods

__init__(
dem: Any,
max_shots: int,
options: Options | None = None,
stream: int | Stream | None = None,
*,
package: Literal['numpy', 'cupy'] = 'cupy',
seed: int | None = None,
)[source]#
get_detector_samples(
bit_packed: bool = True,
) ndarray | ndarray[source]#

Retrieve detector outcomes from the last sample() call.

Parameters:

bit_packed – If True, return a bit-packed uint8 array; otherwise return an unpacked dense uint8 array.

get_errors(
**kwargs,
) BitMatrixCSR[source]#

Retrieve sampled errors as BitMatrixCSR from the last sample() call.

get_outcomes(
bit_packed: bool = True,
) ndarray | ndarray[source]#

Retrieve detector outcomes from the last sample() call.

Parameters:

bit_packed – If True, return a bit-packed uint8 array; otherwise return an unpacked dense uint8 array.

sample(
num_shots: int,
*,
seed: int | None = None,
stream: int | Stream | None = None,
) None[source]#

Sample; delegates to the underlying matrix sampler.