torch_sci_solver.torch_impl.sbdiag¶
Top-level driver — torch analog of torch_sci_solver.sbd_ref.sbdiag.diag.
Builds the helpers and integrals on CPU once (cheap, ragged enumeration isn't worth GPU-vectorizing for the basis sizes SBD targets), then runs Davidson + matvec entirely on the target device.
The interface mirrors the scalar diag() so swapping the import line
gets you the GPU version.
diag_torch
¶
diag_torch(adets: List[int], bdets: List[int], n_orb: int, I0: float, I1: OneInt, I2: TwoInt, *, max_davidson_iters: int = 50, davidson_block_size: int = 30, eps: float = 1e-08, de_tol: float | None = None, init: int = 0, n_roots: int = 1, device: device | str = 'cpu', dtype: dtype = float64, chunk_size: int = 2000000, matvec_impl: str = 'torch', verbose: bool = False, mode: Literal['tpb', 'gdb'] = 'tpb', pair_budget_bytes: int | None = None, block_matvec: str = 'off') -> Tuple[float | Tensor, Tensor, dict]
Lowest eigenpairs — torch port of diag().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adets, bdets
|
In TPB mode ( |
required | |
n_orb
|
int
|
number of spatial orbitals. |
required |
I0, I1, I2
|
integrals from |
required | |
max_davidson_iters
|
int
|
outer Davidson restart count. |
50
|
davidson_block_size
|
int
|
subspace expansion per restart. |
30
|
eps
|
float
|
residual-norm convergence threshold. |
1e-08
|
de_tol
|
float | None
|
opt-in eigenvalue-stability check — see
:func: |
None
|
init
|
int
|
0 = HF, 1 = random. |
0
|
n_roots
|
int
|
number of lowest eigenpairs to return (default 1).
When > 1, returns
|
1
|
device
|
device | str
|
torch device for tensors. |
'cpu'
|
dtype
|
dtype
|
float dtype. |
float64
|
matvec_impl
|
str
|
|
'torch'
|
verbose
|
bool
|
per-iteration prints. |
False
|
mode
|
Literal['tpb', 'gdb']
|
See :class: |
'tpb'
|
pair_budget_bytes
|
int | None
|
GDB only. Peak workspace per excitation-
enumeration chunk; |
None
|
block_matvec
|
str
|
GDB only. |
'off'
|
Returns:
| Type | Description |
|---|---|
float | Tensor
|
For |
Tensor
|
Python float, eigvec is a |
dict
|
For |
Tuple[float | Tensor, Tensor, dict]
|
a |
Tuple[float | Tensor, Tensor, dict]
|
|