Skip to content

v0.22.0 — block CG + low-rank preconditioners, streamed large-basis DF-RHF/DF-MP2, fp64 policy

Choose a tag to compare

@scttfrdmn scttfrdmn released this 03 Nov 21:40
· 48 commits to main since this release
v0.22.0
56aa203

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 a trnsolver::
    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's Kernel.__call__,
    which rebuilds the torch handle on every call, plus the torch.library
    layer. dispatch._launch now calls a torch_neuronx.wrap_nki handle built
    once per kernel; static= arguments (the Jacobi onezero) get the op
    body's int(). On trn2 (LNC=2), a matvec launch drops from 0.121 to
    0.032 ms of issue time (e2e 0.203 to 0.130 ms) and a 128x128x32 matmul
    from 0.123 to 0.032 ms (e2e 0.196 to 0.117 ms). eigh itself 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 folded occupied_subspace pass (subspace_step) for now.
    TRNSOLVER_NKI_EAGER_HANDLE=0 turns this off;
    scripts/bench_eager_handle.py measures 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 subspace or orth, 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.py now defaults to --guess minao. scf_df_rhf.py and scf_df_mp2.py take --guess.
  • pivoted_cholesky(..., block=, sub_fn=, relax=): block row requests
    for the pivoted-Cholesky build (#114).

    • A round takes the block largest remaining diagonals as candidates and
      picks pivots greedily from their exact c × c Schur complement. It
      accepts a candidate while its diagonal is at least relax times the
      largest one outside the round. With relax=1 that is the one-row
      algorithm's pivot sequence (up to ties).
    • The accepted pivots' rows come from one rows_fn call, 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) gives K[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=1 keeps one row per step. The factor is now
      stored row-major internally, so appending a column is stride-1.
  • 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
        scipy cho_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.
    • Opt-in. apply="auto" is unchanged: "host64" for a non-float64 L.
    • tests/test_block_neuron.py holds the device gates: apply accuracy on
      the device, CG iterations against "host64", and a build from device
      rows.
  • 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.where masks (α = β = 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.
    • info has 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=True adds per-column α, β histories and r₀ᵀ M 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 inner cg_block inside a float64 host refinement
    loop, the same shape as gmres_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 has logdet() (matrix determinant lemma)
    and sample() (probes from N(0, L Lᵀ + shift I)). On the RBF matrices
    above, rank 100 cuts CG iterations by about 10×.

  • lanczos_tridiag_from_cg and slq_logdet: Lanczos tridiagonals from
    CG coefficients, and stochastic Lanczos quadrature for log det(A) over one
    cg_block of 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 of torch.linalg.slogdet at 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-run computes 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-nao runs end to end:
      • the out-of-core build (time, peak RSS);
      • the fp32 SCF (noise-aware convergence; --solver auto picks
        subspace with refresh=None above 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 RESULT JSON line per system and a markdown table.
      --out saves the rows.
  • examples/scf_df_mp2.py: DF-MP2 on top of the converged DF-RHF (#15).

    • canonical_orbitals builds 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_mp2 forms B_ia^P aux chunk by aux chunk with
      trntensor.AuxStream.ao_to_mo, into host memory or a .npy memmap
      (bia_path). The energy comes from trntensor.mp2_energy when B_ia
      fits one device, else from trntensor.mp2_energy_blocked over occupied
      blocks, with pairs dealt over devices.
    • run_mp2 chains them and returns E_HF (float64 at the SCF orbitals),
      E_corr, E_total and stage times. frozen freezes 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-device to override).
  • examples/scf_df_rhf.py: J/K streamed over aux chunks (#15).
    DFJK(stream=True) (and run_scf(jk_stream=..., jk_resident_gb=..., jk_prefetch=...)) hands B to trntensor.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 over jk_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_exchange per chunk, with
      each streamed chunk uploaded once.
    • The default streams an out-of-core DFStore B from its memory-mapped
      chunk files when trntensor has AuxStream. In-memory B keeps the
      resident blocks as before.
    • The float64 re-evaluation energy_at_orbitals streams 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-gb and --jk-devices on the example;
      --jk-stream, --resident-gb and --prefetch on bench_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 without AuxStream.
  • 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_store computes B = (mn|P) L^{-T} a block of AO shell rows
      at a time (PySCF int3c2e, 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) .npy file 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.
    • DFStore serves B.shape, B.dtype and B[:, q0:q1], so DFJK
      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_system goes out of core by default above OUTCORE_GB = 16 GB of
    estimated build memory
    (outcore=True|False|None). Stores go under
    store_dir (default $TRNSCI_DF_DIR or ~/.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-dir and --store-dtype
    on the example; --outcore and --store-dir on bench_scf.py.

  • pyscf:water<k>: a synthetic cluster of k water molecules on a 3.1 Å
    cubic lattice with seeded orientations. pyscf_mol / pyscf_sizes give
    the molecule and its basis sizes without computing integrals.

Changed

  • bench_scf_ladder.py --dry-run uses 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 (eigh on the Householder path,
    eigh_generalized through it, eigh_randomized, eigh(method="jacobi"),
    the auto Jacobi region, occupied_subspace):

    • backend auto: float64 under auto now computes in torch at float64
      accuracy (previously cast to fp32 on the NKI path).
      eigh and
      eigh_generalized take torch.linalg.eigh, the Jacobi entries the torch
      Jacobi, the auto Jacobi region the default aten dispatch,
      occupied_subspace its torch filter, eigh_randomized torch.matmul.
      Affected: eigh / eigh_generalized float64 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
      one UserWarning per op
      (the first call of each op) saying that
      precision is reduced to fp32. This now also applies to the Jacobi
      kernels and occupied_subspace (through 0.21.0 they took torch for
      float64) and to eigh_randomized (a compile error on Trn2 through
      0.21.0).
    • TRNSOLVER_REQUIRE_NKI=1: float64 raises NotImplementedError on every
      kernel path
      , under either backend, as trnblas does (trnblas#69). This
      takes precedence over the nki cast. Callers of
      eigh(method="jacobi"), the auto Jacobi region and occupied_subspace
      with float64 input under TRNSOLVER_REQUIRE_NKI=1 now get
      NotImplementedError
      where through 0.21.0 they got a float64 torch
      result; eigh / eigh_generalized float64 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_generalized with a float64 B), including after the FP32
      kernels.
    • float64 on the neuron device is computed on the host under auto.
      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
      neuron device to the host, computes there and returns the result on
      the original device in float64 / complex128, with one UserWarning per
      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=1 keeps device aten (fp32 precision) for
      callers who prefer speed. Host-resident float64 and backends nki /
      pytorch are unchanged. Under TRNSOLVER_REQUIRE_NKI=1 a float64 /
      complex128 operand on the neuron device now raises
      NotImplementedError at every public op
      (backends auto and nki,
      no host copy, ahead of TRNSOLVER_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 returns z on r's device. The block CG routes (#97)
      follow the same rule: cg_block is guarded; pivoted_cholesky builds
      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's apply="auto" and apply="projected"
      (#117, an on-device apply) pick "host64" for a float64 L on the device
      (one UserWarning). cg_block_ir already 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.
  • 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_tol and 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)X and Xᵀ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-iteration dE, err_rms and dp_rms;
      info["e_noise"] the last σ_E. --conv on the example and
      bench_scf.py.
  • examples/scf_df_rhf.py: DFJK packs 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_select with npair and n² indices) compiled for over
    40 min each, so window 3 patched them out in the driver. Now
    DFJK(host_pack=None) (and run_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_scf releases its device integrals before it returns (trnsci/trnsci#115).
    The DFJK's resident chunks (or blocks) were left for the garbage collector.
    A second run_scf on the same system, such as the ladder's --warmup-iters run
    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 new DFJK.close() is called at the end of
    run_scf and after the canonical Fock build in scf_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; walrus remat_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_mp2 on a NeuronCore takes the blocked energy unless trntensor's row kernel fits (trnsci/trnsci#115).
    Before, a B_ia under 20 GB always went to trntensor.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 for mp2_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_GB minus (prefetch + 2) chunks: the uploads in flight plus one
    chunk of df_exchange working 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_store row blocks no longer overflow on int32 ao_loc (trnsci/trnsci#115).
    PySCF's ao_loc is int32, so the block-size test 3 · rows · naux · 8 wrapped
    past 2³¹ once one shell pushed a block from under block_bytes to 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 in scf_df_mp2.py streams the fp32 store in float64 on the host.
    The store's 128-column chunks double to more than 2 GiB there, so DFJK re-split B
    under the device's 2 GiB bound. At n_ao 2522 not even 128 float64 columns fit, and
    aux_chunk_width raised. 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_DTYPES in
    trnsolver/nki/dispatch.py) now lists what each kernel takes, and
    _launch (native and XLA) and the new _simulate (simulator) raise
    TypeError for 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
    raises NotImplementedError under TRNSOLVER_REQUIRE_NKI=1. float16 and
    bfloat16 are cast to FP32 (lossless) and restored. Affected: every release
    with the kernels.

  • cg dropped the imaginary part of complex input (#100). Its inner
    products were float(u.dot(v)): unconjugated, and cast to real, so a
    complex Hermitian positive definite system iterated on the wrong
    quantities and returned a wrong x (or ran to maxiter) with only a
    UserWarning. A complex A with a real b also lost A's imaginary
    part. cg now uses conjugated inner products r^H z, p^H A p
    (accumulated in complex128 / float64) and promotes a real b to complex
    for a complex A. 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
    default eigh path, as torch.linalg.eigh does. An n = 0 input (any
    batch) returns empty w, V instead of failing to reshape. solve_spd
    now reads B (, n) with B.shape == A.shape[:-1] as a batch of vectors,
    following torch.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_spd every release through 0.21.0.

  • cg gave a wrong gradient with respect to A; schur detached
    silently; gmres backward raised (#76).
    cg read its step sizes as
    Python floats, so autograd differentiated a fixed polynomial in A
    (relative error 0.55 at n = 5, 7.2 at n = 20). cg and gmres with a
    tensor A now differentiate implicitly: backward solves the adjoint
    system A^H λ = ∂x with the same solver, giving ∂b = λ and
    ∂A = -λ x^H (one extra solve per backward; double backward works).
    gmres with a callable A raises RuntimeError when b or x0
    requires grad. schur now raises RuntimeError when A requires grad
    in grad mode, instead of returning Q and T that contributed zero
    gradient. Affected: every release through 0.21.0.