qrunch.chemistry.calculators.quantum_selected_configuration_interaction.sqdrift_calculator
SqDRIFT calculator for the lowest energy states: QSCI sampling Krylov states built by qDRIFT time evolution.
Functions
Return the default reference block, currently the Hartree-Fock state only. |
Classes
Calculate the lowest energy states, the ground state included, with SqDRIFT. |
|
Shared SqDRIFT compilation and Krylov sequence options. |
- class SqDriftLowestStatesCalculator
Bases:
objectCalculate the lowest energy states, the ground state included, with SqDRIFT.
This calculator implements baseline SqDRIFT. For PRIME-SqDRIFT enhancements, including SHARP adaptive reweighting, use
calculator_creator().quantum_selected_configuration_interaction().prime_sqdrift().The subspace is seeded by a block of reference states: each reference is evolved by qDRIFT Krylov circuits and sampled, the determinants sampled from all references are pooled into one subspace, and the Hamiltonian is diagonalized once in that subspace. The default reference is the Hartree-Fock state; references overlapping with the low-lying excited states improve the excited-state energies.
- __init__(sampler: Sampler, *, shots_per_circuit: int, options: SqDriftOptions | None = None, time_step: float = 1.0, paired_electron_approximation: bool = False, reference_circuit_providers: Sequence[ReferenceCircuitProvider] | None = None) None
Initialize the SqDRIFT calculator.
- Parameters:
sampler (Sampler) – Sampler used to draw computational-basis samples from each Krylov circuit.
shots_per_circuit (int) – Number of samples to draw from each circuit.
options (SqDriftOptions | None) – Optional SqDRIFT options; if not provided, defaults are used.
time_step (float) – Time step \(\tau\) of the Krylov states.
paired_electron_approximation (bool) – Whether to use the paired-electron approximation. Every reference circuit provider must then support it.
reference_circuit_providers (Sequence[ReferenceCircuitProvider] | None) – Providers of the reference states. Defaults to the Hartree-Fock state. Cannot be combined with an
initial_vqe_resultincalculate().
- Return type:
None
- calculate(problem: RestrictedGroundStateProblem | LazyRestrictedGroundStateProblem | UnrestrictedGroundStateProblem | LazyUnrestrictedGroundStateProblem, initial_vqe_result: AdaptiveVqeGroundStateProblemCalculatorResult | None = None, *, n_lowest: int, callback: SamplingProgressCallback | None = None) QuantumSelectedConfigurationInteractionLowestStatesResult
- calculate(problem: RestrictedReactionPathProblem | UnrestrictedReactionPathProblem, initial_vqe_result: AdaptiveVqeReactionPathProblemCalculatorResult | None = None, *, n_lowest: int, callback: SamplingProgressCallback | None = None) ReactionPathLowestStatesResult
- calculate(problem: RestrictedGroundStateProblem | LazyRestrictedGroundStateProblem | UnrestrictedGroundStateProblem | LazyUnrestrictedGroundStateProblem, initial_vqe_result: AdaptiveVqeGroundStateProblemCalculatorResult | None = None, *, n_lowest: None = None, callback: SamplingProgressCallback | None = None) QuantumSelectedConfigurationInteractionGroundStateProblemCalculatorResult
- calculate(problem: RestrictedReactionPathProblem | UnrestrictedReactionPathProblem, initial_vqe_result: AdaptiveVqeReactionPathProblemCalculatorResult | None = None, *, n_lowest: None = None, callback: SamplingProgressCallback | None = None) ReactionPathProblemCalculatorResult
Calculate the energies of the lowest states of the given molecule or of every geometry of a reaction.
To follow sampling progress, pass a plain object. Name the metrics you need and accept any remaining metrics with
**_other_metrics:class PrintProgress: def record_circuit_sampled(self, *, number_of_circuits: int, **_other_metrics: object) -> None: print(f"{number_of_circuits} circuits sampled") result = calculator.calculate(problem, n_lowest=2, callback=PrintProgress())
See Follow the progress of a run for the full list of keyword arguments. No Qrunch imports or subclassing are needed.
- Parameters:
problem (RestrictedGroundStateProblem | LazyRestrictedGroundStateProblem | UnrestrictedGroundStateProblem | LazyUnrestrictedGroundStateProblem | RestrictedReactionPathProblem | UnrestrictedReactionPathProblem) – Ground state problem or reaction path problem to calculate the energies for.
initial_vqe_result (AdaptiveVqeGroundStateProblemCalculatorResult | AdaptiveVqeReactionPathProblemCalculatorResult | None) – Optional VQE result to start from instead of the reference circuit providers. Its final state is the only reference evolved by the Krylov circuits, and its final operator, if any, defines the Hamiltonian. Without the paired-electron approximation, a paired-electron result, e.g. from OO-BEAST, is converted to fermions. For a GeneralGroundStateProblem this must be an AdaptiveVqeGroundStateProblemCalculatorResult, and for a ReactionPathProblem an AdaptiveVqeReactionPathProblemCalculatorResult. When passing this result, leave the reference family unset: calling
.choose_reference_circuit_providers()AND specifying an initial_vqe_result is not allowed.n_lowest (int | None) – Number of lowest states to calculate, the ground state included. When omitted, only the ground state is calculated and a ground-state result is returned.
callback (SamplingProgressCallback | None) – An optional object whose
record_circuit_sampledmethod receives metrics by keyword after every sampled circuit. A bare function is not accepted. The counts restart for each geometry along a reaction path.
- Return type:
QuantumSelectedConfigurationInteractionGroundStateProblemCalculatorResult | ReactionPathProblemCalculatorResult | QuantumSelectedConfigurationInteractionLowestStatesResult | ReactionPathLowestStatesResult
- class SqDriftOptions
Bases:
DataclassPublicAPIShared SqDRIFT compilation and Krylov sequence options.
Used by baseline SqDRIFT and the calculator with PRIME-SqDRIFT enhancements.
All fields are immutable (
frozen=True) so an instance can be safely reused.- Parameters:
subsequence_length – Number of Hamiltonian terms sampled into each qDRIFT time-evolution circuit, i.e. the length (gate count) of the qDRIFT subsequence. Larger means more precise.(default=10)
maximum_krylov_order – Largest Krylov order \(d\); circuits are generated for every order \(k = 1, \ldots, d\). Larger means more precise. (default=1)
number_of_randomizations – Number of qDRIFT circuits generated per Krylov order. More means a more precise estimate of the Krylov subspace, at the cost of more samples. (default=1)
seed – Optional seed for qDRIFT term sampling and iterative eigensolver probes. (default = None).
use_qeb_gates – Whether to use QEB excitation gates instead of exact fermionic time evolution. (default=True).
- __init__(*, subsequence_length: int = 10, maximum_krylov_order: int = 1, number_of_randomizations: int = 1, use_qeb_gates: bool = True, seed: int | None = None) None
- Parameters:
subsequence_length (int)
maximum_krylov_order (int)
number_of_randomizations (int)
use_qeb_gates (bool)
seed (int | None)
- Return type:
None
- maximum_krylov_order: int = 1
- number_of_randomizations: int = 1
- seed: int | None = None
- subsequence_length: int = 10
- use_qeb_gates: bool = True
- default_reference_circuit_providers() tuple[ReferenceCircuitProvider, ...]
Return the default reference block, currently the Hartree-Fock state only.
- Return type:
tuple[ReferenceCircuitProvider, …]