Skip to content

torch_sci_solver.torch_impl.spinless_helpers

Flat spin-orbital ("spinless") basis + streaming excitation tables.

A spinless Hamiltonian (GHF / spin-orbit-coupled / generalized-spinor) has no alpha/beta factorization: the wavefunction lives over an explicit list of N flat n_spinorb-bit determinants (dim = N), not a Cartesian product or an (alpha, beta) pair list. This module is the flat-determinant analogue of :mod:torch_sci_solver.torch_impl.pairs (the basis container + initial-vector helper) and :mod:torch_sci_solver.torch_impl.pair_helpers (the streaming excitation- table generator) — genuinely simpler than both, since there is no per-spin partner/uid bookkeeping to maintain: each basis row already is the unique element, so membership testing is a single torch.searchsorted against the sorted determinant list, with no "expand over partners sharing a spectator" step (:func:~torch_sci_solver.torch_impl.pair_helpers._stream_same_spin_dedup's whole reason to exist).

Excitation enumeration mirrors :func:~torch_sci_solver.torch_impl.pair_helpers. _stream_same_spin (the non-dedup reference there): for each determinant, enumerate every way to annihilate order occupied spin-orbitals and create order empty ones (order=1 singles, order=2 doubles), then keep the candidates whose excited determinant is also in the (sorted) basis.

Determinants are stored as a stacked (N, n_limbs) int64 tensor (see :mod:torch_sci_solver.torch_impl.determinants's module docstring for the limb convention), so n_spinorb is not capped at 64.

SpinlessSCIState [source] dataclass

SpinlessSCIState(amplitudes: 'np.ndarray', ci_strs: 'np.ndarray', norb: int, nelec: 'tuple[int, int]')

Spinless analog of qiskit_addon_sqd.fermion.SCIState.

SCIState requires amplitudes.shape == (len(ci_strs_a), len(ci_strs_b)) -- a Cartesian alpha/beta product. A spinless basis is a single length-N list of N-particle spin-orbital determinants; the eigenvector is a flat length-N 1-D vector and there is one string array, not two. Mirrors torch_sci_solver.torch_impl.pairs.PairSCIState (the pair-mode lookalike) and sci_solvers.spinless_ci_problem.SpinlessSCIState (the numpy/general-algebra equivalent) -- kept here rather than imported from sci_solvers since torch_sci_solver is the standalone lower-level package (sci_solvers depends on it, not the reverse).

save

save(filename)

Save the SpinlessSCIState object to an .npz file.

SpinlessBasis [source] dataclass

SpinlessBasis(dets: Tensor, n_spinorb: int, n_particles: int)

An explicit, sorted, deduplicated list of flat spin-orbital determinants.

Attributes:

Name Type Description
dets Tensor

sorted, deduplicated (N, n_limbs) int64 determinant bitmasks. Sorted lexicographically by limb index (limb 0 — the lowest 64 bits, see :mod:torch_sci_solver.torch_impl. determinants for the per-limb bit layout — compares first), which is :func:torch.unique's own dim=0 row order and is not the dets' numeric order once n_limbs > 1. Lookups only need self-consistency with that order (every one goes through :func:~torch_sci_solver.torch_impl.pair_helpers. _found_in_multilimb, which compares limbs in the same order) — but the sort order is not semantically neutral: the Davidson seed used to assume index 0 was the HF determinant, which this order only guarantees while n_limbs == 1. The seed is now chosen by diagonal (:func:basis_init_vector_spinless_torch's seed_index, set to the argmin of hii by the adapter), not by basis order.

n_spinorb int

number of spin-orbitals (nmo); each determinant is a bitmask over [0, n_spinorb).

n_particles int

total particle number N (every determinant has this popcount; not validated here, callers should have already filtered to a uniform particle number).

dim property

dim: int

N — the flat basis dimension.

n_limbs property

n_limbs: int

Number of int64 limbs each determinant occupies.

device property

device: device

Torch device of dets.