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:
StatePreparationState preparation using the Q#
PreparePureStateDoperation.This is the simplest dense amplitude-loading strategy: given an arbitrary real-valued amplitude vector, it uses
PreparePureStateDto prepare the corresponding state on a qubit register.- __init__()
Initialize the DensePureStatePreparation.
- class qdk_chemistry.algorithms.state_preparation.SparseIsometryStatePreparation
Bases:
StatePreparationState preparation using sparse isometry with enhanced GF2 Gaussian elimination.
This class implements sparse isometry state preparation for electronic structure problems. The preprocessing includes:
Removing duplicate rows using CX operations
Removing all-ones rows using X operations
Then performing standard GF2 Gaussian elimination
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:
- __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:
- 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"]
- class qdk_chemistry.algorithms.state_preparation.StatePreparationFactory
Bases:
AlgorithmFactoryFactory class for creating StatePreparation instances.
- __init__()
Initialize the StatePreparationFactory.
- 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.
Submodules
- qdk_chemistry.algorithms.state_preparation._binary_encoding_utils module
- qdk_chemistry.algorithms.state_preparation.dense_pure_state module
- qdk_chemistry.algorithms.state_preparation.identity module
- qdk_chemistry.algorithms.state_preparation.sparse_isometry module
- qdk_chemistry.algorithms.state_preparation.state_preparation module