qdk_chemistry.algorithms.state_preparation package

QDK/Chemistry state preparation algorithms module.

This module provides quantum state preparation algorithms for preparing quantum states from classical wavefunctions.

class qdk_chemistry.algorithms.state_preparation.DensePureStatePreparation

Bases: StatePreparation

State preparation using the Q# PreparePureStateD operation.

This is the simplest dense amplitude-loading strategy: given an arbitrary real-valued amplitude vector, it uses PreparePureStateD to prepare the corresponding state on a qubit register.

__init__()

Initialize the DensePureStatePreparation.

name()

Return the algorithm name.

Returns:

The name "dense_pure_state".

Return type:

str

class qdk_chemistry.algorithms.state_preparation.SparseIsometryStatePreparation

Bases: StatePreparation

State preparation using sparse isometry with enhanced GF2 Gaussian elimination.

This class implements sparse isometry state preparation for electronic structure problems. The preprocessing includes:

  1. Removing duplicate rows using CX operations

  2. Removing all-ones rows using X operations

  3. Then performing standard GF2 Gaussian elimination

  4. Apply the additional rank reduction if the reduced row-echelon matrix is diagonal

This enhanced approach can be more efficient than standard GF2 Gaussian elimination, particularly for matrices with duplicate rows or all-ones rows. The algorithm tracks both CX and X operations for proper circuit reconstruction.

Key References:

  • Sparse isometry: Malvetti, Iten, and Colbeck (arXiv:2006.00016) [MIC21]

  • GF(2) affine compression and binary encoding: Chen et al. (arXiv:2608.20593) [CBG+26]

__init__()

Initialize the SparseIsometryStatePreparation.

Return type:

None

create_dense(wavefunction)

Build only the dense-loading stage of the sparse isometry circuit.

This is a helper function for resource estimation. It returns a Circuit that prepares the dense subspace of the wavefunction. This allows users to estimate the resource cost of the dense-loading stage separately from the isometry expansion.

A sparse isometry circuit loads the amplitudes densely on a reduced qubit subset and then applies the isometry gates (binary encoding and/or GF(2) expansion) that map the reduced state back onto the full register. This method returns the dense stage alone, embedded in the same full-width register that StatePreparation.run uses, so the isometry cost can be obtained by subtracting the two resource estimates.

Parameters:

wavefunction (Wavefunction) – The target wavefunction to prepare.

Return type:

Circuit

Returns:

A Circuit containing only the dense-loading stage, acting on the full register.

Examples

>>> prep = create("state_prep", "sparse_isometry")
>>> full = prep.run(wavefunction).estimate()["logicalCounts"]
>>> dense = prep.create_dense(wavefunction).estimate()["logicalCounts"]
>>> isometry_t_count = full["tCount"] - dense["tCount"]
name()

Return the name of the state preparation method.

Return type:

str

class qdk_chemistry.algorithms.state_preparation.StatePreparationFactory

Bases: AlgorithmFactory

Factory class for creating StatePreparation instances.

__init__()

Initialize the StatePreparationFactory.

algorithm_type_name()

Return the algorithm type name as state_prep.

Return type:

str

default_algorithm_name()

Return the sparse_isometry as default algorithm name.

Return type:

str

qdk_chemistry.algorithms.state_preparation.identity_state_prep(num_qubits)

Create an identity state-preparation circuit that leaves the initial state unchanged.

Useful as a trivial state-prep when evolving from a computational basis state (e.g. |0...0>) without any additional preparation.

Parameters:

num_qubits (int) – Number of qubits in the circuit.

Return type:

Circuit

Returns:

A Circuit representing the identity operation on num_qubits qubits.

Submodules