Exact Export Internals#
Use Selected Route, External PySCF References and the YAML input reference to configure an export. This page owns the memory model, scratch lifetimes, numerical screening and acceptance coverage behind those controls.
The exporter uses exact Coulomb integrals with numerical screening, not a density-fitted export. Scheduling changes preserve the retained MO space, Hamiltonian, requested SO/property providers and ordinary materialized HDF5 contract. These implementation notes and small tests do not certify large-Ce accuracy, resource use, performance or downstream capacity.
Documentation Validation Scenarios#
These scenarios specify the documentation-only verification before it is run. They do not add or change numerical tests or introduce a BDD runtime.
ID |
Purpose and existing overlap |
Distinct observable |
|---|---|---|
DOC-EXACT-01 |
Product config tests cover forwarding, not instructions a reader can follow |
YAML/API guidance agrees with source on units, defaults, retained MOs, optional caps/slabs and restart behavior |
DOC-EXACT-02 |
Product lifetime tests do not check hosted navigation |
Deep details and both existing feature inclusions are reachable from functional pages and the primary toctree; old section anchors remain usable |
DOC-EXACT-03 |
Numerical parity does not validate claims about supported modes or resources |
No unsupported export switch, automatic MO truncation, hard-RSS promise or CI/production certification is introduced |
DOC-EXACT-04 |
Source review does not detect Sphinx reference or link errors |
Strict HTML build and linkcheck report new internal failures separately from external-site policy failures |
DOC-EXACT-05 |
SLAB-03 covers runtime ranges and lifetime, not the illustrative documentation arithmetic |
Single-file float64 payloads, decimal GB and sequential build counts agree with the formula without allocating integral arrays or running quantum chemistry |
Feature: Usable exact-export documentation without implementation changes
Scenario: DOC-EXACT-01 Configure an export from the functional pages
Given the supported YAML schema and public reference API
When the configuration fragments and operational warnings are reviewed
Then their defaults, units, route selection and failure guidance match source
And no calculation needs to run to validate the documentation
Scenario: DOC-EXACT-02 Reach the engineering details
Given the functional pages and primary documentation toctree
When their links and the previous public section anchors are followed
Then formulas, lifetimes, screening and existing coverage maps remain reachable
Scenario: DOC-EXACT-03 Keep promises within the implemented scope
Given exact export and the existing HDF5 and consumer contracts
When supported modes and limitations are reviewed
Then memory controls do not imply DF export, MO truncation or a hard RSS cap
And whole-process admission is distinguished from full-route routing hints
Scenario: DOC-EXACT-04 Build and check the hosted pages
Given only the intended documentation changes
When strict Sphinx HTML and the documentation linkcheck target run
Then build results and link diagnostics are retained
And external HTTP policy failures are distinguished from broken internal links
Scenario Outline: DOC-EXACT-05 Check the illustrative slab estimates
Given illustrative dimensions N=1000, M=500, C=100 and A=20
And a first-side width <b>, with None resolving to C+A
When only integer payload and sequential build-count arithmetic is evaluated
Then the largest single half-file payload is <bytes> bytes or <GB> decimal GB
And sequential consumption requires <builds> half-transform builds
And these are not measured RSS, total peak disk or wall-time estimates
Examples:
| b | bytes | GB | builds |
| 16 | 25625600000 | 25.6256 | 8 |
| 32 | 51251200000 | 51.2512 | 4 |
| 64 | 102502400000 | 102.5024 | 2 |
| None | 192192000000 | 192.1920 | 1 |
Screened Direct J/K#
The shared-budget J/K path uses functional hf.get_jk with one reusable VHF
optimizer for the molecule/basis/operator. Integral bounds and the libcint
optimizer are reused; density bounds are refreshed for each actual batch. This
is the exact Coulomb route with numerical screening, not DF or a call through
a density-fitted mean-field object.
The internal screening tolerance is 1e-14, not an additional user control.
Record the actual tolerance and validate full J/K slices, Fock, pair terms and
scalar energy on identical fixed MOs against an independent unscreened oracle
and a stricter-threshold check. The threshold is not a global bound on
accumulated MO-integral or energy error. Small-molecule parity does not certify
large-Ce accuracy, memory use or speedup; end-to-end and measured resource
acceptance remain separate gates.
Exact Half-Transform Slabs#
HalfTransformSource in pyscf2mppt/integrals/half_transform.py supplies rows
to the existing second-half contractions while owning one monolithic or slab
scratch file. For N AOs, core count C, selected count A, full retained
count M and requested first-side width b, the half-transform payload is at
most:
8 * min(b, C+A) * (M-C) * T(N) bytes, where T(N) = N(N+1)/2
The monolithic payload is 8 * (C+A) * (M-C) * T(N) bytes. These formulas
exclude HDF5 overhead and every other file. Final pair-packed lengths remain
those in the public block contract.
Each first-side MO contributes (M-C) * T(N) float64 values, at eight bytes
each. Thus the largest single half-file payload grows linearly with b up to
C+A; it does not estimate process RSS or the whole export’s peak disk use.
For the illustrative N=1000, M=500, C=100, A=20 case, T(N)=500500 and
each first-side MO contributes 1601600000 bytes, or 1.6016 decimal GB.
For sequential row consumption, the number of half-transform builds is
ceil((C+A)/b). The source keeps b fixed, clips each end to
stop = min(start+b, C+A) and calls ao2mo.outcore.half_e1 separately for
each slab. None resolves to b=C+A; an explicit b >= C+A also needs only
one build. Smaller widths repeat more AO integral passes; larger widths can
therefore be faster, but build counts are not wall-time multipliers and do not
guarantee a speedup.
The first slab is built before ERI result allocation. On each later slab, the
old half file is closed and removed before the next is generated; the reusable
row buffer remains live. Actual final ranges can be shorter than b. Context
manager cleanup handles ordinary closure and exceptions without introducing
tile resume or a retry/recovery framework.
Only the half-transform swap is bounded by this option. Dense CV-CV staging, PPAA/PAPA/PACV arrays and J/K data remain, as do their ordinary output writers. The half-slab option does not change second-half contractions, J/K, integral values, MO ordering or the HDF5 contract. The width remains explicit and resource-dependent, separate from automatic J/K and reader/transform work blocks: the RAM planner does not silently resize it. Smaller slabs can repeat AO integral passes and slow the dump. Disk and native-memory preflight are still required.
Omitting the YAML slab key leaves it absent from normalized input, preserving
legacy checkpoint identity. Explicit null or a positive size remains in
normalized input; null still selects the monolithic transform. Existing
explicit memory values and aliases are not rewritten. Direct checkpoint
resume restores saved input/workdir and may return immediately for a completed
dump, as described in the YAML checkpoint reference.
Exact Half-Transform Acceptance Scenarios#
The scenarios below were specified before the slab implementation. Tests use
ordinary pytest with Gherkin intent in their docstrings, not a separate BDD
runtime. Each scenario protects a different observable. Test paths below are
under pyscf2mppt/tests/.
ID |
Necessity and overlap |
Test location |
|---|---|---|
SLAB-01 |
Existing ERI tests check dense block parity; this checks the complete selected HDF5 and observes the real source option, so a silent no-op cannot pass on parity alone |
|
SLAB-02 |
SLAB-01 starts at the public API; this checks the separate YAML/runtime wiring |
|
SLAB-03 |
Equal integrals do not prove bounded disk; this observes source ranges, tail, file lifetime and buffer reuse |
|
SLAB-04 |
Normal closure does not cover an interrupted half build or second transform; no retry/recovery framework is implied |
|
SLAB-05 |
Reject zero/negative/noninteger sizes and the unsupported full route before expensive work; no speculative bad-input grid |
|
Feature: Bounded exact half-transform for selected integral dumps
The approximation, second-half contractions and final packed format stay unchanged.
Omitting exact_half_block_size keeps one monolithic half-transform.
A positive size limits the first MO side of each produced half-transform.
No DF, automatic fallback, tile-resume or full-route slab backend is introduced.
@SLAB-01
Scenario Outline: A selected dump preserves its complete numerical content
Given one fixed small water RHF reference and a nonempty core, selected and virtual partition
And an HDF5 dump made without the slab option
When the same reference is dumped with exact_half_block_size <size>
Then the real half-transform source receives the requested block size
And all HDF5 integral datasets and physical metadata match within 1e-10 absolute and relative tolerance
And the selected route still has no int2e_full dataset
Examples:
| size |
| 1 |
| 4 |
| 99 |
@SLAB-02
Scenario: YAML selection reaches the existing reference exporter
Given a selected-route YAML input with exact_half_block_size 4
When the input is parsed and its dump stage is prepared
Then the existing public reference exporter receives exact_half_block_size 4
@SLAB-03
Scenario: The producing source bounds storage and consumes the partial tail
Given fixed water MOs with seven first-side orbitals and block size 4
When every half-transform row is consumed in order
Then the half-transform is built for ranges 0:4 and 4:7
And each half payload is at most 8 times 4 times the second-side count times the AO-pair count bytes
And the previous half file is deleted before the next file is built
And the same row buffer is reused
And the source leaves no half file when it closes
@SLAB-04
Scenario Outline: An interrupted transform releases its owned scratch
Given an exact selected block transformation with block size 4
When a controlled exception is raised during <stage>
Then the original exception propagates
And neither an owned half file nor an owned dense CV-CV file remains open or on disk
Examples:
| stage |
| half build |
| second half |
@SLAB-05
Scenario Outline: Invalid or unsupported slab requests are rejected
Given an export request with exact_half_block_size <size> and N_select <selected>
When the request is validated
Then it is rejected before integral generation
Examples:
| size | selected |
| 0 | 5 |
| -1 | 5 |
| true | 5 |
| 1.5 | 5 |
| 4 | 0 |