loqs.tools.qectools¶
A collection of tools useful for QEC.
Particularly for syndrome/Pauli frame/lookup table manipulation and calculation.
Functions¶
compose_pstr_lists ¶
compose_pstr_lists(pstr_list1: Sequence[str], pstr_list2: Sequence[str]) -> list[str]
Perform compose_pstrs() on two sets of Pauli strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pstr_list1
|
Sequence[str]
|
First set of Pauli strings |
required |
pstr_list2
|
Sequence[str]
|
Second set of Pauli strings |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of Pauli products between every string in the first set with every string in the second set |
compose_pstrs ¶
compose_pstrs(pstr1: str, pstr2: str) -> str
Multiply two Pauli strings.
Among other uses, it can be used to apply Pauli string
corrections to a frame. Mathematically, it is the same
as update_from_pauli_str(), but without
requiring one of the Pauli strings to be wrapped up in
a PauliFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pstr1
|
str
|
First Pauli string |
required |
pstr2
|
str
|
Second Pauli string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Product of the two Pauli strings |
get_hook_errors_in_flagged_check ¶
get_hook_errors_in_flagged_check(stabilizer: str, check_order: Sequence[int] | None = None) -> list[str]
Compute Pauli strings for hook errors in flagged check circuits.
This is an automated version of the calculation performed to get the data errors in Fig. 2d of arXiv:1705.02329.
The output of this can serve as the pstrs input to
get_syndrome_dict_from_stabilizers_and_pstrs()
for the purpose of computing lookup tables for correcting
measurement errors that result in hook errors.
For an example, see the "Flagged <stab> Decoder" instructions
in codepack_5_1_3_quantinuum2022.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stabilizer
|
str
|
Pauli string of the stabilizer to check |
required |
check_order
|
Sequence[int] | None
|
The order of qubits checked in the stabilizer. This is important because the first and last checks cannot spread, but that is not always done in ascending qubit order. Defaults to None, which does the checks in ascending qubit order. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
All possible hook error Pauli strings |
get_syndrome_dict_from_stabilizers_and_pstrs ¶
get_syndrome_dict_from_stabilizers_and_pstrs(stabilizers: Sequence[str], pstrs: Sequence[str], default_pstr: str | Literal['auto'] | None = 'auto') -> dict[str, list[str]]
Call get_syndrome_from_stabilizers_and_pstr() for many Pauli strings.
The output of this function can be used as a lookup table decoder if there is only a single entry -- i.e. data error -- per syndrome key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stabilizers
|
Sequence[str]
|
required | |
pstrs
|
Sequence[str]
|
List of Pauli strings, see
|
required |
default_pstr
|
str | Literal['auto'] | None
|
A default Pauli string to use for syndromes that do not
have a corresponding entry in |
'auto'
|
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
A dictionary with syndrome string keys and a list of all corresponding Pauli strings as values. |
get_syndrome_from_stabilizers_and_pstr ¶
get_syndrome_from_stabilizers_and_pstr(stabilizers: Sequence[str], pstr: str) -> str
Compute a syndrome for a Pauli string given stabilizers.
The computation here is as follows: for each stabilizer,
check how many entries of pstr anticommute with the
corresponding entry in the stabilizer. If there are an even
number of anticommutations, the stabilizer will measure 0;
otherwise, it will measure 1. Repeat for each stabilizer
to build up the syndrome bitstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stabilizers
|
Sequence[str]
|
A sequence of Pauli strings representing the stabilizers |
required |
pstr
|
str
|
The Pauli string to compute the syndrome for |
required |
Returns:
| Type | Description |
|---|---|
str
|
Syndrome bitstring as a string of |
get_weight_1_errors ¶
get_weight_1_errors(num_qubits: int) -> list[str]
Compute Pauli strings for weight-1 errors.
The output of this can serve as the pstrs input to
get_syndrome_dict_from_stabilizers_and_pstrs()
for the purpose of computing lookup tables for correcting
data errors.
For an example, see the "Unflagged Decoder" instruction
in codepack_5_1_3_quantinuum2022.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_qubits
|
int
|
The number of data qubits |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
All possible weight-1 Pauli strings |