Skip to content

trnsparse 0.4.1 — screened Fock + PySCF integration examples

Choose a tag to compare

@scttfrdmn scttfrdmn released this 15 Apr 01:35
· 20 commits to main since this release

Closes #6 and #13. No API changes, no kernel changes — v0.4.0 users who don't need the examples can stay on v0.4.0.

Added

  • `examples/sparse_fock.py` — rewritten around v0.4.0's `screened_spmm`. Three paths side-by-side on the same inputs:

    1. v0.1.x unfused flow (`schwarz_bounds → screen → from_dense → spmm`)
    2. v0.4.0 fused `screened_spmm` (one call)
    3. Full Fock build — coulomb from path 2 contracted against MO coefficients via `trnblas.gemm` for `F_MO = C.T @ J @ C`. Optional dep on trnblas; falls back to `torch.matmul` otherwise.

    On a 50-basis synthetic system, the fused path is ~130× faster than the unfused (dominated by eliminating the Python `from_dense` CSR construction).

  • `examples/pyscf_bridge.py` (new) — optional PySCF-driven demo. Builds H₂O (or benzene, or H₂), extracts real AO ERIs via `mol.intor("int2e")`, feeds the `(μμ|μμ)` diagonal into `schwarz_bounds` + `screened_spmm` against a mock density matrix. Requires `pip install pyscf`; tests skip cleanly if not available.

  • `tests/test_examples.py` — 2 CPU smoke tests plus a PySCF-gated test. Exercises the unfused + fused paths end-to-end and asserts parity (`atol=1e-6`).

Validation

  • 51 CPU tests pass (49 existing + 2 new example tests); 1 PySCF test skips cleanly.
  • No hardware or simulator regression.