Complex streamed tensor slice¶
Status: bounded source implementation for TENS-06 (#799), 2026-11-02. This extends the initial CPU contract; it does not close #793, #795-#799 or #801. Complete scientific acceptance is pending a runtime containing this source. The source commit and runtime pickup record are recorded on #799.
Subsequent source evidence: the bounded planner ADR records #800 RI-J lowering and structural schedule reuse, plus unchanged complex-kernel regression checks. The historical measurements and limitations below describe this earlier slice.
Memory and work admission¶
BorrowScope can import an authoritative live-byte inventory once. Each
borrowed allocation consumes credits within it, while multiple views of the
same allocation retain that single charge. Credits cannot exceed the imported
inventory and return when the allocation handle dies. This is an explicit
adapter contract, not automatic deduplication of arbitrary pointer aliases.
The native numerical owners and their existing lifetimes remain unchanged.
A conservative 65,536-byte per-worker control envelope admits the bounded
views, IR, source tokens, cursor and leases. The panel adds this to its macro
object inventory and propagates it into real-provider and density-Gram parent
lower bounds. The pair leaf adds it for every rank/worker replica above its
existing inner-factor node peak; tensor_control_bytes_per_worker exposes
that component. Numerical payload caps remain separate. The panel imports
its per-replica inventory, and the pair adapter imports its whole-node inventory
with other workers reserved. Engine metadata must fit the added envelope.
Work accounting adds bounded planning/digest overhead before reads: 8,192 units per panel tile or pair factor build. Existing producer work, candidate, image, tile-call, reader and node/rank ceilings remain checked. The cursor stores only source and counters, not all-q keys. No all-q factors, full AO store, coefficient outer product or four-index tensor is allocated.
Tracked bytes are conservative reservations, not RSS. Allocator/runtime/OS costs outside the original CPU ledger boundary are not silently called a hard process-memory guarantee.
Focused evidence¶
Current C++17 source checks compile independently of an installed QC runtime:
.venv/bin/python -m pytest --noconftest tests/test_tensor_engine.py tests/test_tensor_stream.py -q
Eight cases pass. Four streamed cases also pass AddressSanitizer and UndefinedBehaviorSanitizer. They exercise skewed 3-by-5 pair domains and 2-by-5 panels, genuine imaginary lanes, Hermitian and bilinear products, bitwise predecessor panel parity, independent long-double explicit sums, compensation cancellation, source/metric/frame/q and dependent-domain revision mismatches, expired/conflicting leases, stale plans, provider failure and incomplete/out-of-order streams. Both kernels pass exact-peak admission and refuse one byte below it. Imported-owner overdraw and release are checked.
The bounded test streams 200,003 auxiliary rows in tiles of at most 31: 25,600,384 logical factor bytes with 8,464 tracked peak bytes. This proves bounded transport/execution for generated data, not Gaussian source accuracy. The four changed physical translation units and the dedicated pair binding unit compile with the checkout’s configured native compiler flags.
Existing physical tests remain the integration oracles:
test_periodic_gaussian_local_orbital_factor_blocks.py compares rectangles
against full panels and independent Gaussian transforms;
test_periodic_correlation_pair_integrals.py compares all-q contractions with
independent reciprocal sums and exact node/replica boundaries. Their accounting
assertions include the new control envelope. They were not executed against
an old native extension: collection currently refuses an incomplete basis
overlay, and the previously identified installed extension is stale.
Measured cost and decision¶
The portable microbenchmark is benchmarks/tensor_stream.cpp, built with
C++17, -O3 -DNDEBUG, Apple Clang 21 on Apple M5 Max, one caller thread.
There is no BLAS call, extra packing or thread runtime in these kernels.
Initial general-stride lowering cost 2.38-4.13 times the predecessor loops;
this is why the registered layout-specialized loops remain.
Three subsequent process runs measured the following medians in microseconds. Planning constructs fresh IR without execution; repeated use keeps one plan. Fresh-plan execution includes planning and execution with already-adapted views. Provider generation, descriptor adaptation and whole-method cost are not included. Each operation visits one supplied tile and packs zero bytes.
Operation (aux,left,right) |
Fresh planning |
Reused execution |
Fresh plan + execution |
Predecessor |
Tracked peak bytes |
|---|---|---|---|---|---|
Pair (31,3,5) |
0.134 |
0.961 |
1.072 |
0.975 |
9,336 |
Pair (48,7,13) |
0.139 |
8.401 |
8.558 |
8.387 |
23,160 |
Panel (11,1,3), 31 AO pairs |
0.305 |
2.752 |
2.908 |
3.127 |
16,936 |
Panel (11,7,13), 31 AO pairs |
0.314 |
79.101 |
78.954 |
85.410 |
52,264 |
The peak includes benchmark inputs, outputs, compensation, views and two live plans during the fresh-plan measurement; predecessor comparison arrays are outside the engine ledger. Observed reused/legacy ratios ranged 0.86-1.38 across these runs. Thermal/order noise and small shapes preclude a general speedup claim. No mandatory external tensor package or benchmark target was introduced. Full HF/MP2 cost remains unmeasured.
Scientific acceptance and remaining work¶
No complete HF plus selected-pair MP2 calculation on this changed runtime has
passed through vq yet. The available default vq inventory lists the QC
program as scheduler-only, not as a verified native runtime containing this
source. No stale-runtime override or speculative scientific PASS was used.
Runtime delivery/Validator should execute the existing admitted finite-source
HF/MP2 workflow and physical integration tests, recording source SHA, native
module identity, actual gauges/domains/caps and energies. Use matched CRYSTAL
only if its reference conventions match; otherwise retain the justified
same-source/explicit-sum evidence and state its finite-source limitations.
This source record establishes neither production periodic correlation nor
infinite-image convergence. #799 remains open for that acceptance and broader
stream capabilities; pending runtime delivery does not hold source landing.
The design reuses the library study’s TAMM III-IV (DOI 10.1063/5.0142433) dependent domains and CoRa sections 4-7/CoNST sections 2-5 bounded-iteration evidence. It implements a synchronous, fixed-memory CPU increment, not their distributed/compiler systems or fast-math performance claims. The preserved chemistry follows the existing Sun equations 3, 4, 13, 16, 21 (DOI 10.1063/1.4998644) and Nejad equations 2-10, 26-28 (DOI 10.1063/5.0290816); no scientific approximation is changed. Existing method citations remain in force.