tsim.core.graph.prepare_graph
← Module overview
function
source
functionprepare_graph¶source
tsim.core.graph.prepare_graph
Signature
def prepare_graph(circuit: Circuit, *, sample_detectors: bool) -> SamplingGraphPrepare a circuit for compilation.
This function performs the graph preparation phase:
- Parse the stim circuit into a ZX graph
- Build the sampling graph (compose with adjoint, add outputs)
- Reduce the graph via zx.full_reduce
- Transform error basis via Gaussian elimination (e → f)
- Clear the scalar (safe before stabilizer rank decomposition)
Parameters
| Name | Type | Description |
|---|---|---|
circuit | Circuit | The quantum circuit to prepare. |
sample_detectors | bool | If True, prepare for detector sampling. If False, prepare for measurement sampling. |
Returns
SamplingGraphA SamplingGraph containing the reduced graph and error transformation.