Skip to content

Execution and storage

The library separates the vertex computation into support planning, Wigner symbol evaluation, booster production, and contraction. These are numerical responsibilities rather than four mandatory global passes. CPU execution can generate 6j slabs just before contracting them. GPU execution prepares boosters on the host and generates its 6j inputs on the device. This interleaving avoids keeping the entire network in memory.

From triangle inequalities to packed tensors

For a Wigner symbol

\[ \left\{\begin{matrix}a&b&c\\d&e&f\end{matrix}\right\}, \]

the four triples \((a,b,c)\), \((a,e,f)\), \((d,b,f)\), and \((d,e,c)\) must satisfy triangle inequalities and have integral total spin. For example,

\[ |a-b|\leq c\leq a+b,\qquad a+b+c\in\mathbb Z. \]

Doubled integer labels make both interval and parity tests exact. The planner propagates these restrictions across the 6j network before producing its payloads. In particular, booster values outside every contributing 6j support are unnecessary.

Instead of allocating the full Cartesian product of the channel lists, the library stores dense values within admissible blocks. A one-dimensional block descriptor records its begin, exclusive end, and payload offset; a two-dimensional descriptor records the corresponding rectangle and offset. Contraction kernels intersect applicable descriptors before reading data. The inner arithmetic can therefore work over contiguous arrays while the metadata avoids large regions known to vanish.

Supports describe necessary selection rules, not a guarantee that every stored entry is nonzero. Their bounding intervals or rectangles can contain further zeros, and an admissible symbol can vanish accidentally. The fraction of storage eliminated depends on the boundary data and cutoff; there is no universal sparsity percentage.

Packing also differs from skipping every omitted recurrence step. A normalized 6j recurrence needs a complete admissible spin string, and a booster recurrence can produce a canonical slab before its retained entries are harvested. The recurrence's dependency structure determines which intermediate work remains necessary.

Wigner recurrence and local symmetry

Production Wigner symbols are generated by normalized, seed-free recurrences. For the 6j series, the Luscombe–Luban forward and backward ratio recurrences determine its shape. Orthogonality determines the normalization and the analytic endpoint phase fixes the overall sign. No external numerical seed, persistent Wigner table, or symbol hash table is required. The Wigner chapter derives the recurrence construction, including the 3j rows used by booster seeds and coherent coefficients.

Wigner symmetries place a convenient internal intertwiner on the variable axis. Prepared recurrences share coefficient calculations across related strings, and worker-local scratch arrays are reused during one computation. Only the intervals requested by the packed tensor are retained. GPU kernels perform the corresponding device recurrences and report numerical recurrence failures through a checked counter.

The central factor satisfies

\[ \begin{aligned} &S_C(x,k_3,k_4,\ell_{24},\ell_{34},\ell_{35})\\ &\qquad=S_C(x,k_4,k_3,\ell_{35},\ell_{34},\ell_{24}). \end{aligned} \]

When both blocks exist in the channel ranges, a representative can be stored once and accessed through a transposed logical view for its partner. The mapping retains unmatched blocks explicitly. This local symmetry of one 6j factor is distinct from a reflection of the complete boundary network.

Reflection of the full network

Reflection exchanges tetrahedra \(2\leftrightarrow5\) and \(3\leftrightarrow4\), leaving tetrahedron 1 fixed. It preserves the boundary spins when

\[ j_{12}=j_{15},\qquad j_{13}=j_{14},\qquad j_{23}=j_{45},\qquad j_{24}=j_{35}. \]

The corresponding channel lists and block mappings must also be compatible. For a fixed component, the external intertwiners must additionally obey \(i_2=i_5\) and \(i_3=i_4\). The implementation checks this information before selecting a reflection-specific schedule.

For the full tensor, reflection relates entries under the matching permutation of the external axes. After grouping \((i_2,i_3)\) and \((i_4,i_5)\) into matrix indices, one side's pair ordering is reversed so the relation becomes a matrix transpose. A triangular panel can then represent the output for each \(i_1\). If this panel has side length \(M\), its physical payload contains \(M(M+1)/2\) values instead of \(M^2\).

This compression does not change the logical rank-five shape. Output metadata records how a logical index maps to its stored representative. Dense output materializes every logical value in canonical column-major order, with the \(i_1\) axis contiguous. General boundary data use dense output; both CPU and GPU retain complete schedules when reflection is unavailable.

Host memory planning

The full output size can be estimated from the external channel lengths before constructing detailed supports. This early check catches impossible size products and excessive output requests. Once supports exist, planning accounts for their metadata, packed symbol and booster payloads, output storage, per-worker contraction buffers, and safety allowances.

The storage strategies follow the requested mathematical output:

