qdk_chemistry.data.unitary_representation.containers.block_encoding module
QDK/Chemistry block encoding container module.
- class qdk_chemistry.data.unitary_representation.containers.block_encoding.BlockEncodingContainer[source]
Bases:
UnitaryContainerAbstract base class for block encoding containers.
- class qdk_chemistry.data.unitary_representation.containers.block_encoding.ControlledOperation(ctrl_state, operation)[source]
Bases:
objectA single controlled unitary operation in the SELECT oracle.
- to_hdf5(group)[source]
Save the ControlledOperation to an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group to write attributes to.
- class qdk_chemistry.data.unitary_representation.containers.block_encoding.LCUContainer(prepare, select, power=1)[source]
Bases:
BlockEncodingContainerContainer for a Linear Combination of Unitaries (LCU) decomposition.
Stores the pre-computed PREPARE and SELECT sub-objects that define a block-encoding circuit. This container is agnostic to the specific method used to compute these objects — that logic lives in the builder.
\[W = \text{PREPARE}^\dagger \cdot \text{SELECT} \cdot \text{PREPARE}\]- Parameters:
prepare (Wavefunction)
select (Select)
power (int)
- __init__(prepare, select, power=1)[source]
Initialize an LCUContainer.
- Parameters:
prepare (Wavefunction) – The prepare wavefunction encoding coefficients for the block encoded Hamiltonian.
select (Select) – The select oracle for controlled operations.
power (int) – Number of times to apply the block encoding (for B[H]^power).
- Return type:
None
- property power: int[source]
Number of times to apply the block encoding.
- Returns:
The power value.
- Return type:
- property num_prepare_ancillas: int[source]
Number of qubits in the prepare ancillary register.
Derived from the orbital basis size of the prepare wavefunction.
- Returns:
The ancilla qubit count.
- Return type:
- property num_qubits: int[source]
Total number of qubits (system + ancilla).
- Returns:
The combined qubit count.
- Return type:
- property type: str[source]
Get the type of the unitary container.
- Returns:
The type string
"lcu".- Return type:
- to_hdf5(group)[source]
Save the LCUContainer to an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group to write container data to.
- classmethod from_json(json_data)[source]
Create an LCUContainer from a JSON dictionary.
- classmethod from_hdf5(group)[source]
Load an LCUContainer from an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group to read container data from.
- Returns:
The deserialized instance.
- Return type:
- eigenvalue_from_phase(phase_fraction)[source]
Not applicable for a raw block encoding.
A plain block encoding does not define an eigenvalue-phase relationship on its own. Use
LCUWalkContainerfor QPE with qubitization.- Return type:
- Raises:
NotImplementedError – Always.
- Parameters:
phase_fraction (float)
- class qdk_chemistry.data.unitary_representation.containers.block_encoding.Select(controlled_operations, phases, num_prepare_ancillas, num_target_qubits, prepare_qubits, target_qubits)[source]
Bases:
objectClass representing the SELECT oracle for block encoding.
- Parameters:
- controlled_operations: list[ControlledOperation]
List of controlled operations.
- to_hdf5(group)[source]
Save the Select oracle to an HDF5 group.
- Return type:
- Parameters:
group (h5py.Group) – HDF5 group to write phases, attributes, and controlled operations to.
- __init__(controlled_operations, phases, num_prepare_ancillas, num_target_qubits, prepare_qubits, target_qubits)