pipeline
Compilation pipeline from prepared graphs to executable programs.
classify_direct
classify_direct(
component: Graph, layout: ParamLayout
) -> tuple[int, bool] | None
Return (basis index, flip) if the component's only output is one basis bit.
That is the case when the component is a classical output boundary joined by a Hadamard edge to a classical Z spider whose phase is 0 or π plus one error-basis parameter.
Source code in src/tsim/compile/pipeline.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
compile_program
compile_program(
prepared: SamplingGraph,
*,
mode: DecompositionMode,
strategy: SamplingStrategy
) -> CompiledProgram
Compile a prepared graph into an executable sampling program.
The graph is split into connected components. A component whose single output equals one error-basis bit takes the direct path. With strategy="active_statevector" every other component becomes an action tape for the statevector executor. Otherwise its outputs are plugged (all prefixes in sequential mode, none and all in joint mode), each plugged graph is decomposed into stabilizer terms, and the terms are compiled into JAX arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prepared | SamplingGraph | The prepared graph from | required |
mode | DecompositionMode |
| required |
strategy | SamplingStrategy |
| required |
Returns:
| Type | Description |
|---|---|
CompiledProgram | A CompiledProgram ready for sampling. |
Raises:
| Type | Description |
|---|---|
ValueError | If |
Source code in src/tsim/compile/pipeline.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |