BitMatrixSparseSampler#

class cuquantum.stabilizer.BitMatrixSparseSampler(
matrix: Array | BitMatrixCSR | SparseCSR,
probs: Array,
max_shots: int,
*,
num_outcomes: int | None = None,
bit_packed: bool = False,
package: Literal['numpy', 'cupy'] = 'numpy',
seed: int | None = None,
options: Options | None = None,
stream: Stream = None,
)[source]#

Sparse Bernoulli sampler with GF(2) matrix multiply.

Samples independent Bernoulli errors into a sparse intermediate representation, then multiplies by a binary outcome matrix to produce detector outcomes.

Best when error probabilities are low and n_errors is large.

Methods

__init__(
matrix: Array | BitMatrixCSR | SparseCSR,
probs: Array,
max_shots: int,
*,
num_outcomes: int | None = None,
bit_packed: bool = False,
package: Literal['numpy', 'cupy'] = 'numpy',
seed: int | None = None,
options: Options | None = None,
stream: Stream = None,
)[source]#
get_errors() BitMatrixCSR[source]#

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

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

Retrieve outcomes from the last sample() call.

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

Sample errors and outcomes.

Results are stored internally; retrieve via get_outcomes() and get_errors().

Attributes

n_errors#
n_outcomes#
operands_package#