> ## Documentation Index
> Fetch the complete documentation index at: https://tsim.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# types

> Core data types for the tsim compilation and sampling pipeline.

This module defines immutable data structures that represent the different
stages of circuit compilation:

1. SamplingGraph: Result of parsing and reducing a circuit graph
2. CompiledComponent: A single compiled connected component
3. CompiledProgram: The full compiled circuit ready for sampling

## class `CompiledComponent`

```python theme={null}
CompiledComponent()
```

A single compiled connected component of a circuit.

Each component is independent and can be sampled separately. The results
are then combined according to output\_indices.

## class `CompiledProgram`

```python theme={null}
CompiledProgram(components: tuple[CompiledComponent, ...], direct_f_indices: Array, direct_flips: Array, output_order: Array, output_reindex: Array | None, num_outputs: int, num_detectors: int)
```

A fully compiled circuit program ready for sampling.

This is the result of compiling a SamplingGraph and contains everything
needed to sample from the circuit.

## class `CompiledScalarGraphs`

```python theme={null}
CompiledScalarGraphs()
```

JAX-compatible compiled representation of a list of scalar ZX graphs.

The scalar for each graph is a product of four term families, multiplied by
a per-graph `ScalarPrefactor` (global phase, floatfactor, `2^power2`,
optional approximate complex floatfactor). All arrays are static-shaped so
the whole struct can be traced under `jax.jit`.

## class `SamplingGraph`

```python theme={null}
SamplingGraph(graph: BaseGraph, error_transform: np.ndarray, channel_probs: list[np.ndarray], num_outputs: int, num_detectors: int)
```

Result of the graph preparation phase for sampling.

Contains all data structures needed for sampling. This represents a circuit
that has been:

1. Parsed from stim format
2. Converted to a ZX graph
3. Doubled (composed with adjoint)
4. Reduced via zx.full\_reduce
5. Had its error basis transformed (Gaussian elimination: e → f)
