Documentation Index
Fetch the complete documentation index at: https://tsim.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
class Channel
i corresponds
to 1 \<\< i in probs. For example, in a 2-bit channel, index 1
(0b01) is bit pattern bit0=1, bit1=0 and index 2 (0b10) is
bit0=0, bit1=1.
class ChannelSampler
f_i = error_transform_ij * e_j mod 2. Within each channel,
probability-array bit 0 corresponds to the first produced error bit, bit 1
to the second, and so on.
Channels are automatically simplified by:
- Removing bits e_i that do not affect any f-variable (i.e. all-zero columns in error_transform)
- Folding duplicate column IDs, i.e. channels whose column signatures contain duplicate IDs.
- Merging channels with identical column signatures, i.e. channels whose corresponding columns in error_transform are identical.
- Absorbing channels whose signatures are subsets of others, i.e. channels whose corresponding columns in error_transform are a strict subset of another channel’s columns.
sample
num_samples(int) — Number of samples to draw.
np.ndarray— NumPy array of shape (num_samples, num_f) with uint8 values indicatingnp.ndarray— which f-variables are set for each sample.
absorb_subset_channels
channels(list[Channel]) — List of channelsmax_bits(int) — Maximum number of bits allowed per channel
list[Channel]— List with no channel being a strict subset of another
correlated_error_probs
probs[0]is the probability that no branch fires.probs[1 \<\< i]is the probability that branchifires after all previous branches did not fire.
probabilities(list[float]) — List of conditional probabilities [p1, p2, …, pk]
np.ndarray— Array of shape (2^k,) with probabilities for each outcome.
error_probs
[P(bit0=0), P(bit0=1)].
expand_channel
target_col_ids when considered as sets, and both tuples must be sorted.
New target bit positions are treated as always zero.
Duplicate source column IDs are allowed. When multiple source bits map to
the same target bit, their contribution is XORed, matching GF(2)
composition. Duplicate target column IDs are not allowed; channels with
duplicate IDs should be canonicalized before subset absorption.
Parameters:
channel(Channel) — Channel to expand (must have sorted unique_col_ids)target_col_ids(tuple[int, ...]) — Target signature set (must be sorted superset)
Channel— New channel with expanded distribution
fold_duplicate_channel_bits
channels(list[Channel]) — List of channels with sorted unique_col_ids
list[Channel]— List of channels whose unique_col_ids contain no duplicates
heralded_pauli_channel_1_probs
- bit 0: herald bit, written to the measurement record
- bit 1: Z error component
- bit 2: X error component
- index 0 (0b000): no herald, no Pauli error
- index 1 (0b001): herald + I
- index 3 (0b011): herald + Z
- index 5 (0b101): herald + X
- index 7 (0b111): herald + Y, represented as X+Z
merge_identical_channels
channels(list[Channel]) — List of channels
list[Channel]— List with at most one channel per unique signature set
normalize_channels
unique_col_ids tuples, enabling merge_identical_channels to group
them. The probability tensor is transposed using the same axis permutation
so little-endian outcome bits continue to refer to the matching column IDs.
Parameters:
channels(list[Channel]) — List of channels
list[Channel]— List of channels with sorted unique_col_ids
pauli_channel_1_probs
- bit 0: Z error component
- bit 1: X error component
- index 0 (0b00): I
- index 1 (0b01): Z
- index 2 (0b10): X
- index 3 (0b11): Y
pauli_channel_2_probs
- bit 0: Z error component on
qubit_i - bit 1: X error component on
qubit_i - bit 2: Z error component on
qubit_j - bit 3: X error component on
qubit_j
z_i + 2*x_i + 4*z_j + 8*x_j stores the
probability for the corresponding two-qubit Pauli outcome. The arguments
follow Stim’s naming convention: pix is I on qubit_i and X on
qubit_j, pzi is Z on qubit_i and I on qubit_j, etc.
reduce_null_bits
channels(list[Channel]) — List of channelsnull_col_id(int | None) — Column ID representing the all-zero column, or None if there is no all-zero column.
list[Channel]— List of channels with null bits marginalized out. Channels with alllist[Channel]— null entries are removed entirely (they have no effect on outputs).
simplify_channels
channels(list[Channel]) — List of channels to simplifymax_bits(int) — Maximum number of bits allowed per channelnull_col_id(int | None) — Column ID representing the all-zero column, or None if there is no all-zero column.
list[Channel]— Simplified list of channels
xor_convolve
probs_a(np.ndarray) — Shape (2^k,) probabilities for channel Aprobs_b(np.ndarray) — Shape (2^k,) probabilities for channel B (same size as A)
np.ndarray— Shape (2^k,) probabilities for the combined channel