Computation Progressively smaller working sets
Fixed component Resident 6j inputs; groups of \(x\) slices; \(x\) slices subdivided into local blocks.
Coherent scalar Shared 6j slices across \(i_1\) batches; smaller batches and slices; streamed work for a single \(i_1\).
Full CPU tensor Resident inputs; streamed 6j inputs with resident boosters; external-intertwiner and booster tiles with a suitable output sink.

The aim is to retain reusable data while bounding the largest active intermediates. More streaming can increase repeated setup, recurrence work, and transfers. Conversely, a larger resident allocation can reduce cache locality. Memory admission and local contraction costs therefore influence the selected plan together.

Automatic host budgeting considers physical capacity and available allocation headroom. On Linux, it also considers process cgroup and recognized Slurm job limits. An explicit library memory budget further constrains planning. Estimates are admission decisions for modeled library allocations; they do not account perfectly for every allocation in the surrounding application or vendor library.

Streaming input tensors cannot remove the storage required by the requested output itself. The tensor container consequently separates its logical shape, physical representation, and backing: a tensor can own its payload in memory or map a persistent file, and reflection compression can reduce the payload when the boundary permits it.

GPU placement and bounded fallback

Host workers build channels, supports, coherent coefficients, and booster payloads. CUDA backends upload the required booster representation, generate 6j values on the device, and contract there. Generating these symbols where they are consumed avoids transferring large host-generated 6j arrays and reduces transfer time. Booster recurrence and quadrature remain host computations in the current production routes.

Device admission includes uploaded operands, recurrence storage, vendor-library workspace, materialized panels, output buffers, and pipeline slots. The coherent backend can overlap its central-symbol recurrence, middle contraction, and tail using three slots. Under memory pressure, it can retry with two and then one, and tile the \(\ell_{34}\) axis. The full-tensor backend can reduce the capacity of its materialized row slabs and select resident or streamed central 6j data. These changes preserve the contraction algebra.

Only recognized memory pressure justifies these retries. Invalid metadata, numerical recurrence failure, and other backend errors are reported rather than reinterpreted as a request for another mathematical route. Explicit GPU execution does not silently become a CPU calculation.

Multi-GPU scheduling follows the output structure. A coherent scalar has independent \(x\) contributions that devices can claim dynamically; final host reduction uses fixed \(x\) order. Full tensors are partitioned over disjoint \(i_1\) ranges, so each device produces a different output section. These two decompositions have different load-balancing and replicated-input costs.

Numerical approximations

Exact support pruning and symmetry compression preserve the defined finite network. The numerical approximations occur elsewhere:

Approximation Consequence
Common lifted-spin cutoff \(\Delta\ell\) Replaces six infinite sums with finite ones; convergence depends on the observable and boundary data.
Fixed 128-point quadrature Approximates the mapped booster integral; a larger lifted-spin cutoff does not refine the integration grid.
Finite-precision recurrence and contraction Accumulation order and cancellation affect numerical error, including differences between CPU/GPU trees.
Relative \(C_1\) pruning Omits small coherent coefficients and their associated contraction work.

For the public coherent computation, the last threshold is

\[ \tau=\varepsilon\max_{i_1}|C_1(i_1)|. \]

Coefficients with \(|C_1(i_1)|<\tau\) are discarded. The configurable ratio \(\varepsilon\) defaults to \(10^{-8}\); zero disables this approximate relative pruning. Exactly zero coefficients need no work regardless of that setting. The same configured ratio is passed to CPU and GPU execution.

The discarded coefficient mass alone does not bound the amplitude error: the network values multiplying those coefficients can have very different scales. Likewise, relative agreement is poorly conditioned near a vanishing amplitude, where absolute differences also matter. Cutoff convergence, quadrature accuracy, and floating-point agreement are separate numerical questions.

Persistence and cache identity

Persisted full tensors provide deliberate reuse across calculations and language interfaces. Their files contain logical dimensions, physical layout, spins, cutoff, the simplicity prescription, and the exact floating-point value of \(\gamma\). Layout and payload sizes are checked when mapping a file. Physics metadata, not a human-readable directory name, decides whether a result can be reused.

An ordinary fixed-component computation evaluates its network directly. Its explicit cache policy can instead probe a compatible full tensor and retrieve one component. A missing or incompatible candidate in this optional probe falls back to direct computation. An on-disk full-tensor request with reuse enabled treats an existing incompatible file as a cache error, preserving it instead of silently overwriting it. Recalculation with replacement writes the new result through the library's persistent-output machinery.

Working arrays and recurrence factors reused within a computation are separate from persisted result caches. Ordinary calculations do not build hidden, unbounded global collections of Wigner symbols or intermediate tensors.

Implementation map

Support representations are defined in amplitude supports and full-tensor supports. Related implementation includes Wigner recurrences, reflection orbits, host budgeting, full-tensor execution planning, tensor storage, and scalar cache lookup.