Configuration recovery (qiskit_addon_sqd.configuration_recovery)

Functions for performing self-consistent configuration recovery.

post_select_by_hamming_weight(bitstring_matrix, *, hamming_right, hamming_left)[source]

Post-select bitstrings based on the hamming weight of each half.

Parameters:
  • bitstring_matrix (ndarray) – A 2D array of bool representations of bit values such that each row represents a single bitstring

  • hamming_right (int) – The target hamming weight of the right half of bitstrings

  • hamming_left (int) – The target hamming weight of the left half of bitstrings

Returns:

A mask signifying which samples (rows) were selected from the input matrix.

Return type:

ndarray

recover_configurations(bitstring_matrix, probabilities, avg_occupancies, num_elec_a, num_elec_b, rand_seed=None)[source]

Refine bitstrings based on average orbital occupancy and a target hamming weight.

This function refines each bit in isolation in an attempt to transform the Hilbert space represented by the input bitstring_matrix into a space closer to that which supports the ground state.

Note

This function makes the assumption that bit i represents the spin-down orbital corresponding to the spin-up orbital in bit i + N where N is the number of spatial orbitals and i < N.

Note

The output configurations may not necessarily have correct hamming weight, as each bit is flipped in isolation from the other bits in the bitstring.

Parameters:
  • bitstring_matrix (ndarray) – A 2D array of bool representations of bit values such that each row represents a single bitstring

  • probabilities (Sequence[float]) – A 1D array specifying a probability distribution over the bitstrings

  • avg_occupancies (ndarray) – A 1D array containing the mean occupancy of each orbital. It is assumed that avg_occupancies[i] corresponds to the orbital represented by column i in bitstring_matrix.

  • num_elec_a (int) – The number of spin-up electrons in the system.

  • num_elec_b (int) – The number of spin-down electrons in the system.

  • rand_seed (Generator | int | None) – A seed for controlling randomness

Returns:

A refined bitstring matrix and an updated probability array.

Return type:

tuple[ndarray, ndarray]

References

[1]: J. Robledo-Moreno, et al., Chemistry Beyond Exact Solutions on a Quantum-Centric Supercomputer,

arXiv:2405.05068 [quant-ph].