vibe-qcDocumentation

Restricted DF-MP2 factor products (#806)

Native restricted FP64 MP2 uses the source, auxiliary space and active orbital domains returned by the AO-to-MO transform. MP2 binds the two column selections to a common reference invocation with independent identities and their actual frozen/occupied offsets. The resident view has axes [P,i,a] and strides [nocc*nvir,nvir,1]. The checked binary program contracts Pia,Pjb -> iajb. Its real product uses the same source twice under one read lease. A stale epoch, expired owner, wrong source stamp or different orbital selection refuses execution. A completed window owns its private row-major result and its budget reservation.

The kernel implements only the auxiliary sum. Restricted MP2 evaluates the direct and exchanged entries with the denominator and OS/SS accumulation of Szabo and Ostlund, eq. 6.71, then applies the caller’s spin scaling. This uses the separation of equations and binary operations in Hirata, TCE and explicit orbital spaces in TAMM, sections III-IV.

Execution and admission

Incore requests the full pair matrix. Direct and disk use at most nocc-1 occupied rows per slab when there are multiple occupied orbitals. With one occupied orbital they use a virtual row and its exchanged column. Disk keeps its private sequential row-major scratch file and reads exchanged columns in the one-occupied case. The file owner removes its private directory on return or exception. The default slab target is 64 MiB with a one-occupied-row floor.

The method retains the earlier conservative DF preparation ceiling. The transform has its own measured peak. Its metric, AO panels and auxiliary basis leave scope before the product. The product ledger imports the active coefficient and energy arrays, transformed factor storage once, view and IR metadata, the entire requested window and aligned pack buffers. Disk adds its stream controls and an 8 KiB buffer shared across the separate write and read phases. Slab selection uses remaining bytes after charging resident storage. Method telemetry reports the maximum across the three phases. Tracked bytes describe method storage. Process RSS and filesystem cache have separate lifetimes.

One synchronous CPU worker reads the resident affine factor once per window. Behind this logical visit, Eigen packs and rereads matrix blocks. There is no per-P descriptor list or copy of all transformed factors. The registered GEMM uses the bounded Eigen kernel from #805. Ordered mode sums each entry in ascending auxiliary order. The method permits reassociated FP64. A square diagonal window of at least 128 pairs computes upper block rows with 64-pair tiles and copies completed off-diagonal blocks to their transposes. The ordered and rectangular paths compute every entry directly. FP32-option incore and slab routes retain their predecessor precision behavior. UMP2, CC and triples have separate migrations.

Fixed-factor benchmark

Compile benchmarks/tensor_mp2_product.cpp with the transform ADR flags. Both profiles used one arm64 CPU worker, Eigen 5.0.1 and 21 rotated samples. Columns are median microseconds for fresh results. Eigen and Accelerate are the predecessor profiles. Bounded uses the registered Eigen leaf even in the Accelerate build. Raw times exclude planner, leases and allocations. The strong reference is the fastest measured predecessor, noalias, explicitly packed and, for square matrices, triangular rank-update path in the Accelerate build. Measurements were taken on a shared machine.

P, occupied, virtual

Occupied rows

Eigen old

Accelerate old

Strong reference

Bounded

Raw bounded

Tracked peak bytes

12, 2, 2

2

0.46

0.29

0.29

1.25

0.21

3,480

12, 2, 2

1

0.21

0.25

0.25

1.67

0.17

3,224

83, 4, 19

4

39.96

7.42

7.42

45.38

45.33

164,408

83, 4, 19

1

13.96

2.79

2.79

16.71

15.17

106,712

95, 8, 17

8

141.17

19.96

19.96

122.88

125.42

319,064

95, 8, 17

1

24.08

4.13

3.83

25.25

24.58

165,528

129, 11, 23

11

655.71

224.96

134.67

489.67

500.33

840,904

129, 11, 23

1

77.46

25.38

25.38

100.63

99.54

354,392

The largest full product took 530 us in the Eigen-only build. The blocked symmetric candidate beat the original bounded rectangle on this shape in both profiles. Accelerate’s rank update was faster still. Its opaque workspace requires separate qualification. First-plan cost across the Accelerate cases was 0.50-1.88 us. On the largest full/slab cases the explicit-pack baseline spent 10.96/1.88 us copying inputs. The registered path writes the final layout directly and its internal packing is included in raw GEMM time. Full and slab packs used 65,568/44,576 bytes including alignment. The separate temporary-file creation, unbuffered block write/read and close benchmark took 532/402 us. Complete method disk timings below include its own storage policy. Maximum difference from the fixed-factor predecessor was 4.27e-14.

Numerical controls

The native contract fixture checks every direct and exchanged entry against explicit auxiliary sums, including full symmetric blocks, frozen offsets, nonzero-origin slabs, unequal and equal-sized independent orbital spaces. A cap admitting exactly one occupied row processes the full sequence. One byte below refuses before a factor visit. Other controls cover invalid provider storage, layout and domain bindings, writer conflicts, expired leases, stale epochs, overflow and injected pack allocation failure. A private output and its reservations are released after failure. An Eigen-allocation-disabled test exercises the symmetric leaf with supplied packs, including the partial edge block.

The vq controls ran exact restricted HF, unscaled RI-MP2, a 64 MiB method request and one worker. CPython 3.14.10 called the installed native RHF for converged orbitals (energy/gradient thresholds 1e-13/1e-10). Separate native executables then called production run_mp2 on identical references with the new product and with the predecessor from 659c834d. The numerical limits recorded before submission were 2e-11 for transformed factors, 1e-11 Eh for same-reference OS/SS and cross-mode agreement, and 2e-7 Eh for each matched ORCA energy. Runtime hashes and queue receipts are on #806.

System

HF (Eh)

OS (Eh)

SS (Eh)

Total (Eh)

ORCA total (Eh)

H4, STO-3G

-2.209069888186

-0.029472383917

-0.000150986978

-2.238693259082

-2.238693259091

Water, def2-SVP

-75.960973265765

-0.150551072374

-0.050526811494

-76.162051149633

-76.162051122032

Water, def2-TZVP

-76.058984956195

-0.191727754825

-0.062259972875

-76.312972683896

-76.312972678207

H2, def2-SVP

-1.128861143900

-0.026381723389

0 to roundoff

-1.155242867289

-1.155242867804

H4 reuses the geometry and ORCA comparison in the transform ADR. Both water controls used O at the origin, H at (0, +/-1.43, 1.11) bohr, one frozen core orbital and matching def2 correlation-fitting bases. Their active dimensions were 4 by 19 and 4 by 38. The larger water case exercised the blocked symmetric product. H2 at 1.43 bohr tested the single-occupied disk traversal with zero frozen orbitals and def2-SVP-RIFIT. All systems are neutral singlets. ORCA 6.1.1 used VeryTightSCF, the same orbital/fitting bases and occupations, and a separate unit-OS/zero-SS projection. Water ORCA OS/SS were -0.150551054/-0.050526802 and -0.191727751/-0.062259971 Eh respectively, with SS obtained by subtracting printed energies. H2 gave -0.026381724/0 Eh in its OS/SS projections. The four external comparisons passed the preset HF, OS, SS and total limits. The runtime evidence applies to the tested executables and restricted FP64 route.

Complete MP2 medians below are milliseconds over five calls on a fixed converged HF reference. Each call reconstructs its own DF factors, transforms, products and energy. Each cell gives predecessor / migrated time. These shared-machine measurements include scratch operations and exclude HF.

Case

Incore

Direct

Disk

Method workspace bytes

Disk extent bytes

H4

2.32 / 2.44

2.44 / 2.23

2.83 / 2.60

104,064

128

Water SVP

3.55 / 3.56

3.50 / 3.47

4.21 / 4.09

1,544,064

46,208

Water TZVP

8.39 / 8.60

7.91 / 8.46

8.75 / 9.86

6,556,264

184,832

H2

2.52 / 2.43

2.23 / 2.28

2.66 / 2.90

109,216

648

The earlier unbuffered stream took 38.6 ms for the TZVP disk case. Sharing a charged 8 KiB buffer reduced that to 9.86 ms. The same run still measured a 1.11 ms disk regression versus the predecessor. The intact scratch extent and empty private scratch directory were checked for every case and mode. Across the four cases the maximum independent transformed-factor error was 2.99e-16, and OS/SS agreed with the independent factors and MP2 sums within 2.78e-17 Eh.

A neutral water dimer tested memory-mode selection under a 1,100,000-byte cap. The second water translates the first by (7,0,0) bohr. Both programs used def2-SVP orbitals and STO-3G as the Coulomb fitting basis specifically for this capacity control. All ten occupied orbitals were active and there were 38 virtuals. The full output alone needs 1,155,200 bytes. Explicit incore refused, auto selected direct, and both direct and disk reproduced the admitted 64 MiB incore result within 1e-11 Eh per spin component. Peak method workspace was 1,055,328 bytes. Disk wrote exactly 1,155,200 bytes. A separate 16 KiB process file-size limit induced a scratch write failure after creation and the private scratch directory was removed on exception.

Dimer HF/OS/SS/total were -151.919876027570, -0.184194804635, -0.135396014373, -152.239466846578 Eh. Matched ORCA values were -151.919876027374, -0.184194766, -0.135395988, -152.239466781042 Eh. This comparison tests the same small auxiliary basis in both programs.