tsim.utils.encoder.TransversalEncoder
classTransversalEncoder¶source
tsim.utils.encoder.TransversalEncoder
Base class for transversal quantum error correction encoders.
Signature
class TransversalEncoder(n: int, encoding_qubit: int, encoding_program_text: str | None, stabilizer_generators: list[list[int]], observables: list[list[int]])Parameters
| Name | Type | Description |
|---|---|---|
n | int | |
encoding_qubit | int | |
encoding_program_text | str | None | |
stabilizer_generators | list[list[int]] | |
observables | list[list[int]] |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
n | int | n | |
encoding_qubit | int | encoding_qubit | |
circuit | — | tsim.Circuit() | |
used_qubits | set[int] | set() | |
encoding_program_text | — | encoding_program_text | |
stabilizer_generators | — | stabilizer_generators | |
observables | — | observables |
methodinitialize¶source
tsim.utils.encoder.TransversalEncoder.initialize
Signature
def initialize(program_text: str, encoding_program_text: str | None = None) -> NoneInitialize state preparation and apply encoding circuit.
Apply the state preparation program for k qubits, then apply an encoding circuit to encode the state into n qubits.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
program_text | str | required | The state preparation program for k qubits. Generally, this should be a simple program that prepares each of the k qubits in a single-qubit state. |
encoding_program_text | str | None | None | An encoding circuit for a single logical qubit. This should encode a single logical qubit at input `self.encoding_qubit` into a state of n qubits. If not provided, the encoder will use a noiseless default encoding. |
methodencode_transversally¶source
tsim.utils.encoder.TransversalEncoder.encode_transversally
def encode_transversally(program_text: str) -> NoneEncode a program transversally by replacing physicalgates with transversal gates.
Transform a program on m qubits into a program on n * m qubits (consisting of n code blocks).
Parameters
| Name | Type | Description |
|---|---|---|
program_text | str | The program to encode transversally. |
methoddiagram¶source
tsim.utils.encoder.TransversalEncoder.diagram
def diagram(**kwargs={})Return a timeline-svg diagram of the encoded circuit.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
**kwargs | — | {} |
methodencoding_flow_generators¶source
tsim.utils.encoder.TransversalEncoder.encoding_flow_generators