Skip to content

Commit

Permalink
multiply error by stabiliser
Browse files Browse the repository at this point in the history
  • Loading branch information
meandmytram committed Oct 11, 2024
1 parent 07263ca commit 41872df
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions examples/decoding/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ def decode_css(
bias_type: str = "Depolarising",
bias_prob: float = float(0.1),
renormalise: bool = True,
multiply_by_stabiliser: bool = True,
silent: bool = False,
contraction_strategy: str = "Naive",
optimiser: str = "Dephasing DMRG",
Expand All @@ -1203,6 +1204,8 @@ def decode_css(
The error in a string format.
The way the decoder takes the error is as follows:
"X_0 Z_0 X_1 Z_1 ..."
num_runs : int
Number of DMRG sweeps.
chi_max : int
Maximum bond dimension to keep during contractions
and in the Dephasing DMRG algorithm.
Expand All @@ -1211,10 +1214,10 @@ def decode_css(
Available options: "Bitflip" and "Depolarising".
bias_prob : float
The probability of the depolarising bias applied before checks.
num_runs : int
Number of DMRG sweeps.
renormalise : bool
Whether to renormalise the singular values during contraction.
multiply_by_stabiliser : bool
Whether to multiply the error by a random stabiliser before decoding.
silent : bool
Whether to show the progress bars or not.
contraction_strategy : str
Expand All @@ -1232,6 +1235,13 @@ def decode_css(
if not silent:
logging.info("Starting decoding.")

if multiply_by_stabiliser:
stabilisers_x, stabilisers_z = css_code_stabilisers(code)
stabilisers = stabilisers_x + stabilisers_z
error = multiply_pauli_strings(error, np.random.choice(stabilisers))

error = pauli_to_mps(error)

num_sites = 2 * len(code) + code.num_x_logicals() + code.num_z_logicals()
num_logicals = code.num_x_logicals() + code.num_z_logicals()

Expand Down Expand Up @@ -1272,6 +1282,19 @@ def decode_css(
renormalise=renormalise,
)

if not silent:
logging.info("Applying logicals' constraints.")
error_mps = apply_constraints(
error_mps,
logicals_sites,
logicals_tensors,
chi_max=chi_max,
renormalise=renormalise,
silent=silent,
strategy=contraction_strategy,
result_to_explicit=False,
)

if not silent:
logging.info("Applying the X constraints.")
try:
Expand Down Expand Up @@ -1310,19 +1333,6 @@ def decode_css(
)
return None, 0

if not silent:
logging.info("Applying logicals constraints.")
error_mps = apply_constraints(
error_mps,
logicals_sites,
logicals_tensors,
chi_max=chi_max,
renormalise=renormalise,
silent=silent,
strategy=contraction_strategy,
result_to_explicit=False,
)

if not silent:
logging.info("Marginalising the error MPS.")
sites_to_marginalise = list(range(num_logicals, len(error) + num_logicals))
Expand Down

0 comments on commit 41872df

Please sign in to comment.