compile_state
- GateCompiler.compile_state(target_state, initial_state=None)
Compile the circuit preparing a state on the device.
A preparation asks less than a unitary: the circuit has to act correctly on the one state the experiment starts from, not on every basis state. The backend searches in that smaller space, so a preparation reaches register widths a unitary of the same circuit does not.
Runs under
AdaptiveConfigandErrorAwareAdaptiveConfig. Under the second the circuit carries its error-aware diagnostics onmetadata["error_aware"], and the search stops where the compilation and physical errors are smallest together rather than attolerance_error.- Parameters:
target_state (
Any) – State to prepare, as aStatevectoror an amplitude array.initial_state (
Any) – State the register starts in, as a basis-state index or aStatevector.Nonemeans the all-zero state. A device starting elsewhere is brought to it by a leading rotation on each excited qubit.
- Return type:
- Returns:
Native circuit preparing
target_statefrominitial_state.- Raises:
ConfigError – If the configuration has no state-preparation path.
ValidationError – If a state’s width does not match the gate set, its norm is not 1, or
initial_stateis not a basis state.