Vakint implementation architecture
Topology construction, canonicalization and tensor-reduction flow, backend selection, external-process ownership, persistence boundaries, invariants, and tests.
Status: Current implementation architecture, audited against the Vakint source on 2026-10-04.
This note describes the Rust engine and its optional Symbolica community-module wrapper. Backend availability and numerical coverage depend on the selected topology, epsilon depth, and installed external tools.
Boundaries
Vakint is an in-process Symbolica transformation engine for single-scale vacuum integrals. The Rust crate owns five boundaries:
VakintandTopologies: construction of the known topology library and entry points for canonicalization, tensor reduction, parametric evaluation, and numerical evaluation;VakintExpressionandVakintTerm: the structured numerator/topology representation used between stages;VakintSettings,TensorReductionMethod,EvaluationOrder, andEvaluationMethod: precision, normalization, dependency, and backend-selection policy;- FORM and pySecDec adapters: template rendering, subprocess execution, and result decoding;
- the optional
symbolica.community.hepkit.vakintmodule: Python classes that own a Rust engine and settings while exchanging Symbolica expressions.
The modules alphaloop_numerics, matad, matad_numerics, fmft, and fmft_numerics contain backend-specific reductions and master-integral substitutions. symbols owns the namespaced Symbolica symbols. graph is a small vacuum-topology graph used for validation, contraction, and loop-momentum-basis work; it is not Linnet’s generic half-edge graph.
Core representation
Vakint::new initializes the symbol registry and generates an in-memory Topologies collection. The collection contains canonical one- through four-loop families and selected contractions, followed by an Unknown matcher whose allowed evaluation method is pySecDec. Each Integral stores its canonical and optional short expressions, match patterns and conditions, graph, loop/propagator counts, and applicable backend set.
Input is represented as a Symbolica Atom. VakintExpression::split_integrals separates a sum into VakintTerm values, each containing:
- one
topo(...)expression; - its coefficient as the numerator;
- the loop and external vectors discovered in that numerator.
ReplacementRules is the result of matching one input topology. It carries the selected canonical topology, the canonical-to-input edge map, substitutions for masses, powers, momenta, and nodes, and the substitutions required to rewrite the numerator consistently. It is an ephemeral transformation plan, not a persisted cache.
VakintSettings controls epsilon and scale symbols, executable paths, input rationalization and runtime precision, numerator verification, normalization, unknown-integral policy, temporary files, epsilon depth, dot-product notation, TensorReductionMethod, and EvaluationOrder. A Vakint engine is reusable; settings are passed explicitly to Rust operations. The Python Vakint wrapper stores the engine and settings together for convenience.
Main control flow
The complete Rust entry point is Vakint::evaluate:
AtomView
-> validate selected settings and external dependencies
-> split into VakintExpression terms
-> match and canonicalize topology plus numerator
-> tensor-reduce each numerator with the selected TensorReductionMethod
-> choose the first supported EvaluationMethod for each term
-> run the backend and decode its Symbolica expression
-> combine the transformed terms into an Atomto_canonical, tensor_reduce, and evaluate_integral expose narrower stages. Canonicalization tries registered topologies in order, derives replacement rules, normalizes momentum routing, and can emit the short topology form. Tensor reduction defaults to the native FeynKit projector, which converts the numerator to FeynKit tensor syntax and returns a scalar-product expression without requiring FORM. Selecting TensorReductionMethod::AlphaLoop uses the historical FORM projector: it expands compact dot notation, translates vectors and indices, runs the embedded reduction program, and maps the result back to Symbolica.
Dot conversion visits every normalized dot power once, reserving existing dummy indices and numeric source slots before assigning fresh ones. Each copy of a powered scalar sum receives an independent dummy scope. Graph numerator products and scalar spectators stay factored; the converter does not rescan the entire numerator for each occurrence. Its indexed output binds a native vector’s index inside the existing compact representation. This contract applies after scalar integration as well as tensor reduction. Explicit source slots on loop and external momenta retain their representation through projection, so a surviving numeric source label cannot be mistaken for a newly allocated backend dummy.
Integral evaluation matches again so that it has the canonical topology and numerator mapping. It then walks settings.evaluation_order and selects the first method whose topology, loop count, and requested epsilon depth are supported. AlphaLoop is limited to its registered topologies, at most three loops, and at most four requested terms; MATAD covers its registered topologies up to three loops and normally five terms; FMFT covers registered four-loop topologies up to five terms; pySecDec covers topologies registered for that numerical path. Failure to find a method is an explicit NoEvaluationMethodFound error, not an implicit fallback.
MATAD also accepts exactly six terms for a certified product of at most three independent tadpoles with the same nonzero mass. Each line must be a self-loop carrying a distinct loop momentum with coefficient +1 or -1. These products need only the existing Gamma series through epsilon degree five. Connected master tables retain their original depth limit; mixed masses, scaled loop momenta and seven-term requests do not qualify. The FORM remainder check still rejects unavailable coefficients.
The registered one-scale two-loop sunsets include the MM0 and M00 mass patterns. Canonical masses accept either zero or msq(index), and scale extraction chooses a nonzero mass. These partially massless topologies use MATAD: AlphaLoop’s uvprop representation has no mass slot and cannot preserve which lines are massless, so that representation is withheld for any topology with a zero mass.
Numerical evaluation is a later boundary. Parametric backend output remains a Symbolica expression. Numerical parameters and optional external momenta are converted to the configured binary precision, and NumericalEvaluationResult represents the result and optional error as Laurent coefficients (epsilon power, complex value). Laurent extraction reads the actual epsilon atom and its integer powers, preserving its namespace and display registrations. A malformed monomial or a coefficient that still depends on epsilon returns an evaluation error.
External tools and feature boundaries
AlphaLoop, MATAD, and FMFT invoke FORM. The pySecDec method invokes both FORM and pySecDec through the configured Python executable. validate_settings checks only dependencies required by the selected evaluation order, validates the loop-normalization expression, and enforces FORM >= 4.2.1 and pySecDec >= 1.6.4 when those tools are selected. evaluate and evaluate_integral perform this validation; the narrower tensor_reduce stage does not validate scalar-evaluation dependencies. Native FeynKit tensor reduction can therefore run without those external tools.
Backend expression serialization follows the exact atom tree and symbol identities, independently of display callbacks. A complex numeric atom is written from its explicit real and imaginary coefficients, including a unit imaginary numerator; the FORM adapter then maps the imaginary unit to i_. This preserves valid syntax for coefficients such as i/16 without changing their value.
Saved FORM indices retain the caller’s epsilon symbol, including dimensions inside native Lorentz slots. These same index atoms identify vector-map sources, so the mapping uses the caller’s convention before restoring concrete FORM indices.
FORM programs, headers, and run templates are embedded in the Rust binary with include_str!. For each run, Vakint renders those resources into a uniquely named temporary directory, launches the configured process, reads out.txt, and removes the directory when clean_tmp_dir is true. pySecDec can reuse a caller-selected output directory; the implementation labels this unsafe for normal operation because stale generated sources or results can be mistaken for the current calculation.
The Cargo build script has one platform-specific boundary: on macOS, setting EXTRA_MACOS_LIBS_FOR_GNU_GCC opts into linking gcc_s.1.1 from MacPorts’ libgcc directory when that library exists. This affects native linking only; it does not select an evaluation backend.
The core Rust API has no feature requirement. python enables the PyO3 wrapper and registers Vakint, VakintExpression, VakintEvaluationMethod, and VakintNumericalResult on symbolica.community.hepkit.vakint. python-stubs adds stub metadata and also enables Symbolica’s Python export. The wrapper delegates transformations to the Rust engine and converts VakintError into Python ValueError; it does not implement a second evaluation pipeline. Construction stores the selected tensor-reduction and evaluation settings without checking external executables; the evaluation entry points validate dependencies when needed.
The community-module citation hook reports cumulative process-wide usage. Constructing the engine or using its Python wrappers records Vakint; backend boundaries separately record the tools they invoke. Repeated queries do not clear other callers’ usage or duplicate a citation. This bookkeeping does not choose the tensor-reduction or scalar-evaluation backend.
Persistence and reproducibility
Vakint does not serialize its topology library or settings. Known topologies are regenerated by Vakint::new, which is why one engine should be reused for multiple operations. Durable values cross the API as Symbolica expressions or Laurent-coefficient lists. Temporary FORM/pySecDec workspaces are implementation artifacts unless cleanup is disabled or a reuse directory is explicitly supplied.
A reproducible result therefore depends on more than the input expression: record the topology form, numerator, normalization convention, epsilon depth, decimal precision, tensor-reduction method, backend order and options, numerical masses and external momenta, executable versions, and whether a pySecDec workspace was reused.
Maintained invariants
- Each input term contains exactly one first-power
topo(...)factor; scalar-only terms and powers of a topology are rejected by the structured-expression boundary. - Propagator ids are contiguous from one, and loop-momentum ids are contiguous from one through the detected loop count. Vacuum-graph nodes must have degree greater than one.
- Canonical topology substitutions and numerator substitutions are applied as one mapping; sequential replacement is avoided because one replacement target can be another source.
- When
verify_numerator_identificationis enabled, no unrecognized loop-momentum dependence may remain after canonical mapping. EvaluationOrderis policy: the first supported method wins. Unsupported methods are skipped, but execution errors from the selected method are returned.- Loop normalization may reference only the documented symbols and is expanded to the requested epsilon order before backend results are normalized.
- Runtime numerical precision is converted to a binary precision of at least the equivalent of 17 decimal digits; Python convenience inputs are converted at that boundary.
Verification and related documentation
The integration-test modules separate topology/input matching, tensor reduction, analytic evaluation, free-form evaluation, backend comparisons, and direct pySecDec evaluation. Analytic cross-checks compare AlphaLoop with MATAD, while numerical suites compare supported analytic results with pySecDec. Tests that need pySecDec detect or explicitly skip that dependency; FORM and backend-enabled coverage still requires the corresponding external tools. The crate also has focused unit tests for expression encoding and numerical-result behavior.
For supported workflows, see the matching tutorial, evaluation and reproducibility guide, Rust/Python interface guide, and generated topology table. Exact Rust signatures are in the native Vakint Rustdoc.
Factorized tensor projection and epsilon coefficients
The default tensor-projection path reduces universal loop-momentum kernels while preserving graph coefficients as factorized expressions. Temporary coefficient aliases are restored after analytic integration. The native FeynKit backend uses its existing tensor reducer; the project_onto_tensor_integrals choice selects the factorized projection or complete-numerator FORM route when the AlphaLoop backend is requested. Both backends retain separate denominator topologies and validate Lorentz domains.
The native adapter selects raw k, p, and g leaves and Lorentz tensors with the existing filtered collector. Scalar coefficient subtrees remain opaque. A selected indexed power stays intact until the checked reducer can allocate independent dummy scopes for its copies. Branch-local Lorentz metadata is attached before that lowering, preserving distinct original dimensions when sum branches reuse the same written index. External-vector syntax is retained inside pure_scalar metadata, so it does not add an extra tensor port and can be restored after projection.
The raw Vakint adapter uses TensorReducer::admit to admit each converted selected numerator once as a SymbolicTensor<PartialStructure>, then calls TensorReducer::reduce with that retained value. Rejected source expressions keep the reducer’s precise index/power error when its existing parser can refine the native admission error; validation is never bypassed. TensorReductionTerm keeps its tensor body in the same carrier; its separate Atom coefficient is the exact scalar orbit or projector weight. Foreign-representation spectators remain tensors during selected Lorentz reduction and composition. TensorReduction also retains the source interface for an empty or identically vanishing result, including odd-rank moments. Typed addition and multiplication preserve declared logical ports. Only the adapter’s return to Vakint’s raw projector/index ABI decodes the completed result; raw VakintTerm storage remains that backend boundary.
GammaLoop passes its actual spin tensors through the existing opaque-slot bridge. Their Lorentz ports stay connected to the projected metrics, and GammaLoop completes the d-dimensional Dirac algebra before Laurent truncation. Duplicating a tensor body and its port list in a frontend wrapper would allow the two copies to diverge during projection; dropping that wrapper afterward would restore stale indices. The bridge requires no such duplicate representation. Vakint itself does not evaluate spin algebra. Numerator and normalization poles increase the required epsilon order; positive powers do not reduce the conservative depth. Opaque epsilon-dependent functions error.
After tensor reduction, both projection policies share ScalarTerms for analytic scalar evaluation. It validates polynomial loop scalar products, isolates the complete loop-independent coefficients and supplies one synthetic kernel to the selected backend. Coefficients are restored before the final Laurent projection, retaining their factors and complex-function branches. Numerator and normalization poles increase the required backend depth; regular or evanescent coefficients never reduce the conservative depth. The supported Laurent-function and integer-power guards apply in either policy.
The same coefficient-protection owner also shields unrelated factors during AlphaLoop’s complete tensor-numerator FORM reduction. At that earlier stage, protection requires both loop independence and a closed Lorentz interface. Open native ports remain visible to metric contraction and index transport; unselected function payloads are atomic. This preserves products and powers of scalar graph factors while allowing FORM to reduce the connected loop-tensor polynomial. Coefficient symbols are collision-checked against the input and restored at the owning boundary.
The scalar-evaluation boundary uses the same Lorentz-incidence parser for raw momentum factors and registered native tensor leaves. Incidence keys are complete represented Minkowski slots, so equal written labels in different tensor representations remain independent. Declared tensor_index markers from the universal projector also count as direct ports until native restoration. A closed external contraction such as a gamma leaf times its matching external vector is scalar with respect to loop integration while retaining its spinor interface. Metrics relabel complete slots on the actual leaf, and ordinary raw loop/external momentum pairs still become scalar products. Successive attachments retain a native leaf’s remaining ports after the first contraction forms a product; closed native coefficients do not obstruct independent raw momentum contractions. Scalar spectators stay factorized. Hidden compound Lorentz slots or projector markers require materialization by their tensor owner; loop-dependent native leaves require tensor reduction before this scalar boundary. Vakint does not infer spin or color identities from those interfaces.
A closed dot of a fixed coordinate basis and an external momentum is scalar at this boundary. Spenso’s fixed-basis matcher validates its concrete component and representation. The basis vector alone is still non-scalar, and a dot involving an active loop momentum still requires projection before scalar evaluation.
The native FeynKit projector accepts compact fixed vectors as well as indexed vector factors. The GammaLoop bridge normalizes scalar weights in compact dots through the shared notation owner. It removes compact representation arguments only from Vakint’s own loop and external momentum syntax; a native fixed vector retains its actual port. AlphaLoop’s compact angular-input syntax expects elementary external p vectors. Cross-backend checks of native fixed vectors therefore materialize just the compact dot arguments into indexed factors before invoking AlphaLoop, without distributing the surrounding numerator. Both projection policies and both output dot-notation settings retain the same dimensional-algebra boundary; arbitrary native fixed vectors inside compact Vakint dots are not an AlphaLoop input contract.
After projection, GammaLoop restores the shared native interface before scalar dot conversion or epsilon expansion. It first identifies regulated Lorentz-slot metadata with the source’s symbolic dimension, leaving scalar evanescent coefficients untouched. Fresh projected dummy slots are then checked against the existing complete source slots in that unified frame. Allocating before this metadata normalization could identify a fresh slot with an already reserved source index. Raw numeric backend dummies use the same topology-local chart in momentum and metric leaves. Symbolic source labels regain their representation without changing identity; compact fixed vectors keep their native leaves. Only after completed dimensional tensor algebra and residual-contraction checks does the bridge replace scalar dimension dependence for Laurent expansion. A retained external basis keeps its representation metadata.
GammaLoop’s vacuum-only AmplitudeGraph::analytical_evaluation uses the same Integrated::restore_numerator owner on its backend result. Before exporting, it and Integrated::integrate use Integrated::protect_numeric_ports to transport explicit numeric public ports to collision-free native labels with reserved_dummies and reindex_interface_ports. Raw numeric backend dummies can then acquire their topology-local labels without capturing an original public port. Restoration recovers native tensor notation, checks the result against the retained protected interface, and inverse-transports the public labels in their original logical order. A zero result keeps that interface; source Lorentz dimension is not silently specialized to four. Scalar inputs need no public-index transport.
The analytical command still canonicalizes, tensor-reduces and evaluates each component in that order. Its numerical option invokes Vakint’s scalar numerical evaluator at the same per-component stage, before the global projector; this does not provide general numerical evaluation of open tensor components. The command combines component results, projector and overall factor as tensors, sums graph contributions, and exports source notation only for its final return value or output file. No performance conclusion follows from this ownership change without separate measurements.
The Python adapter accepts complex mass/numerator substitutions as numerical_parameters; the PySecDec boundary requires real pole masses and external momenta, with complex numerator coefficients allowed. Physical PySecDec integration tests remain explicit manual checks. The commands and detailed contracts are in the evaluation guide.