Repository navigation
v0.22.0 — block CG + low-rank preconditioners, streamed large-basis DF-RHF/DF-MP2, fp64 policy
Validated on Trn2 (trn2.3xlarge, Neuron SDK 2.33.0, native TorchNeuron) — see trnsci/trnsci#35.
Headline: cg_block / cg_block_ir block CG and pivoted-Cholesky low-rank preconditioners for matrix-free operators (#97, #114); out-of-core and streamed DF-RHF + DF-MP2 at large basis on Trn2 (#15, trnsci/trnsci#115); cached eager NKI handles; and the trnsci float64 policy with a dtype guard at the kernel boundary. The [dev] extra now requires trntensor>=0.24 (AuxStream, trntensor#102).
Performance
- Eager NKI kernel calls skip the per-call handle rebuild and the custom-op
layer (same fix as trnblas#92). On the native path atrnsolver::
custom-op call cost about 0.1 ms of host time before the kernel was queued,
against 0.016 ms for aten. Most of it went to nki'sKernel.__call__,
which rebuilds the torch handle on every call, plus thetorch.library
layer.dispatch._launchnow calls atorch_neuronx.wrap_nkihandle built
once per kernel;static=arguments (the Jacobionezero) get the op
body'sint(). On trn2 (LNC=2), amatveclaunch drops from 0.121 to
0.032 ms of issue time (e2e 0.203 to 0.130 ms) and a 128x128x32matmul
from 0.123 to 0.032 ms (e2e 0.196 to 0.117 ms).eighitself is host-bound
and gains less: n=32 on the Householder kernels 86.7 to 76.1 ms, a 4x32x32
Jacobi batch 6.10 to 5.95 ms. Results are bit-identical.torch.compile,
requires-grad, int64 and tensor-subclass inputs keep the custom op, as
does the foldedoccupied_subspacepass (subspace_step) for now.
TRNSOLVER_NKI_EAGER_HANDLE=0turns this off;
scripts/bench_eager_handle.pymeasures it.
Added
-
run_scf(guess=...): a minao initial guess, or given occupied orbitals (trnsci/trnsci#115)."core"is the default and keeps the old behaviour."minao"takes PySCF's superposed atomic densities (minao_density) as natural orbitals in the kept orthonormal basis (guess_orbitals).- An
(n, nocc)tensor is S-orthonormalised and used directly, for example to restart. - Why: from the core guess, fp32 DIIS did not converge for alkane69 / cc-pVDZ (n_ao 1666) in 40 iterations, on either
subspaceororth, with the energy wandering between -1900 and +9500 Eh. J and K matched the CPU to 5e-6 relative. From minao it converged in 6 iterations. bench_scf_ladder.pynow defaults to--guess minao.scf_df_rhf.pyandscf_df_mp2.pytake--guess.
-
pivoted_cholesky(..., block=, sub_fn=, relax=): block row requests
for the pivoted-Cholesky build (#114).- A round takes the
blocklargest remaining diagonals as candidates and
picks pivots greedily from their exact c × c Schur complement. It
accepts a candidate while its diagonal is at leastrelaxtimes the
largest one outside the round. Withrelax=1that is the one-row
algorithm's pivot sequence (up to ties). - The accepted pivots' rows come from one
rows_fncall, so a device
kernel evaluation (trnsparse.kernel_matmul(X, X[idx], I)) makes one
launch per round. One GEMM gives the Schur rows and one triangular
solve the new columns, in float64 on the host, independent of the
device's reduction order. sub_fn(idx)givesK[idx][:, idx], so only accepted rows are
requested. Without it, every candidate row is.- GP kernel (RBF, ℓ = 0.15, d = 3, rank 1024, CPU), with
block=512, relax=0.5:- n = 10⁵: 26 calls instead of 1024, 0.85 s against 4.1 s;
- n = 10⁶: 61 calls, 11.3 s against 34.6 s, with fp32 kernel rows. Two
host threads; the factor adds 4.5 s ("host64") or 5.2 s
("projected").
- CG iteration counts are unchanged at n = 2×10⁴, 5×10⁴ and 10⁵.
- The default
block=1keeps one row per step. The factor is now
stored row-major internally, so appending a column is stride-1.
- A round takes the
-
PivotedLowRankPreconditioner(..., apply="projected"): an fp32
on-device apply that does not cancel (#114).- Q is an orthonormal basis of L's range, from the Gram matrix LᵀL in
float64 on the host (one n × k × k GEMM; no n × k QR). - The apply is
Q (Σ² + sI)⁻¹ QᵀV + (I − QQᵀ)V/s, with the projection
applied twice: four (n × k) GEMMs on the device, no host round trip. - The single-pass Woodbury form (
"native") leaves an error of about
u·√k·‖V‖ along the captured subspace, which the 1/s weight amplifies.
The second pass removes it. What remains is orthogonal to Q and
perturbs the preconditioner only to second order. - CPU, fp32 operator, R = 33, rank 1024, tol 1e-6,
"host64"against
"projected":- n = 2×10⁴, noise 1e-2: 10 and 10 iterations. Posterior mean against
scipycho_solve: 6.0e-5 and 6.1e-5. - n = 2×10⁴, noise 1e-3: 30 and 30.
- n = 5×10⁴: 20 and 20.
- n = 10⁵: 20 and 20 (column maximum 15 and 15). The posterior means
differ by 6.4e-5. "native"does not converge in 150–200 iterations on the same cases.
- n = 2×10⁴, noise 1e-2: 10 and 10 iterations. Posterior mean against
- Opt-in.
apply="auto"is unchanged:"host64"for a non-float64 L. tests/test_block_neuron.pyholds the device gates: apply accuracy on
the device, CG iterations against"host64", and a build from device
rows.
- Q is an orthonormal basis of L's range, from the Gram matrix LᵀL in
-
cg_block: block CG for many right-hand sides on matrix-free operators (#97).- R independent preconditioned CG recurrences, one per column of an (n, R)
B, driven by ONE operator call A(P) on the whole block per iteration.
The GP exemplar (trnsci/trnsci#109) gets the posterior-mean solve and
every log-det probe solve from the same applications. - Converged columns freeze through
torch.wheremasks (α = β = 0) and the
block keeps its shape. Zero columns return zero, converged at
iteration 0. - The host reads the convergence state only every
check_every
iterations. That changes when the loop stops, never the solution. infohas per-column iterations, the converged and breakdown masks,
the recurrence residual, and a true residual ‖B − A X‖ / ‖B‖ from one
extra call at the end. Report both: on an RBF kernel + 1e-4 I
(n = 2000), fp32 recurrence residuals of 1e-4 had true residuals of
0.05–0.5.return_coeffs=Trueadds per-column α, β histories and r₀ᵀ M r₀.
- R independent preconditioned CG recurrences, one per column of an (n, R)
-
PivotedLowRankPreconditioner(..., apply="auto")applies in float64 on
the host for a non-float64 L. The Woodbury form V − W (Wᵀ V) cancels
(W Wᵀ is within s/λ of the identity on the captured subspace), so in fp32
the applied operator is wrong by up to u·√k·λ/s there. On a GP with
noise 1e-3 (n = 2×10⁴, rank 1024) fp32 preconditioned CG did not
converge in 150 iterations; with the host-float64 apply it converges in
30, against 20 in full float64.apply="native"keeps the old
on-device path. -
cg_block_ir: fp32 innercg_blockinside a float64 host refinement
loop, the same shape asgmres_ir. Returns a float64 host X and
per-outer-step true residuals. With the pivoted preconditioner it reaches
1e-10 relative residual on that matrix where fp32 alone stalls. -
pivoted_cholesky(diag_fn, rows_fn, rank)and
pivoted_lowrank_preconditioner(diag_fn, rows_fn, rank, shift): rank-k
greedy pivoted Cholesky from the diagonal plus one row of K per step. The
preconditioner applies (L Lᵀ + shift I)⁻¹ as two (n × k) GEMMs, through
the low-rank-plus-diagonal inverse identity (k × k factor built once, in
float64 on the host). It also haslogdet()(matrix determinant lemma)
andsample()(probes from N(0, L Lᵀ + shift I)). On the RBF matrices
above, rank 100 cuts CG iterations by about 10×. -
lanczos_tridiag_from_cgandslq_logdet: Lanczos tridiagonals from
CG coefficients, and stochastic Lanczos quadrature for log det(A) over one
cg_blockof probes. Probes are Rademacher, or N(0, P) when preconditioned
(log det P is then exact and only the remainder is estimated). Within 4
standard errors oftorch.linalg.slogdetat n = 1024 with 64 probes. -
scripts/bench_scf_ladder.py: a DF-RHF + DF-MP2 size ladder (#15).- Systems. Linear alkanes C_k H_{2k+2} and k-water clusters, both
synthetic geometries, in cc-pVDZ, aug-cc-pVDZ and cc-pVTZ with
-jkfit. k is picked for each basis to land nearest 500, 1000, 1658
(C40H82 / aug-cc-pVDZ), 2500 and 3500 AOs, which gives 30 systems. --dry-runcomputes no integrals. Per system it gives:- sizes, the fp32 B, PySCF's in-core build memory and B_ia;
- logical cores and chips needed to hold B resident (20 GB per 24 GiB
core); - the window plan: trn2.3xlarge resident, trn2.3xlarge streaming from
host RAM or NVMe, or trn2.48xlarge resident on N chips; - rough per-iteration and MP2 times, scaled from the window-3
measurements.
- Otherwise each system up to
--max-naoruns end to end:- the out-of-core build (time, peak RSS);
- the fp32 SCF (noise-aware convergence;
--solver autopicks
subspacewithrefresh=Noneabove 1200 AOs, as window 3 found); - the float64 E_HF at the SCF orbitals and DF-MP2;
- PySCF DF-RHF + DF-MP2 on the same jkfit basis, with a matched
linear-dependency threshold, up to--ref-max-nao.
- Output is a
RESULTJSON line per system and a markdown table.
--outsaves the rows.
- Systems. Linear alkanes C_k H_{2k+2} and k-water clusters, both
-
examples/scf_df_mp2.py: DF-MP2 on top of the converged DF-RHF (#15).canonical_orbitalsbuilds one Fock matrix at the SCF's occupied orbitals
(streamed J/K, float64 on the host by default) and diagonalises it in the
orthogonalizer's basis.df_mp2formsB_ia^Paux chunk by aux chunk with
trntensor.AuxStream.ao_to_mo, into host memory or a.npymemmap
(bia_path). The energy comes fromtrntensor.mp2_energywhenB_ia
fits one device, else fromtrntensor.mp2_energy_blockedover occupied
blocks, with pairs dealt overdevices.run_mp2chains them and returns E_HF (float64 at the SCF orbitals),
E_corr, E_total and stage times.frozenfreezes the lowest occupied
orbitals.- It uses the SCF's jkfit basis, the same one PySCF's
mp.dfmp2.DFMP2
uses on a density-fitted mean field. - Against PySCF: water/cc-pVDZ fp64 is within 1.1e-9 Eh of E_MP2. A fp32
SCF with a fp32 transform and energy is within 2.7e-7 Eh at C4H10
(tests/test_scf_df_mp2.py). - A fp32 canonical Fock costs 4e-6 Eh there, which is why the float64
host Fock is the default (--fock-on-deviceto override).
-
examples/scf_df_rhf.py: J/K streamed over aux chunks (#15).
DFJK(stream=True)(andrun_scf(jk_stream=..., jk_resident_gb=..., jk_prefetch=...)) hands B totrntensor.AuxStream(trntensor#102).- Aux chunks are under 2 GiB, below the 4 GiB transposed-LHS limit of
aws-neuron-sdk#1457, and dealt round-robin overjk_devices
(neuron:0..3). - Chunks are kept resident up to
DEVICE_RESIDENT_GB= 20 GB per
NeuronCore (one LNC=2 core has 24 GiB) and uploaded every iteration
otherwise. A loader thread works one chunk ahead per device, so the
upload overlaps the kernels on the previous chunk. - J and K come from one pass:
df_coulomb+df_exchangeper chunk, with
each streamed chunk uploaded once. - The default streams an out-of-core
DFStoreB from its memory-mapped
chunk files when trntensor hasAuxStream. In-memory B keeps the
resident blocks as before. - The float64 re-evaluation
energy_at_orbitalsstreams too, so it no
longer needs a float64 copy of B. info["stream"]records the chunk count, width, resident count and the
bytes streamed / wait / load time per iteration.- Flags:
--jk-stream,--resident-gband--jk-deviceson the example;
--jk-stream,--resident-gband--prefetchonbench_scf.py. - J/K are identical to the block path on one and three devices,
all-streamed or all-resident, with or without host pack (CPU tests).
The tests skip withoutAuxStream.
- Aux chunks are under 2 GiB, below the 4 GiB transposed-LHS limit of
-
examples/df_store.py: out-of-core DF integrals (#15). At n_ao 1658
PySCF's in-core build held two float64 copies of B (133 GB, over the 124 GB
host), and window 3 had to go through a 67 GB HDF5 file and a separate fp32
conversion.build_pyscf_storecomputesB = (mn|P) L^{-T}a block of AO shell rows
at a time (PySCFint3c2e,aosym="s2ij", then a triangular solve with
the metric's Cholesky factor, or PySCF's eigen fallback) and writes each
block's packed rows straight into the chunk files. Peak host memory is
one row block (1 GiB by default) plus the metric. It is the same tensor as
df.incore.cholesky_eri(CPU test, 1e-12).- The store is a directory:
meta.json,system.pt(H, S, nocc, e_nuc,
reference) and one C-contiguous(npair, nq).npyfile per aux chunk.
The chunks are 128-multiples under 2 GiB, below the 4 GiB
transposed-LHS limit (aws-neuron-sdk#1457). Each is one sequential read,
and memory-mapped without a copy. DFStoreservesB.shape,B.dtypeandB[:, q0:q1], soDFJK
takes it as is, plus per-chunk loaders for streaming. fp32 by default:
33.4 GB at n_ao 1658.- The synthetic H2-lattice integrals are generated in pair-row blocks too
(h2_lattice(n, store=...)).
-
make_systemgoes out of core by default aboveOUTCORE_GB= 16 GB of
estimated build memory (outcore=True|False|None). Stores go under
store_dir(default$TRNSCI_DF_DIRor~/.cache/trnsci/df), and a
finished store is reused without recomputing anything. With an
out-of-core build the PySCF reference energy is off unless asked for, and
uses PySCF's own DF build.--outcore,--store-dirand--store-dtype
on the example;--outcoreand--store-dironbench_scf.py. -
pyscf:water<k>: a synthetic cluster of k water molecules on a 3.1 Å
cubic lattice with seeded orientations.pyscf_mol/pyscf_sizesgive
the molecule and its basis sizes without computing integrals.
Changed
-
bench_scf_ladder.py --dry-runuses the window-4 Trn2 measurements (trnsci/trnsci#115).- The build is scaled by npair · naux² (the triangular solve), from 1215 s on 2 pinned host threads at n_ao 1658. Before, it was npair · naux from the Mac's 12 threads, about 10× low on the box.
- A streamed layout keeps the per-core budget less three chunks of headroom resident, about 60 GB per chip, not 80. That matches #109's
default_resident_bytes. - DF-MP2 is costed at the measured 5.8e13 multiply-adds/s per chip.
- At water61 / aug-cc-pVDZ the planner now gives 54 GB/it streamed (measured 49.7 under the earlier two-chunk rule), 4.9 s/it (measured ≈ 6), MP2 71 s (measured 69) and a 6290 s build (10051 s measured, sharing the CPUs).
-
float64 policy for the NKI kernels (#89, trnsci/trnsci#35; the same rule
across the trnsci suite). Every trnsolver kernel computes in FP32, and
Trainium computes float64 at FP32 precision on device. Where an FP32
input would run the kernels (eighon the Householder path,
eigh_generalizedthrough it,eigh_randomized,eigh(method="jacobi"),
the auto Jacobi region,occupied_subspace):- backend
auto: float64 underautonow computes in torch at float64
accuracy (previously cast to fp32 on the NKI path).eighand
eigh_generalizedtaketorch.linalg.eigh, the Jacobi entries the torch
Jacobi, the auto Jacobi region the default aten dispatch,
occupied_subspaceits torch filter,eigh_randomizedtorch.matmul.
Affected:eigh/eigh_generalizedfloat64 on the Householder path ran
the FP32 kernels in 0.21.0 (#84; before that, 0.4.0 through 0.20.0, it
gave garbage); this lands in 0.22.0. - backend
nki: float64 runs the FP32 kernels and returns float64, with
oneUserWarningper op (the first call of each op) saying that
precision is reduced to fp32. This now also applies to the Jacobi
kernels andoccupied_subspace(through 0.21.0 they took torch for
float64) and toeigh_randomized(a compile error on Trn2 through
0.21.0). TRNSOLVER_REQUIRE_NKI=1: float64 raisesNotImplementedErroron every
kernel path, under either backend, as trnblas does (trnblas#69). This
takes precedence over thenkicast. Callers of
eigh(method="jacobi"), the auto Jacobi region andoccupied_subspace
with float64 input underTRNSOLVER_REQUIRE_NKI=1now get
NotImplementedErrorwhere through 0.21.0 they got a float64 torch
result;eigh/eigh_generalizedfloat64 under it raise where 0.21.0
ran the FP32 kernels.- Result dtype: always what the pytorch backend returns for the same
inputs, for float32, float64, bfloat16, float16 and mixed-dtype operands
(e.g.eigh_generalizedwith a float64 B), including after the FP32
kernels. - float64 on the
neurondevice is computed on the host underauto.
Device aten computes float64 at fp32 precision (measured on Trn2), so
"torch at float64 accuracy" did not hold for device-resident input.
Every public op now copies a float64 / complex128 operand on the
neurondevice to the host, computes there and returns the result on
the original device in float64 / complex128, with oneUserWarningper
op ("float64 on the neuron device is computed on the host for float64
accuracy (device arithmetic is fp32); pass float32 to stay on device").
TRNSOLVER_FP64_ON_DEVICE=1keeps device aten (fp32 precision) for
callers who prefer speed. Host-resident float64 and backendsnki/
pytorchare unchanged. UnderTRNSOLVER_REQUIRE_NKI=1a float64 /
complex128 operand on theneurondevice now raises
NotImplementedErrorat every public op (backendsautoandnki,
no host copy, ahead ofTRNSOLVER_FP64_ON_DEVICE=1). Before, the routes
with no kernel (solve_spd,inv_spd,pinv,cg,gmres, ...) ran
device aten at fp32 precision with no error. One decorator
(nki.dispatch._fp64_host_guard) holds the rule; the preconditioner
constructors (jacobi_/block_jacobi_/ssor_preconditioner), which
return closures, use_fp64_host_preconditioner: the closure computes on
the host and returnszonr's device. The block CG routes (#97)
follow the same rule:cg_blockis guarded;pivoted_choleskybuilds
in float64 on the host for every input (#117, one row or batched with
rows_fn/sub_fn), so a device-resident float64 diagonal needs no
extra host route and L returns to its device; and
PivotedLowRankPreconditioner'sapply="auto"andapply="projected"
(#117, an on-device apply) pick"host64"for a float64 L on the device
(oneUserWarning).cg_block_iralready refines in float64 on the host.
The library has no complex kernels; complex input keeps its aten / torch
routes (#65). Paths where an FP32 input would not run a kernel either (the
aten cutover, the XLA lineage for Jacobi) are unchanged.
- backend
-
examples/scf_df_rhf.py: a noise-aware convergence test for fp32
(#15).run_scf(conv="auto"|"energy"|"density");"auto"keeps the
energy test in float64 and uses"density"otherwise."density"stops when the commutator rms(FPS − SPF) <d_toland the
density change rms(P_k − P_{k−1}) <p_tol(fp32 defaults 1e-5 and
1e-5). The energy only has to be inside its own rounding noise:
|dE| < max(e_tol,e_noise_mult· σ_E), with σ_E = ε · ½ Σ|P||H + F|
computed on the device each iteration, in the same single host copy.- Why: at |E| = 1562 Eh one fp32 ulp is 1.9e-4 Eh, and the energy sum
rounds above that, so a fixed energy delta (the old relative 2e-7 test)
sat at its noise floor at n_ao 1658. - On the CPU it converges as fast as or faster than the energy test, with
the float64 energy at the fp32 orbitals within 1.4e-8 Eh of the fp64
run (h2-lattice:16/32, benzene/cc-pVDZ). With ±3e-5 Eh of injected
energy jitter the energy test never stops and the density test does
(test). - Both norms are taken in the orthonormal basis of the kept subspace,
Xᵀ(FPS − SPF)XandXᵀS dP S X. In the AO basis, with functions dropped
by the orthogonalizer, the commutator keeps a floor along the dropped
directions: 4.7e-7 at a converged float64 C12H26 / aug-cc-pVDZ
(canonical 1e-6), which never passed the float64 1e-7 test and ran to
max_iter. In fp32, X's 1/sqrt(s_min) amplified the AO dP noise to
4e-5. Now that system converges in 33 iterations in float64. - The commutator threshold is noise-aware too:
max(d_tol,d_noise_mult· σ_d) with σ_d = ε max|F| max|X|. The fp32
floor there is 1.3e-4 against σ_d = 1.2e-4, and the float64 energy at
those orbitals is 4e-5 Eh above fp64. That is the fp32 conditioning
limit window 3 met at n_ao 1658. info["history"]holds per-iterationdE,err_rmsanddp_rms;
info["e_noise"]the last σ_E.--convon the example and
bench_scf.py.
-
examples/scf_df_rhf.py:DFJKpacks P and unpacks J on the host above
1e6 pairs (#87). At n_ao = 1658 (npair 1.4e6) the two device gathers in
DFJK.j(index_selectwith npair and n² indices) compiled for over
40 min each, so window 3 patched them out in the driver. Now
DFJK(host_pack=None)(andrun_scf(jk_host_pack=...),
bench_scf.py --host-pack auto|on|off) does that by default off the CPU
when npair >HOST_PACK_NPAIR= 1e6: an 11 MB copy each way per iteration
at that size. The J values are bit-identical to the device-gather path
(CPU test).
Fixed
-
run_scfreleases its device integrals before it returns (trnsci/trnsci#115).
The DFJK's resident chunks (or blocks) were left for the garbage collector.
A secondrun_scfon the same system, such as the ladder's--warmup-itersrun
followed by the timed run, then uploaded a second copy of B while the first was
still held. At alkane43 / cc-pVTZ over 4 cores (19.2 GB per core), the second
upload failed with NRT_RESOURCE. The newDFJK.close()is called at the end of
run_scfand after the canonical Fock build inscf_df_mp2.py. -
DIIS history padded to a multiple of 16384 elements (trnsci/trnsci#115). On Trn2 the
(space, n²) @ (n²,)GEMV for the DIIS row did not finish compiling in 21 min at n = 1640
(water40 / aug-cc-pVDZ; walrusremat_optimization). Two exclusive slots and two
single-core runs timed out inside it. Padded with zeros to 2,703,360 elements, it
compiles in 40 s. Dot products and the extrapolated Fock are unchanged. -
df_mp2on a NeuronCore takes the blocked energy unless trntensor's row kernel fits (trnsci/trnsci#115).
Before, a B_ia under 20 GB always went totrntensor.mp2_energy. When the row kernel
doesn't fit SBUF, that call runs aten einsums summed into an fp32 scalar. At C40H82 /
aug-cc-pVDZ on one core it took 222 s, against 184 s formp2_energy_blocked,
and landed 3.8e-6 Eh off it. At alkane43 / cc-pVTZ it took 531 s against 258 s, 5.2e-6 Eh
off. The blocked route sums per-pair partials in float64. -
Streamed J/K: the default resident budget leaves room for chunks in flight (trnsci/trnsci#115).
If some chunks stream, the default per-device resident budget is now
DEVICE_RESIDENT_GBminus (prefetch + 2) chunks: the uploads in flight plus one
chunk ofdf_exchangeworking memory. Before, it was the full 20 GB, and a 24 GiB
Trn2 core ran out of memory (NRT_RESOURCE) in the second SCF iteration in two cases:
C40H82 / aug-cc-pVDZ on one core at 20 GB resident (16 GB ran), and
alkane69 / cc-pVDZ (nocc 277) at 15.7 GB (13 GB converged in 6 iterations).
Fully resident layouts (B fits the budget) are unchanged. -
df_storerow blocks no longer overflow on int32ao_loc(trnsci/trnsci#115).
PySCF'sao_locis int32, so the block-size test3 · rows · naux · 8wrapped
past 2³¹ once one shell pushed a block from underblock_bytesto over 2 GiB.
That happens at cc-pVTZ, n_ao ≈ 2500. The test then passed when it should have
stopped. At alkane43 / cc-pVTZ (n_ao 2522) the largest row block came out at 13.0 GB
of float64 int3c2e, about 39 GB with its solve copies, against the 1 GiB budget,
and the box build was among the processes OOM-killed. With Python ints the sizes give 495 blocks of
≤ 0.61 GB (previously 344). -
Host float64 J/K over an fp32 store no longer raises at n_ao ≳ 2050 (trnsci/trnsci#115).
The canonical Fock inscf_df_mp2.pystreams the fp32 store in float64 on the host.
The store's 128-column chunks double to more than 2 GiB there, soDFJKre-split B
under the device's 2 GiB bound. At n_ao 2522 not even 128 float64 columns fit, and
aux_chunk_widthraised. On the host the store's own chunks are now used as they
are, since that bound applies only to the device matmul. -
float64, integer and bool operands reached the FP32 NKI kernels (#83,
trnsci/trnsci#35). One dtype table (KERNEL_DTYPESin
trnsolver/nki/dispatch.py) now lists what each kernel takes, and
_launch(native and XLA) and the new_simulate(simulator) raise
TypeErrorfor anything else, so no kernel is reached with another dtype.
The wrappers route first with one guard (_kernel_dtype/
_kernel_operands), which applies the float64 policy above. Integer and
bool input takes torch (which raises, as the pytorch backend does), or
raisesNotImplementedErrorunderTRNSOLVER_REQUIRE_NKI=1. float16 and
bfloat16 are cast to FP32 (lossless) and restored. Affected: every release
with the kernels. -
cgdropped the imaginary part of complex input (#100). Its inner
products werefloat(u.dot(v)): unconjugated, and cast to real, so a
complex Hermitian positive definite system iterated on the wrong
quantities and returned a wrongx(or ran tomaxiter) with only a
UserWarning. A complexAwith a realbalso lostA's imaginary
part.cgnow uses conjugated inner productsr^H z,p^H A p
(accumulated in complex128 / float64) and promotes a realbto complex
for a complexA. Real input is unchanged. Affected: every release
through 0.21.0. -
eigh(method="jacobi")raised on complex and 0×0 input;solve_spd
raised on a batch of vector right-hand sides (#79). Jacobi is real-only:
complex Hermitian input (NotImplementedError: "ge_cpu") now takes the
defaulteighpath, astorch.linalg.eighdoes. An n = 0 input (any
batch) returns emptyw,Vinstead of failing to reshape.solve_spd
now reads B (, n) withB.shape == A.shape[:-1]as a batch of vectors,
followingtorch.linalg.solve, where it raised before. The one shape that
already worked, last batch dim of A equal to n, keeps its old (, n, k)
reading. Affected:eigh(method="jacobi")0.17.0 through 0.21.0;
solve_spdevery release through 0.21.0. -
cggave a wrong gradient with respect toA;schurdetached
silently;gmresbackward raised (#76).cgread its step sizes as
Python floats, so autograd differentiated a fixed polynomial inA
(relative error 0.55 at n = 5, 7.2 at n = 20).cgandgmreswith a
tensorAnow differentiate implicitly: backward solves the adjoint
systemA^H λ = ∂xwith the same solver, giving∂b = λand
∂A = -λ x^H(one extra solve per backward; double backward works).
gmreswith a callableAraisesRuntimeErrorwhenborx0
requires grad.schurnow raisesRuntimeErrorwhenArequires grad
in grad mode, instead of returningQandTthat contributed zero
gradient. Affected: every release through 0.21.0.