qsci_algorithms
¶
Implementation of QSCI and TE-QSCI algorithms using quri-parts framework.
This module provides implementations of: 1. Vanilla QSCI algorithm 2. Time-Evolved QSCI (TE-QSCI) variants 3. Algorithm interfaces compatible with quri-algo
Key algorithms: - QSCI: Quantum Selected Configuration Interaction - TE-QSCI: Time-Evolved QSCI (single-time and time-average variants)
Classes:
Name | Description |
---|---|
QSCIVariant |
Enumeration of QSCI algorithm variants. |
QSCIResult |
Result of QSCI algorithm execution. |
QSCIBase |
Base class for QSCI algorithms. |
VanillaQSCI |
Vanilla QSCI algorithm implementation. |
TimeEvolvedQSCI |
Time-Evolved QSCI (TE-QSCI) algorithm implementation. |
SingleTimeTE_QSCI |
Single-time TE-QSCI wrapper for testing compatibility. |
TimeAverageTE_QSCI |
Time-average TE-QSCI wrapper for testing compatibility. |
FfsimStateVectorQSCI |
QSCI algorithm for direct ffsim state vector input. |
StateVectorTE_QSCI |
State vector TE-QSCI wrapper for testing compatibility. |
QSCIVariant
¶
Bases: Enum
Enumeration of QSCI algorithm variants.
Attributes:
Name | Type | Description |
---|---|---|
VANILLA |
|
|
SINGLE_TIME_TE |
|
|
TIME_AVERAGE_TE |
|
|
STATE_VECTOR |
|
QSCIResult
dataclass
¶
QSCIResult(
eigenvalues,
eigenstates,
selected_states,
subspace_dimension,
total_shots,
algorithm_variant,
execution_time=None,
computational_basis_probabilities=None,
)
Result of QSCI algorithm execution.
Attributes:
Name | Type | Description |
---|---|---|
eigenvalues |
Sequence[float]
|
|
eigenstates |
Sequence[ComputationalBasisSuperposition]
|
|
selected_states |
Sequence[ComputationalBasisState]
|
|
subspace_dimension |
int
|
|
total_shots |
int
|
|
algorithm_variant |
QSCIVariant
|
|
execution_time |
Optional[float]
|
|
computational_basis_probabilities |
Optional[Dict[int, float]]
|
|
ground_state_energy |
float
|
Ground state energy (lowest eigenvalue). |
ground_state |
ComputationalBasisSuperposition
|
Ground state (eigenstate corresponding to lowest eigenvalue). |
ground_state_probability |
float
|
Probability of measuring the ground state in computational basis. |
QSCIBase
¶
QSCIBase(
hamiltonian, sampler=None, num_states_pick_out=None
)
Bases: ABC
Base class for QSCI algorithms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Operator
|
Target Hamiltonian to diagonalize |
required |
|
Optional[ConcurrentSampler]
|
Quantum sampler for measurement |
None
|
|
Optional[int]
|
Number of states to select for subspace |
None
|
Methods:
Name | Description |
---|---|
run |
Run the QSCI algorithm. |
Attributes:
Name | Type | Description |
---|---|---|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
Source code in src/qsci_algorithms.py
run
abstractmethod
¶
run(input_states, total_shots, **kwargs)
Run the QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Sequence[CircuitQuantumState]
|
Input quantum states for sampling |
required |
|
int
|
Total number of measurement shots |
required |
|
Additional algorithm-specific parameters |
{}
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult containing eigenvalues, eigenstates, and metadata |
Source code in src/qsci_algorithms.py
VanillaQSCI
¶
VanillaQSCI(
hamiltonian, sampler=None, num_states_pick_out=None
)
Bases: QSCIBase
Vanilla QSCI algorithm implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Operator
|
Target Hamiltonian to diagonalize |
required |
|
Optional[ConcurrentSampler]
|
Quantum sampler for measurement |
None
|
|
Optional[int]
|
Number of states to select for subspace |
None
|
Methods:
Name | Description |
---|---|
run |
Run vanilla QSCI algorithm. |
Attributes:
Name | Type | Description |
---|---|---|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
Source code in src/qsci_algorithms.py
run
¶
Run vanilla QSCI algorithm.
Source code in src/qsci_algorithms.py
TimeEvolvedQSCI
¶
TimeEvolvedQSCI(
hamiltonian,
sampler=None,
num_states_pick_out=None,
time_evolution_method="trotter",
)
Bases: QSCIBase
Time-Evolved QSCI (TE-QSCI) algorithm implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Operator
|
Target Hamiltonian |
required |
|
Optional[ConcurrentSampler]
|
Quantum sampler (None for state vector variant) |
None
|
|
Optional[int]
|
Number of states to select |
None
|
|
str
|
Method for time evolution ("trotter", "exact") |
'trotter'
|
Methods:
Name | Description |
---|---|
run_single_time |
Run single-time TE-QSCI algorithm. |
run_time_average |
Run time-average TE-QSCI algorithm. |
run_state_vector |
Run TE-QSCI with direct state vector calculation. |
run |
General run method for TE-QSCI (defaults to single-time). |
Attributes:
Name | Type | Description |
---|---|---|
time_evolution_method |
|
|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
Source code in src/qsci_algorithms.py
run_single_time
¶
run_single_time(
initial_state,
evolution_time,
total_shots,
trotter_steps=None,
**kwargs
)
Run single-time TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of measurement shots |
required |
|
Optional[int]
|
Number of Trotter steps (if using Trotter method) |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with TE-QSCI results |
Source code in src/qsci_algorithms.py
run_time_average
¶
run_time_average(
initial_state,
evolution_times,
shots_per_time,
trotter_steps=None,
**kwargs
)
Run time-average TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
Sequence[float]
|
Times for evolution |
required |
|
int
|
Number of shots per time point |
required |
|
Optional[int]
|
Number of Trotter steps |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with time-average TE-QSCI results |
Source code in src/qsci_algorithms.py
run_state_vector
¶
run_state_vector(
initial_state,
evolution_time,
num_eigenstates=1,
**kwargs
)
Run TE-QSCI with direct state vector calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
QuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of eigenstates to compute |
1
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with state vector TE-QSCI results |
Source code in src/qsci_algorithms.py
run
¶
General run method for TE-QSCI (defaults to single-time).
Source code in src/qsci_algorithms.py
SingleTimeTE_QSCI
¶
Bases: TimeEvolvedQSCI
Single-time TE-QSCI wrapper for testing compatibility.
Methods:
Name | Description |
---|---|
run |
|
run_single_time |
Run single-time TE-QSCI algorithm. |
run_time_average |
Run time-average TE-QSCI algorithm. |
run_state_vector |
Run TE-QSCI with direct state vector calculation. |
Attributes:
Name | Type | Description |
---|---|---|
evolution_time |
|
|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
|
time_evolution_method |
|
Source code in src/qsci_algorithms.py
run
¶
Source code in src/qsci_algorithms.py
run_single_time
¶
run_single_time(
initial_state,
evolution_time,
total_shots,
trotter_steps=None,
**kwargs
)
Run single-time TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of measurement shots |
required |
|
Optional[int]
|
Number of Trotter steps (if using Trotter method) |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with TE-QSCI results |
Source code in src/qsci_algorithms.py
run_time_average
¶
run_time_average(
initial_state,
evolution_times,
shots_per_time,
trotter_steps=None,
**kwargs
)
Run time-average TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
Sequence[float]
|
Times for evolution |
required |
|
int
|
Number of shots per time point |
required |
|
Optional[int]
|
Number of Trotter steps |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with time-average TE-QSCI results |
Source code in src/qsci_algorithms.py
run_state_vector
¶
run_state_vector(
initial_state,
evolution_time,
num_eigenstates=1,
**kwargs
)
Run TE-QSCI with direct state vector calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
QuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of eigenstates to compute |
1
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with state vector TE-QSCI results |
Source code in src/qsci_algorithms.py
TimeAverageTE_QSCI
¶
Bases: TimeEvolvedQSCI
Time-average TE-QSCI wrapper for testing compatibility.
Methods:
Name | Description |
---|---|
run |
|
run_single_time |
Run single-time TE-QSCI algorithm. |
run_time_average |
Run time-average TE-QSCI algorithm. |
run_state_vector |
Run TE-QSCI with direct state vector calculation. |
Attributes:
Name | Type | Description |
---|---|---|
evolution_times |
|
|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
|
time_evolution_method |
|
Source code in src/qsci_algorithms.py
run
¶
Source code in src/qsci_algorithms.py
run_single_time
¶
run_single_time(
initial_state,
evolution_time,
total_shots,
trotter_steps=None,
**kwargs
)
Run single-time TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of measurement shots |
required |
|
Optional[int]
|
Number of Trotter steps (if using Trotter method) |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with TE-QSCI results |
Source code in src/qsci_algorithms.py
run_time_average
¶
run_time_average(
initial_state,
evolution_times,
shots_per_time,
trotter_steps=None,
**kwargs
)
Run time-average TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
Sequence[float]
|
Times for evolution |
required |
|
int
|
Number of shots per time point |
required |
|
Optional[int]
|
Number of Trotter steps |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with time-average TE-QSCI results |
Source code in src/qsci_algorithms.py
run_state_vector
¶
run_state_vector(
initial_state,
evolution_time,
num_eigenstates=1,
**kwargs
)
Run TE-QSCI with direct state vector calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
QuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of eigenstates to compute |
1
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with state vector TE-QSCI results |
Source code in src/qsci_algorithms.py
FfsimStateVectorQSCI
¶
FfsimStateVectorQSCI(hamiltonian, num_states_pick_out=None)
Bases: QSCIBase
QSCI algorithm for direct ffsim state vector input.
This class provides direct integration with ffsim's LUCJ/UCJ ansatz state vectors, bypassing circuit sampling and using exact computational basis probabilities for more accurate QSCI analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Operator
|
Target Hamiltonian to diagonalize (quri-parts Operator) |
required |
|
Optional[int]
|
Number of states to select for subspace |
None
|
Methods:
Name | Description |
---|---|
run |
Run QSCI algorithm - maintained for interface compatibility. |
run_ffsim_state_vector |
Run QSCI with direct ffsim state vector input. |
Attributes:
Name | Type | Description |
---|---|---|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
Source code in src/qsci_algorithms.py
run
¶
Run QSCI algorithm - maintained for interface compatibility.
Note: This method maintains the standard QSCI interface but is not the primary entry point for ffsim integration. Use run_ffsim_state_vector() instead.
Source code in src/qsci_algorithms.py
run_ffsim_state_vector
¶
run_ffsim_state_vector(
ffsim_state_vector,
n_qubits,
num_eigenstates=1,
nelec=None,
**kwargs
)
Run QSCI with direct ffsim state vector input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
State vector from ffsim LUCJ/UCJ ansatz (numpy array) |
required |
|
int
|
Number of qubits in the system (typically 2 * norb) |
required |
|
int
|
Number of eigenstates to compute |
1
|
|
Additional parameters |
{}
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with exact QSCI analysis results |
Source code in src/qsci_algorithms.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
|
StateVectorTE_QSCI
¶
Bases: TimeEvolvedQSCI
State vector TE-QSCI wrapper for testing compatibility.
Methods:
Name | Description |
---|---|
run |
|
run_single_time |
Run single-time TE-QSCI algorithm. |
run_time_average |
Run time-average TE-QSCI algorithm. |
run_state_vector |
Run TE-QSCI with direct state vector calculation. |
Attributes:
Name | Type | Description |
---|---|---|
evolution_time |
|
|
hamiltonian |
|
|
sampler |
|
|
num_states_pick_out |
|
|
time_evolution_method |
|
Source code in src/qsci_algorithms.py
run
¶
Source code in src/qsci_algorithms.py
run_single_time
¶
run_single_time(
initial_state,
evolution_time,
total_shots,
trotter_steps=None,
**kwargs
)
Run single-time TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of measurement shots |
required |
|
Optional[int]
|
Number of Trotter steps (if using Trotter method) |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with TE-QSCI results |
Source code in src/qsci_algorithms.py
run_time_average
¶
run_time_average(
initial_state,
evolution_times,
shots_per_time,
trotter_steps=None,
**kwargs
)
Run time-average TE-QSCI algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
CircuitQuantumState
|
Initial quantum state |
required |
|
Sequence[float]
|
Times for evolution |
required |
|
int
|
Number of shots per time point |
required |
|
Optional[int]
|
Number of Trotter steps |
None
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with time-average TE-QSCI results |
Source code in src/qsci_algorithms.py
run_state_vector
¶
run_state_vector(
initial_state,
evolution_time,
num_eigenstates=1,
**kwargs
)
Run TE-QSCI with direct state vector calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
QuantumState
|
Initial quantum state |
required |
|
float
|
Time for evolution |
required |
|
int
|
Number of eigenstates to compute |
1
|
Returns:
Type | Description |
---|---|
QSCIResult
|
QSCIResult with state vector TE-QSCI results |