WorksPhysics and Astronomy
Automatic amplitude generation with DiaGen
Abstract
DiaGen is a C++ program for automated multiloop amplitude generation with integrated identification of Feynman integral topologies. Given a user-defined quantum field theory model and a scattering process, the program generates compatible diagrams at a specified loop order, assigns fields and momentum routings, determines fermionic signs and combinatorial symmetry factors, and produces FORM-readable amplitudes for subsequent algebraic processing. The central feature is the construction of a symmetry-aware prototype map during diagram generation. Propagator structures are classified using mass-labelled graph isomorphisms and, for vacuum and two-point integrals, canonical momentum representations, while admissible subprototypes are related to parent prototypes. The resulting mappings organize scalar integrals into a compact set of representatives and provide the transformations needed for subsequent matching. DiaGen exports these data, together with kinematic information, in a form suitable for integration-by-parts reduction with Kira. We present the diagram and prototype conventions, explain the workflow from model input to integral families, and report benchmark timings for representative multiloop processes. We also describe the inverse Kirchhoff reconstruction of scalar diagrams from integral-family sectors and the subsequent determination of consistent edge orientations. The scope of the implemented equivalences and the associated computational trade-offs are stated explicitly. Since a given input always yields byte-identical output, DiaGen can also serve as a deterministic, verifiable component in workflows driven by AI coding agents: the agent prepares inputs and orchestrates the calculation, while the exact combinatorics of diagram generation and topology identification are delegated to a reproducible program.
PROGRAM SUMMARY
Program title: DiaGen
Developer’s repository link: https://gitlab.com/diagen-cpp/diagen
Licensing provisions: GNU General Public License 3 (GPL)
Programming language: C++
External routines/libraries used: GiNaC [1, 2] with CLN, yaml-cpp [3], GMP, zlib. Optional tools include Graphviz and Ghostscript for drawings, FORM [4, 5] for the supplied amplitude processing, and Kira [6, 7, 8] for the subsequent reductions.
Does this version supersede a previous version?: Not applicable.
Reasons for this release: First public release of DiaGen.
Nature of problem: Multi-loop amplitude calculations require a consistent transition from large sets of field-labelled Feynman diagrams to scalar integrals organized in families suitable for integration-by-parts (IBP) reduction. Repeated topology identification, momentum rerouting, symmetry matching, and subtopology classification can create substantial computational and process-specific overhead, particularly at high loop orders and with several mass scales.
Solution method: DiaGen generates diagrams at a specified loop order for a user-defined model and process. It assigns fields, masses, and momenta, determines fermionic signs and combinatorial symmetry factors, and writes amplitudes in a FORM-readable format [4, 5]. In parallel, the program constructs a prototype map based on physical denominators, admissible subtopologies, and graph-based equivalences, including the symmetry and momentum-mapping information needed to express different contributions in common integral representations. User-provided FORM procedures can perform further algebraic transformations, including partial fractioning where required. The program also exports integral-family and kinematic information for subsequent reductions with Kira [6, 7, 8]. A complementary mode reconstructs scalar diagrams from specified propagator momenta and mass labels.
Introduction
Multi-loop scattering amplitudes are essential for precision predictions in high-energy physics. The demand for higher-order calculations is documented, for example, in the community “precision wishlist” [1]. As loop order, external-particle multiplicity, and the number of mass scales increase, a central practical challenge is not only to generate the diagrams but also to organize their scalar-integral content consistently. A single integral topology may occur in many diagrams and with different loop-momentum routings. Identifying these repetitions early can reduce subsequent bookkeeping and simplify the interface to integral reduction.
Two complementary aspects of automation are important for this problem: the construction of the amplitude from model information and the organization of its integral content. In the broader software landscape, QGRAF [2, 3] and FeynArts [4, 5] provide diagram-generation capabilities. More recent diagram generators include feyngen [6], FeynGraph [7], and the generator built into FORM 5 [8]. Model data can be prepared with FeynRules [9, 10]. The resulting amplitudes can be processed in computer algebra systems such as FORM [11, 12], including its color package [13], or Mathematica [14] with tools such as FormCalc [15] and FeynCalc [16, 17, 18, 19, 20]. For multi-loop calculations, tools also address the intermediate tasks of topology classification, denominator mapping, or the preparation of reduction input. Examples include DIANA [21], q2e/exp [22, 23], Reduze 2 [24], TopoID [25], HepLib [26], tapir [27], FeAmGen.jl [28], the multiloop extension of FeynCalc, and the higher-order amplitude-generation tool ANATAR [29]. The organization of data across these stages requires compatible conventions for momenta, fields, and denominator indices. In particular, constructing integral families independently of diagram generation can require recovering relations that are already accessible from the diagrammatic representation.
In this work we present DiaGen (pronounced [ˈdiː.a.ɡɛn]). The name derives from the German Diagramm-Generator. The program combines diagram generation with the construction of a symmetry-aware map of integral prototypes. The program is built on a general collection of graph-theoretical algorithms, including graph generation, canonical labelling, automorphism searches, connectivity and component analysis, and subgraph construction. Some of these routines have applications beyond the workflow documented here. For instance, the library contains algorithms for selecting the heavy subgraphs required in a large-mass expansion by subgraphs [30]. This functionality is not exposed as a supported workflow in the present release. The library also provides algorithms for constructing cuts of scalar diagrams, decomposing them into subdiagrams, and adapting their momentum routing. While cut-based diagram selection is already available, a dedicated interface for generating and exporting cut integrals is planned for a future release.
Instead of treating topology classification solely as a separate step after algebraic reduction, DiaGen records propagator structures and their relationships during the generation workflow.
It produces FORM-readable expressions, identifies graph-equivalent prototypes and admissible subprototypes, and exports a compact set of integral-family descriptions and momentum mappings for use with the IBP reduction program Kira [31, 32, 33]. Conversely, DiaGen can reconstruct a scalar diagram from the propagator momenta and mass labels of an existing integral-family sector. The original code was developed about 25 years ago and has since been used and further developed in a number of multi-loop projects [34, 35, 36, 37, 38]. An account of the use of an earlier version of DiaGen/IdSolver in multiloop calculations can be found in Ref. [39].
From a technical point of view, DiaGen is implemented in C++ and relies on well-established libraries for symbolic manipulation and structured input: GiNaC [40, 41] (with CLN [42]) and yaml-cpp [43]. The build system follows standard Autotools conventions.
The way research software is written and used is changing rapidly. AI coding agents based on large language models now write, run, and modify analysis code with little human intervention. Their output is probabilistic: the same request can lead to different code or results. Precision calculations, by contrast, require every intermediate step to be exact and repeatable. A natural division of labour is therefore emerging, in which the agent orchestrates the workflow — preparing input files, running programs, and checking results — while well-defined computational steps are delegated to deterministic tools. Diagram generation is such a step. A program used in this way must produce identical output for identical input, so that any change in the output can be attributed to a change in the input or in the program, and can be detected by a plain file comparison. DiaGen meets this requirement: repeated runs of the same version with the same input produce byte-identical amplitudes, prototype definitions, and Kira configurations (§ 8). Its inputs and outputs are plain-text files that can be read, generated, and compared by both humans and automated tools.
This article is organized as follows. § 3 introduces the graph-theoretic conventions and the integral objects used by DiaGen. § 4 demonstrates the program workflow using representative examples, including the specification of model and kinematics inputs. § 5 describes the inverse Kirchhoff problem, its implementation, and the interface for drawing graphs from integral families. § 6 explains the generated output, and § 7 documents the template macros used to construct propagators, wavefunctions, and interaction vertices. § 8 discusses reproducibility and the use of DiaGen in agent-driven workflows. Benchmarks are presented in § 9, followed by recommendations for practical use in § 10. Installation instructions are given in § 11, and the scope and limitations of the present release are summarized in § 12. We conclude in § 13.
Preliminaries
We fix notation and terminology used throughout the paper and summarize the objects constructed by DiaGen: graphs/topologies, diagrams with field and mass assignments, momentum routings, and the integral objects used for matching and IBP reduction. For general graph-theoretic aspects of Feynman diagrams, see Ref. [44].
Graphs, topologies, and diagrams
We use a multigraph , allowing parallel edges and self-loops. A connected Feynman diagram has interaction nodes and explicit degree-one external nodes. Internal edges join interaction nodes, whereas external edges join an interaction node to an external node and carry the external fields and momenta. This convention makes edge orientations and momentum assignments uniform across internal and external lines [44].
In DiaGen we distinguish the following objects:
A topology, i.e. the graph structure at fixed loop order and external legs, without field or mass assignments.
A diagram, obtained from a topology by assigning fields to edges such that each vertex matches an allowed interaction of the model (including statistics such as fermionic signs).
A scalar diagram, i.e. a topology with mass labels assigned to its edges. A scalar diagram can be obtained from a diagram by forgetting the field labels while retaining the masses and the momentum routing, if assigned. It can also be constructed directly from propagator data without a model-specific diagram.
For bookkeeping, DiaGen equips topology edges with an orientation. Physical expressions are invariant under consistent changes of these conventions. An incidence specifies one endpoint of an edge at a vertex. The degree of a vertex counts its incidences, so that a self-loop (an edge with both endpoints at the same vertex) contributes two. In reconstructing a topology from propagators, we refer to an endpoint not yet assigned to a vertex as an unassigned incidence or incidence slot.
Momentum routing via spanning trees
External momenta are fixed by the process definition and satisfy one overall momentum-conservation relation, which we use to eliminate one momentum. A momentum routing assigns to each internal edge a momentum such that momentum conservation holds at each internal node.
DiaGen constructs routings using spanning trees [44]. A spanning tree is a connected acyclic subgraph containing every vertex of . For a connected graph it contains edges, so the number of edges outside the tree is . Each such edge (a chord) defines a fundamental cycle together with the unique tree path between its endpoints. We assign an independent loop momentum to each chord. Loop momenta are then propagated along tree paths with signs fixed by the chosen edge orientations. External momenta are distributed along the unique tree paths connecting external legs to the eliminated leg. Different spanning-tree choices lead to equivalent routings related by linear redefinitions and loop-momentum shifts.
Integral families, sectors, and topology minimization
After applying projectors and performing Lorentz and color algebra (in our setup with FORM and its package color), amplitudes are expressed as linear combinations of scalar integrals. A standard integral family is characterized by propagators and integer indices ,
where is the loop order, is the space-time dimension, and are linear combinations of loop and external momenta, respectively, and is the mass associated with denominator . The term denotes the Feynman prescription, with . The sector label is defined below. For independent external momenta, the loop-dependent bilinears are ($1 \leq i \leq j \leq lk_i \cdot p_r, ). In generic kinematics their number is
A complete integral family spans this space, with purely external scalar products treated as coefficients. If the physical denominators are independent but fewer than , one can complete them with independent numerator bilinears or with suitable auxiliary inverse propagators. The former convention is used in the prototype representation of DiaGen introduced below. When physical denominators are linearly dependent, a partial-fraction step may instead be necessary. The sector identifier commonly used in IBP systems is
Here is the Heaviside step function, equal to one for and zero for . For a fixed integral family, a sector is specified by the subset of propagators with positive indices. A top-level sector denotes a designated maximal sector of that family. It need not have the same number of physical lines as the top-level sector of another family. Subsectors follow by removing one or more denominators from the positive-index set. In graph-based prototype generation, the corresponding operation is the contraction of eligible propagator edges, subject to connectivity, loop-order, and the exclusion of massless vacuum components.
Minimizing the number of distinct topologies is essential for efficient reductions. A classical approach is based on graph invariants such as the Nickel index [45] and efficient algorithms for its computation [46]. Software supporting such topology minimization includes Alibrary [47], Feynson [48], and tapir.
Prototypes in DiaGen
For fast matching and symmetry handling, DiaGen uses a slightly more specialized integral object than a generic family, the prototype,
Here is the number of physical propagators (), and denote the denominators of the defining prototype, with positive denominator powers . The remaining entries represent a basis of independent numerator scalar products with non-negative powers . In the integral-index notation, these numerator powers are represented by the negative indices . The map identifies the scalar product associated with each numerator entry: denotes one of the bilinears or selected to complete the basis of Eq. (2).
This notation describes integrals with all physical propagators of the defining prototype present. The integral families exported by DiaGen use the more general indexing convention introduced in § 3.3, where the indices of physical denominators may take arbitrary integer values. The auxiliary numerator entries, however, are expressed directly as irreducible scalar products (ISPs), rather than as inverse propagators. They are selected by elimination of the scalar products that can be expressed in terms of the physical denominators and the remaining bilinears. A different completion of the basis, for example by auxiliary denominators of the form , can be obtained by an algebraic change of basis, with the corresponding transformations of the numerator expressions and integral indices. A user-selectable basis completion is a natural extension of the current interface. In particular, propagators of the defining prototype may have zero or negative indices, corresponding to absent denominators or numerator factors, respectively. Thus, the exported integral representation also accommodates subsectors and more general numerator structures. The prototype identifier ID is an internal label, not a sector number or an IBP master-integral index.
From scalar diagrams to prototypes. The conversion from a scalar diagram to a prototype removes internal edges that do not carry loop momentum, since their denominators depend only on external kinematics. Edges carrying identical momenta up to a sign and the same mass are represented by a single denominator. The powers of the original denominators can be added together. When equal momentum squares occur with different mass labels, alternative prototypes are constructed by retaining one representative of each momentum class for each admissible choice of mass. This provides the representations needed for subsequent partial fractioning. In all cases the correspondence between the surviving prototype edges and the original scalar-diagram edges is recorded. These operations remove redundant denominators of the indicated kind, but do not constitute a general test of linear independence of quadratic forms.
The program tests for massless vacuum components and rejects diagrams whose unique candidate prototype contains such a component. When several alternative prototypes are generated, massless vacuum candidates may be retained, for example in connection with partial fractioning. This graph-based criterion is not a general test of scalelessness under arbitrary external kinematics. The prototype algorithms discussed below operate on the reduced structures. In particular, the integral-comparison routines require one-particle-irreducible prototypes (those that cannot be disconnected by cutting a single internal edge) without self-energy insertions in the sense of the implemented structural test.
Graph isomorphisms and combinatorial symmetry factors
An isomorphism between two topologies is a bijection of their vertices preserving the multiplicities of edges joining each pair of vertices. An isomorphism of a topology with itself is called an automorphism. External-leg constraints and, when appropriate, field or mass labels further restrict the allowed permutations. To avoid repeated searches over arbitrary vertex numberings, DiaGen constructs a canonical labelling, i.e. a representative of the graph independent of its initial numbering.
The algorithm follows the partition-refinement approach to graph isomorphism [49, 50]. A partition divides the vertices into disjoint nonempty subsets, called cells. For a simple graph, a partition is equitable if the number of neighbours in any given cell is the same for every vertex of another fixed cell (including the cell itself). In a topology with multiple edges and self-loops, DiaGen refines using a generalized degree that also distinguishes the multiplicities of the adjacencies and the presence of self-loops. Starting from an initial ordered partition, successive refinement splits cells whose vertices differ according to these invariants. The ordering of cells is maintained by a deterministic rule. If each cell contains one vertex, the partition is called discrete and defines an ordering of the vertices. Otherwise, one vertex in a non-singleton cell is separated into its own cell (individualization) and refinement is repeated. Branching over the remaining choices gives a search tree of discrete partitions. Among the leaves of this tree the lexicographically smallest adjacency representation defines the canonical topology. Permutations between orderings with the same adjacency matrix are automorphisms. For scalar diagrams, induced edge orderings are compared with their mass labels, and ties are resolved using the external-momentum labelling. Edge orientations are recorded separately as signs in the edge map.
Illustration of partition refinement. Figure 1 illustrates this procedure for the topology of the two-loop diagram used again in § 5. For the purpose of canonical topology labelling, field assignments, mass labels and momenta are disregarded. The vertex names in panel (a) only serve to identify the vertices in this example. Initially, all eight vertices are in the same cell. Since the external and internal vertices have degrees one and three, respectively, the first refinement separates these two sets (b). The internal vertices are further distinguished by their adjacency to external vertices (c). In the resulting partition, has two neighbours in the cell , whereas and each have only one. Splitting the cell and subsequently distinguishing the external vertex from and gives the equitable partition in (d).
Figure 1. Illustration of canonical topology labelling by partition refinement. Vertices of the same colour belong to the same partition cell. Colours do not denote particle species or masses. (a) Initial partition and vertex names. (b) Separation according to vertex degree. (c) Refinement according to adjacency to external vertices. (d) Equitable partition, with three remaining two-element cells. (e) Individualization of (magenta). (f) Discrete partition after further refinement. The alternative choice yields the same canonical adjacency representation.
where we omit the ordering of the cells for clarity. No further adjacency-based splitting is possible at this stage. Individualizing in (e) distinguishes from , which in turn separates from . The resulting partition (f) is discrete. The alternative choice gives an ordering with the same adjacency matrix: the two choices are related by the automorphism . Thus the ambiguity can be resolved with two leaves in this example, rather than by comparing all possible vertex orderings. The panels are a schematic refinement sequence, not a prescription for the order in which active cells are processed.
The external vertices are interchangeable in this example of an unlabelled topology. For the internal vertex automorphism group relevant to diagram generation, however, the initial partition instead contains each external vertex as a separate singleton cell. In this example, fixing the external vertices individually makes the internal vertex automorphism group trivial.
Combinatorial factors. The symmetries relevant to a Feynman diagram are not the same as those of its associated scalar diagram: field assignments must be preserved, and the specified external nodes must remain fixed. During diagram generation, the algorithm orders the field assignments on parallel edges and self-loops so that indistinguishable permutations are not generated repeatedly. A complete assignment is compared lexicographically with its images under the internal vertex automorphism group. Only the representative of each orbit is retained, and the number of vertex permutations leaving the ordered field configuration unchanged is counted at the same time. This is the order of its stabilizer.
Let count occurrences of the same field in the interaction at vertex , and let denote the multiplicity of each class of identical parallel propagators or identical self-loops (with the field and conjugate-field assignments taken into account). Let count the self-loops carrying a self-conjugate field. The combinatorial weight used by DiaGen is
The parallel-line factors are counted once during the traversal of the diagram. The factors of two arise because the two incidences of a self-conjugate self-loop can be interchanged. The numerator is the vertex-normalization factor associated with the multiplicities of identical fields in the model interaction. It is not an additional automorphism factor. For instance, two identical parallel lines between fixed vertices give a factor in the denominator, independently of possible vertex permutations. With conventional vertex rules that already include the identical-field factorials, the model templates must compensate the numerator in Eq. (6). The familiar inverse diagram symmetry factor is then obtained. This convention is important when comparing amplitudes with those of another generator such as QGRAF. The fermionic sign is determined separately from fermion chains and is not part of the positive combinatorial weight.
Example of a combinatorial weight. Consider the four-loop two-point diagram in Figure 2 with four quartic vertices in a massive real scalar theory. All seven internal propagators carry the same self-conjugate field. The two external momenta, in the all-incoming convention, are and and both external edges are attached to A. There are three contributions to the denominator of Eq. (6). The two parallel edges between C and D are identical and give . The self-loop at B gives . The identity and the transposition constitute the internal vertex automorphism group preserving the field assignment, so . These contributions give the order of the combinatorial symmetry group,
Figure 2. Contributions to the combinatorial symmetry factor of a four-loop two-point diagram in massive real scalar theory. (a) The diagram with interaction vertices , , , . Momentum enters at and exits through the second external leg. (b) Permutation of the two identical edges joining and (factor 2!). (c) Exchange of the two incidences of the self-conjugate self-loop at (factor 2). (d) The internal vertex automorphism (group order 2 including the identity). Highlighted edges and vertices identify the respective operations. All internal propagators have the same field and mass assignment.
With conventional vertex rules the diagram weight is therefore . In the convention of Eq. (6), the four identical fields at each of the four vertices give instead . For example, if the conventional vertex rule is for the interaction , the model template includes the compensating factor at each vertex. This recovers the conventional contribution multiplying the rest of the integrand. The example also illustrates why counting vertex automorphisms alone is insufficient for the symmetry factor of a diagram with multiple edges or self-loops.
Integral equivalences and the prototype map
Graph equivalence versus integral equivalence. For scalar integrals, an equivalence may exist even when the corresponding mass-labelled graphs are not isomorphic. The relevant criterion is whether one set of denominator momenta can be transformed into the other, up to individual reversals and a mass-preserving permutation of the denominators. Let and collect the independent loop and external momenta of one prototype, respectively, and let and denote the corresponding bases of a second prototype with the same and . Write for the momentum on internal edge of the first prototype and for that on edge of the second. Their masses are denoted by and , respectively. Both prototypes have physical denominators, and is a bijection between their internal edge sets. For generic kinematics, a sufficient condition for an equivalence of the two denominator sets is
for every internal edge . The integer matrix is unimodular (), so that the loop integration measure is unchanged. The matrix specifies shifts of the loop momenta by external momenta. The matrix describes an allowed invertible change of the external momentum basis that preserves the kinematic invariants and external mass assignments. In the vacuum case, and the external-momentum terms are absent. The permutation matches denominators of equal mass, and each sign allows for reversal of the momentum on a matched edge. These signs are immaterial for quadratic denominators but must be retained when constructing the momentum map. With denominator powers permuted accordingly and the numerator transformed by the same substitution, the integrals coincide. This criterion explains why graph isomorphism alone need not give the smallest set of integral representatives. Consider the two four-loop vacuum topologies in Figure 3, an example of a Whitney twist. Both have four vertices and seven edges, but their vertex-degree multisets are and , respectively, so they cannot be isomorphic. Nevertheless, both admit the same set of propagator momenta (up to individual signs),
Figure 3. Two non-isomorphic four-loop vacuum topologies related by a Whitney twist, following Fig. 1 of Ref. [24] and Eq. (4.8) of Ref. [39]. Although their vertex-degree multisets differ, they admit the same seven denominator momenta, Eq. (9). With matching masses they correspond to the same integral prototype.
To see this, denote the left, upper, right and lower vertices of either panel by , respectively. In both topologies, assign to the two edges from to , to the edge from to , and to the horizontal edge from to . In panel (a), assign from to and to the two edges from to . In panel (b), assign to the two edges from to and from to $c. Momentum conservation holds at every vertex in both routings. For equal masses, or corresponding mass labels in these routings, the sets of quadratic denominators coincide. The integrals are therefore identical for corresponding denominator powers and the same numerator in this common momentum basis. The canonical momentum comparison described below can identify this equivalence without explicitly generating Whitney twists.
Vacuum and two-point prototypes. For these classes the program constructs a canonical integral labelling, by comparing momentum distributions rather than merely graph connectivity. Consider a prototype with loops and internal edges. The algorithm tries subsets of internal edges as candidate carriers of independent loop momenta. Momentum conservation at the internal vertices gives a linear system for the remaining edge momenta. Choices for which the system does not have full rank are rejected. The remaining choices enumerate the routings in which a basis of loop momenta is carried by individual propagators. Changes of this basis incorporate shifts by other loop and external momenta.
For multiloop vacuum prototypes, the loop-momentum names and relative signs are permuted, and each denominator momentum is normalized up to an overall sign. The resulting lists of coefficient vectors are sorted. The algorithm selects a preferred distribution by first minimizing the sum of the absolute values of its momentum coefficients, then comparing the ordered momentum patterns and finally the mass patterns lexicographically. For two-point prototypes, the same independent-edge search is used with the external momentum-conservation relation imposed. In this case a recursive partition search normalizes the propagators under momentum permutations and sign changes: loop and external momentum names begin in separate cells. Choosing a lexicographically maximal momentum pattern refines the cells according to positive, zero and negative coefficients. The procedure continues on the remaining propagators, with ties resolved using mass labels. The chosen canonical labels contain the original edge indices and their orientation signs, so that equal representations also provide an explicit denominator correspondence. The vacuum case with a single independent loop uses the simpler graph-based labelling.
For vacuum and propagator-type prototypes the implementation is designed to provide a unique integral representation within its class of admissible propagator structures and momentum transformations. This does not assert uniqueness of the individual transformation (a representative can itself have symmetries), nor does it identify integrals related solely by IBP, partial fractions or special kinematic identities.
Higher-point prototypes. For three or more external legs the implemented comparison instead uses canonical mass-labelled graph representations, with an additional treatment of vacuum components. The decomposition into biconnected components, i.e. blocks separated by articulation vertices, permits vacuum attachments to be compared separately from the part carrying external momentum. An articulation vertex is a vertex whose removal disconnects a connected graph. In particular, the position at which a vacuum component is attached need not distinguish integral representatives. For fewer than four legs the external momentum names do not enter the separate momentum-labelling comparison. External mass labels are still retained. For four legs the comparison permits the three double transpositions (12)(34), (13)(24) and (14)(23) if they preserve the external mass pattern. In the all-incoming convention these preserve the usual Mandelstam invariants by momentum conservation. Beyond four legs the external momentum labels are retained. These restrictions reflect the implemented matching rules, rather than a general search over all kinematically allowed transformations. Consequently, in the multileg case equivalent integrals with different graph structures may remain in the prototype map.
Construction of the prototype map. The map is populated concurrently with diagram generation. For each new candidate prototype, the comparison described above is used to look for an existing representative. If one exists, the edge correspondence gives the momentum substitutions required to express the diagram in that representative. Otherwise a new entry is created. For every inserted prototype, subsets of internal edges are then considered for contraction, starting with the largest allowed number of removed edges. Contraction merges the endpoints of an edge. If a proposed contraction would remove a self-loop, including a self-loop created by earlier contractions in the same subset, the subset is discarded. This preserves the loop number. The search excludes the implemented massless vacuum and auxiliary-component cases and applies any configured selection criteria. The children option bounds the search from below in the number of surviving denominators, with the loop number as the minimum.
Every surviving subprototype is compared with the entries already stored. A new representative is inserted only if no match is found. An existing subprototype may therefore be reached from several distinct parent prototypes or from several edge contractions of the same parent. Together with the momentum and index mappings, these relations form a directed acyclic graph ordered by the number of physical propagators. This organization permits terms from different diagrams to be expressed in common integral representations before IBP reduction and allows cancellations to become visible at that stage.
Example of the successive construction of the map. Figure 4 illustrates the interplay between diagram and prototype generation for a set of two-loop contributions to the massive-quark two-point function. The small field-assigned Feynman diagrams are shown next to their corresponding prototypes. Consider first the diagram associated with PR0. After assigning momenta and converting its scalar diagram to a prototype, DiaGen inserts PR0 at level and generates its admissible subprototypes (blue arrows). In particular, PR7, PR5 and PR6 occur at level . Contractions of these structures lead to lower levels. Entries with more than one incoming arrow are shared representatives rather than separately stored copies of each contraction. The next diagram shown, associated with PR7, has a propagator structure that is already present as a subprototype of PR0. Consequently, its contribution can be mapped to PR7 without introducing another entry or repeating the construction of its descendants.
Figure 4. Successive construction of the prototype map during diagram generation for an illustrative set of two-loop massive-quark two-point diagrams. The small field-assigned diagrams are placed next to their corresponding prototypes. The level denotes the number of distinct physical propagators in a prototype. Light-blue prototype edges denote massless propagators and black internal edges massive ones. Blue and orange arrows mark contraction relations associated with the branches originating at PR0 and PR8, respectively. Shared descendants are stored only once. The two maximal prototypes PR0 and PR8 determine integral families into which the contributions shown can be mapped.
A subsequent diagram leads to PR8, a second five-propagator prototype whose internal mass pattern is inequivalent to that of PR0. Its subprototype relations are shown by the orange arrows. The contractions leading to PR5 and PR6 reuse existing entries, while PR10 introduces a new structure at level . Further contractions also give PR9 at level , which was not present in the first branch. In particular, PR1 at level can be reached from both top-level prototypes via several paths. The diagrams shown next to PR6 and PR10 can subsequently be matched to these entries. For the illustrated set of contributions, PR0 and PR8 are the two maximal prototypes, and two complete integral families suffice to accommodate these contributions, with the subprototype and momentum maps specifying how the lower structures are embedded. The labels PR0, PR1, . . . are prototype identifiers, not sector identifiers or a loop-order classification. The order of their assignment need not follow the order of the levels in the figure.
The key feature is that the map is available during diagram generation: a diagram can match a subprototype even if no earlier Feynman diagram has had precisely that propagator structure. The two branches in the figure also show how the construction avoids introducing a separate family for every diagram. The number of representatives depends on the implemented equivalence and contraction criteria and on the configured subprototype cutoff. The example does not imply that two families suffice for arbitrary two-loop processes.
Momentum maps and residual symmetries. The canonical edge labellings provide signed edge correspondences between matched prototypes. For parent–child relations, the original momentum vectors on the surviving parent edges are equated to the corresponding vectors on the child edges, including the orientation signs. After imposing external momentum conservation, Gaussian elimination gives the substitutions between the two momentum bases. The matching rules and scalar-product remappings are exported in FORM format. In addition, mass- and external-label-preserving graph automorphisms of a prototype, including permutations of identical parallel lines, induce symmetry transformations within that prototype. The program retains one transformation per distinct permutation of the internal denominators and constructs its momentum substitution in the same way. The associated identity relates the original integral to the transformed one, including its numerator structure. This internal symmetry search should be distinguished from the canonical integral comparison between different prototypes.
Algebraic relations arising from linearly dependent denominators may require additional partial fractioning with the supplied FORM procedures. Further equivalences, particularly for multileg integrals, can be identified by algorithms based on the Feynman-parameter representation, such as the method of Pak [51, 52]. In the present workflow, Kira can search for such remaining symmetries at the reduction stage. Thus the map performs substantial topology minimization during generation, without claiming global minimality for arbitrary integral families. Finally, projector-based workflows mapping diagrams to form factors or helicity amplitudes are well established (see, e.g., Refs. [53, 54, 55]).
Using DiaGen
We illustrate the main interfaces of DiaGen using two representative processes. The examples establish the input conventions and show how the generated amplitudes and prototype definitions are used in subsequent processing.
Example A:
Job file. The main purpose of the job file jobs.yaml is to define a process of incoming and outgoing particles. The following job file is provided in examples/ggH.
#jobs.yaml
jobs:
- generate_diagrams:
loop: 2
children: 5
output_form: "form"
draw_graphs: "false"
draw_protos: "false"
parallel_form: 1
incoming_fields: [A, A]
outgoing_fields: [H]
internal_fields_max: [[H, 0]]
flag_loop_particles:
- {particles: [Q], symbol: "nh"}
- {particles: [q], symbol: "nl"}
The options are explained in the following:
The option
loop: 2generates diagrams at the specified loop order, given by a nonnegative integer. This option is required.The option
children: 5controls the lower bound on the number of physical propagators retained when generating subprototypes. A larger positive bound restricts the search and usually reduces the run time, whereas a smaller bound permits more extensive subprototype matching. In the present implementation,children: 0, which is also the default, selects an automatic procedure: generation starts with a large cutoff and can reset it according to the first matched diagram. This is not equivalent to requesting every admissible subprototype. The chosen setting therefore affects the completeness of the prototype map and should be reported with benchmark results. A practical procedure for choosing the cutoff is described in § 10.The option
output_formselects the format of the processed amplitude output:form(default) ormath(Mathematica format). The option does not change the format of the initially generated diagram expressions, which remain FORM-compatible. The subsequent algebraic processing also continues to use FORM.The option
draw_graphsdraws Feynman diagrams and diagram topologies usingneatofrom Graphviz. It takes the valuestrueorfalse. The default isfalse. Drawing significantly slows down the generation.The option
draw_protosgenerates prototype drawings in thepicturesdirectory, using filenames of the formPR<N>.pdf. The default isfalse.
The option
read_protosloads an existing prototype map from the amplitude directory for reuse in subsequent diagram generation. Previously identified prototypes can be reused, while unmatched structures are inserted into the map according to the ordinary prototype-generation procedure. Thus, this option does not freeze the prototype map or guarantee an identical set of prototypes when changing the process. The default isfalse.
The option
parallel_formtakes a non-negative integer. A positive value selects the parallel FORM processing layout and specifies the default concurrency of the generated scripts. Settingparallel_form: 0(the default) selects serial processing. DiaGen generates the corresponding scripts but does not execute FORM during diagram generation.
The option
incoming_fields: [A, A]takes a list of incoming particles.
The option
outgoing_fields: [H]takes a list of outgoing particles.
The option
internal_fields_max: [[H, 0]]takes a list of pairs. The first entry of the pair is the name of the particle and the second entry is an integer number. The program DiaGen discards diagrams if the number of specified particles is bigger than the integer number. Only internal particles are considered.
The option
internal_fields_min: [[H, 0]]takes a list of pairs. The first entry of the pair is the name of the particle and the second entry is an integer number. The program DiaGen discards diagrams if the number of specified particles is lower than the integer number. Only internal particles are considered. Both options use the canonical field name, i.e. the second entry of the correspondingfieldpair inmodel.yaml. For example, a field defined as[QBar,Q]must be selected usinginternal_fields_min: [[Q,1]]rather thaninternal_fields_min: [[QBar,1]].
The option
min_one_fieldrequires at least one internal propagator to carry one of the specified field types. For example,min_one_field: [[Q, 1], [q, 1]]retains diagrams containing an internal heavy or light quark propagator. Unlikeinternal_fields_min, the conditions are combined using a logical OR, and only the field names of the pairs are used.
The option
flag_loop_particlesassigns symbolic counters to closed fermion loops of specified field types. Each entry contains a list of particle names and a corresponding symbol. For example,{particles: [Q], symbol: "nh"}introduces the counternh, which can be used in the subsequent FORM calculation. This option labels contributions but does not filter the generated diagrams. Usefermion_loops_minandfermion_loops_maxto restrict their total number.
The optional settings
fermion_loops_minandfermion_loops_maxselect diagrams according to the number of closed fermion chains. An omitted bound imposes no restriction in that direction. These options do not constrain external open fermion chains. For example, setting both bounds to 1 retains only diagrams containing exactly one closed fermion loop.
The options
cut_fieldsandno_cut_fieldsselect diagrams by the field content of allowed cuts. A diagram is retained if a compatible cut exists that contains all requestedcut_fieldsand contains none of the fields listed inno_cut_fields. For an example, the job file inexamples/bottom-decayrequestscut_fields: [lepton,neutrino]andno_cut_fields: [bottom]. These options select the original diagrams. They do not export individual cut configurations or apply cutting rules to the propagators. The optionscut_fieldsandno_cut_fields, as well as the particle lists inflag_loop_particles, use the canonical field names. For example,cut_fields: [Q]selects cuts containing the field defined by[QBar,Q], whereascut_fields: [QBar]does not match this canonical name.
The option
open_chain_photonselects diagrams according to whether a chosen boson is attached at an external endpoint of a selected open fermion chain. It takes the fields identifying the chain, the boson name, andkeep: withorkeep: without. It does not select arbitrary internal attachments along the chain.
open_chain_photon:
fields: [mu]
boson: A
keep: without
Here fields identifies the fermion-chain field types, boson specifies the boson to check, and keep determines whether matching diagrams are retained or discarded. The accepted values are with and without.
The option
open_chain_massreplaces the mass label of internal propagators on selected open fermion chains. A chain is selected if it contains at least one of the listed fields. The internal propagators of these fields along the chain are then assigned the specified mass label instead of the mass defined inmodel.yaml. External legs and closed fermion loops are not affected.
open_chain_mass:
fields: [mu]
mass: 0
The replacement enters both the generated propagators, through the macro %m, and the scalar diagrams used for prototype matching. The value 0 sets the selected lines massless. Both fields and mass are required.
The option
two_particle_vertex(default: 0) specifies the exact number of two-particle vertices allowed in a diagram. All other diagrams are discarded.
The option
counter_term_order(default: 0) retains only those diagrams whose total counterterm order is exactly equal to this value. All others are discarded. The counterterm order may be specified in the model file.
The option
output_filechanges the name of the generated amplitude file. By default, DiaGen usesoutput.diagen. When specifying a different filename, the supplied FORM procedures must be adapted accordingly. In particular,TreatAmplitude.prccontains
a reference to output.diagen for the momentum-mapping procedure, which is not automatically updated by this option.
Options that filter diagrams based on additional information during topology generation:
one_particle_irreducible: falseA topology is called one-particle irreducible if cutting any of the internal edges does not lead to a disconnected topology. Setting this option to true retains only one-particle irreducible topologies. By default, this option is set tofalse.The option
no_tadpolesexcludes topologies containing tadpole subgraphs. These are subgraphs connected to the remainder of a diagram through a single vertex and carrying no net external momentum. The default is true. The filter is graph-theoretic and should not be confused with the subsequent evaluation of scaleless integrals.The option
no_loopsexcludes graph self-loops, i.e. internal edges whose source and target are the same vertex. This restriction does not exclude diagrams containing ordinary closed cycles or diagrams of nonzero perturbative loop order. The default is true.no_self_energies: falseA topology is said to have a self-energy insertion if there exists a proper subgraph that can be disconnected from the topology by cutting two edges such that the removed component does not contain external nodes. By default, this option is set tofalseto allow for self-energy insertions.on_shell: trueA topology is called on-shell if the corresponding graph is devoid of self-energy insertions on the external edges. By default, this option is set to true.
The job-file parser additionally accepts the keys allow_disconnected, qgraf_style, and qgraf_model. They are reserved for internal and legacy use, are not part of the validated workflow described here, and should not be used in production calculations.
Model file. The user has to provide a directory config with a file named model.yaml. See for example:
#model.yaml
model:
- name: "ggH"
fields:
- {field: [A, A],
propagator: "DV(v%sl%e,v%tl%e,%p,%m)",
wavefunctions: ["Eps(v%vl%l,%p,cOli%l)",
"EpsStar(v%vl%l,%p,cOli%l)"]}
- {field: [CBar, C],
anticommuting: "yes",
propagator: "DG(%p,%m)"}
- {field: [QBar, Q],
anticommuting: "yes",
fermion: "yes",
mass: "M",
propagator: "SF(%c,%p,%m)"}
- {field: [qbar, q],
anticommuting: "yes",
fermion: "yes",
propagator: "SF(%c,%p,%m)"}
- {field: [H, H],
mass: "MH",
propagator: "DS(%p,%m,1)",
wavefunctions: ["1","1"]}
interactions:
- {interaction: [QBar, Q, A],
vertex: ["G(%c,%i3)*cOlT(cOli%l1,cOli%l2,cOli%l3)"]}
- {interaction: [qbar,q, A],
vertex: ["G(%c,%i3)*cOlT(cOli%l1,cOli%l2,cOli%l3)"]}
- {interaction: [CBar, C, A],
vertex: ["GhostV(%p1,%i3)*(i_*cOlf(cOli%l1,cOli%l2,cOli%l3))"]}
- {interaction: [A, A, A],
vertex: ["VVV(%p1,%i1,%p2,%i2,%p3,%i3)*
(-1/6*i_*cOlf(cOli%l1,cOli%l2,cOli%l3))"]}
- {interaction: [A, A, A, A],
vertex: ["(+d_(%i1,%i2)*d_(%i3,%i4)*(-1/24*
(cOlf(cOlj%v,cOli%l1,cOli%l3)*cOlf(cOlj%v,
cOli%l2,cOli%l4)+cOlf(cOlj%v,cOli%l2,cOli%l3)*
cOlf(cOlj%v,cOli%l1,cOli%l4)))+d_(%i1,%i3)*
d_(%i2,%i4)*(-1/24*(cOlf(cOlj%v,cOli%l1,cOli%l2)*
cOlf(cOlj%v,cOli%l3,cOli%l4)+cOlf(cOlj%v,cOli%l3,
cOli%l2)*cOlf(cOlj%v,cOli%l1,cOli%l4)))+d_(%i1,%i4)*
d_(%i2,%i3)*(-1/24*(cOlf(cOlj%v,cOli%l1,cOli%l2)*
cOlf(cOlj%v,cOli%l4,cOli%l3)+cOlf(cOlj%v,cOli%l4,
cOli%l2)*cOlf(cOlj%v,cOli%l1,cOli%l3))))"]}
- {interaction: [QBar, Q, H],
vertex: ["(-1)*(%m1)*delta(cOli%l1,cOli%l2)"]}
The main options are explained in the following:
The option
fieldsis used to define the fields of the particles.
The option
interactionsdefines the allowed interactions between particles. Vertices with up to 10 legs can be generated. However, the vertex-template macros support only single-digit leg indices (1–9), so the tenth leg cannot be accessed through these macros.
The option
order: N, where N is a positive integer, assigns a counterterm order to an interaction. It is used together with the job optioncounter_term_order.
The option
field: [QBar,Q]specifies the antiparticle and particle identifiers, respectively. Both identifiers may be identical for self-conjugate fields. Internally, the second entry defines the canonical field name shared by the particle and antiparticle. For example,[QBar,Q]has the canonical name Q, which is used by several diagram filters and in generated expressions.
The option
anticommuting: yesinstructs DiaGen to treat the particle as an anticommuting field. The default value isno.
The option
fermion: yesinstructs DiaGen to treat the particle as a fermion. The default value isno.
The option
mass: Massigns a mass label to a field. If the option is omitted or empty, the field is treated as massless and the internal mass label is set to 0. Consequently, the macro%mexpands to 0 for a massless field.
The option
propagator: SF(%c,%p,%m)is used to define the field propagator.
The option
wavefunctions: [...]accepts a list of two or four elements. With two entries, the first and second specify the incoming and outgoing wavefunctions, respectively. For distinct particle and antiparticle identifiers, these templates are reused for both fields.With four entries, separate wavefunctions can be specified: the first and fourth entries correspond to the incoming and outgoing particle, respectively, while the third and second entries correspond to the incoming and outgoing antiparticle, respectively.
Whether a field is self-conjugate is determined by the field identifiers, not by the number of wavefunction templates. Identical particle and antiparticle identifiers define a self-conjugate field.
The option
interaction: [QBar,Q,H]specifies the field content of an allowed interaction vertex, using the identifiers defined in the model.
The option
vertextakes the user-defined Feynman rule for the vertex.
The attributes anticommuting and fermion serve different purposes. The former specifies Grassmann statistics, while the latter identifies fermionic fields for the corresponding fermion-chain treatment. For example, ghost fields are anticommuting but are not assigned ordinary fermion-chain semantics.
For conventional vertex Feynman rules, the identical-field factorials in the numerator of Eq. (6) must be compensated in the model templates. Every interaction vertex and internal line contributes one factor of the imaginary unit by default. To compensate a single such factor in a FORM vertex template, include (-i_)*, where i_ is the predefined imaginary unit in FORM.
Kinematics file. The file kinematics.yaml, located in the config directory, specifies the external kinematics and their algebraic relations. While this file is optional for diagram generation, it is required for the complete FORM and Kira workflow described in this paper. Without it, DiaGen does not generate the corresponding kinematic declarations and replacement rules needed for the supplied FORM procedures, and the exported Kira configuration lacks the necessary kinematic information. Users omitting this file must provide these definitions separately.
An example is given below:
#kinematics.yaml
kinematics:
incoming_momenta: [p1, p2]
outgoing_momenta: [p3]
momentum_conservation: [p3, p1+p2]
kinematic_invariants:
- [M, 1]
- [mQ2, 2]
- [s, 2]
scalarproduct_rules:
- [[p1, p1], 0]
- [[p2, p2], 0]
- [[p1+p2, p1+p2], s]
mass_replacements:
- [M^2, mQ2]
symbol_to_replace_by_one: s
This file is used to generate replacement rules for diagram kinematics. In the present version, the external momenta are restricted to the label format p1, p2, p3, …. The labels k, k1, k2, k3, … are reserved for internal loop momenta. DiaGen currently always eliminates the last momentum in lexicographical ordering, which has to be respected when specifying momentum conservation. For two-point functions, the incoming and outgoing momentum must be assigned the same name. The options are briefly explained:
The option
incoming_momentatakes a list of incoming momenta.
The option
outgoing_momentatakes a list of outgoing momenta.
The option
momentum_conservationreplaces the momentum defined in the first input, through the expression defined in the second input.
The option
kinematic_invariantsdefines the kinematic symbols required by the generated expressions and exported integral families. Each entry is a pair consisting of the symbol name and its mass dimension. Relevant mass parameters and the invariants appearing inscalarproduct_rulesandmass_replacementsmust be included. Mass parameters belonging to fields not used in the generated expressions need not be listed.
The option
scalarproduct_rulesdefines all kinematic relations. Each relation is given as a pair: the first element is a pair of momenta, and the second element is the value of their scalar product.
The option
mass_replacementsis required for the interface to Kira: squares of masses as defined in the model must be replaced by new variables for proper integral-family definitions.
The option
symbol_to_replace_by_onecan be used to set one kinematic symbol to one.
Having prepared these files, the working directory should contain the following files:
jobs.yaml
config
config/model.yaml
config/kinematics.yaml
To run the diagram generation, DiaGen is started with the name of the job file as command-line argument:
diagen jobs.yaml
Example B:
The following input files are provided in examples/ggQQBar.
Job file.
#jobs.yaml
jobs:
- generate_diagrams:
loop: 1
children: 2
parallel_form: 1
output_form: "form"
draw_graphs: "true"
draw_protos: "true"
incoming_fields: [A, A]
outgoing_fields: [Q, QBar]
flag_loop_particles:
- {particles: [Q], symbol: "nh"}
- {particles: [q], symbol: "nl"}
Model file. The model file for this example is obtained from that of § 4.1 by changing the model name to ggQQBar, removing the Higgs field [H,H] and the interaction [QBar,Q,H], and adding external wavefunctions to the heavy-quark field definition. The modified entry in the fields list reads
- {field: [QBar, Q],
anticommuting: "yes",
fermion: "yes",
mass: "M",
propagator: "SF(%c,%p,%m)",
wavefunctions: ["U(%p,%c,cOli%l)","V(%p,%c,cOli%l)",
"VBar(%p,%c,cOli%l)","UBar(%p,%c,cOli%l)"]}
All other field definitions and QCD interaction templates are unchanged. The four wavefunction entries specify the incoming quark, outgoing antiquark, incoming antiquark, and outgoing quark, respectively, following the convention described in § 4.1. The complete model file is supplied in examples/ggQQBar/config/model.yaml.
Kinematics file.
#kinematics.yaml
kinematics:
incoming_momenta: [p1, p2]
outgoing_momenta: [p3, p4]
momentum_conservation: [p4, p1+p2-p3]
kinematic_invariants:
- [M, 1]
- [mQ2, 2]
- [s, 2]
- [t, 2]
- [u, 2]
scalarproduct_rules:
- [[p1, p1], 0]
- [[p2, p2], 0]
- [[p3, p3], M^2]
- [[p1+p2, p1+p2], s]
- [[p1-p3, p1-p3], t]
- [[p2-p3, p2-p3], 2*M^2-s-t]
mass_replacements:
- [M^2, mQ2]
symbol_to_replace_by_one: s
The following listings illustrate the generated output for a representative diagram. Diagram identifiers such as d33 and m33 are assigned during generation. Repeated runs of the same DiaGen version with the same input produce identical output, but these identifiers, the edge orientations, and the printed momentum expressions may change when the model, the job options, or the program version are changed.
Example output for d33.
#output.diagen
*--#[ d33 :
* topology: ./pictures/t6.pdf
*
* internal fields: A A Q A
*
* detailed description:
*
* 0: 0 -> 7, p1
* 1: 4 -> 7, A -> A, -p3-k
* 2: 5 -> 7, A -> A, -p1+p3+k
* 3: 1 -> 6, -p4
* 4: 4 -> 6, Q -> QBar, k
* 5: 5 -> 6, A -> A, p4-k
* 6: 2 -> 5, p2
* 7: 3 -> 4, -p3
#define nf "0"
#define nO "1"
#define nh "0"
#define nl "0"
g d33 =
+36*(+1)
*UBar(p3,0,cOli7)
*G(0,v4l1)*cOlT(cOli7,cOli4,cOli1)
*SF(0,-k,M)
*G(0,v6l5)*cOlT(cOli4,cOli3,cOli5)
*V(p4,0,cOli3)
*VVV(p2,v5l6,p1-p3-k,v5l2,-p4+k,v5l5)*(-1/6*i_*cOlf(cOli6,cOli2,cOli5))
*VVV(p1,v7l0,-p3-k,v7l1,-p1+p3+k,v7l2)*(-1/6*i_*cOlf(cOli0,cOli1,cOli2))
*Eps(v7l0,p1,cOli0)
*DV(v4l1,v7l1,-p3-k,0)
*DV(v5l2,v7l2,-p1+p3+k,0)
*DV(v5l5,v6l5,p4-k,0)
*Eps(v5l6,p2,cOli6)
;
*--#] d33 :
Example output for m33.
#output.diagen
*--#[ m33 :
* associated prototype(s):
#define NPROTO "1"
#define PROTO1 "PR19"
* momentum shift(s):
id DS(k+p3,0,n1?)*DS(k-p1+p3,0,n2?)*DS(k,M,n3?)*DS(k-p4,0,n4?) =
PR19*DS(k+p3,0,n1)*DS(k-p1+p3,0,n2)*DS(k,M,n3)*DS(k-p4,0,n4)
*replace_(p1,p1,
p4,-(-p4),
p2,p2,
p3,-(-p3),
k,k);
*--#] m33 :
Getting-to-Know Example
In this example, we illustrate the complete workflow from diagram generation to the preparation of scalar integrals for IBP reduction. We consider the one-loop process , using the example directory examples/ggQQBar included in the DiaGen source distribution. The example contains the required model, kinematics, job configuration, and FORM procedures.
The corresponding model, kinematics, and job configuration were introduced in the preceding example.
Input files. The working directory contains the job file jobs.yaml and the directories config and form. The config directory contains model.yaml, specifying the field content and interactions, and kinematics.yaml, defining the external momenta, momentum conservation, and kinematic invariants.
The form directory contains the procedures used for the subsequent algebraic processing:
ColorFactors.prc declarations.h splitDS.prc
color.h FeynmanRules.prc TreatAmplitude.prc
The file FeynmanRules.prc defines the additional algebraic rules required to process the model-dependent expressions generated by DiaGen. The file TreatAmplitude.prc specifies the treatment of the amplitude, including the projectors used to extract the desired form factors or squared matrix elements.
The file declarations.h contains declarations of the symbolic objects introduced in the model and used during the FORM calculation. The files color.h and ColorFactors.prc provide the color-algebra conventions and simplification procedures. For standard QCD applications, these files can typically be reused without substantial modifications.
The file splitDS.prc provides rules for partial fractioning scalar propagator expressions when required. In contrast to the graph-based prototype matching performed by DiaGen, this is an algebraic preprocessing step carried out within the FORM workflow.
For applications beyond the supplied QCD examples, the user must adapt the relevant FORM procedures, in particular FeynmanRules.prc and TreatAmplitude.prc, to the chosen theory and observable.
Diagram generation. From the example directory, the diagram generation is started by executing
diagen jobs.yaml
Upon successful completion, the working directory contains the following files and directories:
amplitude config form kira_interface
compute diagen.log jobs.yaml pictures
The directory amplitude contains the generated diagrams and their associated expressions. In particular, amplitude/output.diagen stores the diagram contributions in a human-readable, FORM-compatible representation.
For each diagram, DiaGen records the field assignments, momentum routing, symmetry factor, and fermion sign. The corresponding prototype mappings specify how the scalar propagator structures are related to the selected integral representatives.
The directory pictures is used for visualizations of diagrams, topologies, and prototypes. Drawing is enabled in the supplied example through draw_graphs: true and draw_protos: true. Since drawing introduces additional computational overhead, both options are typically disabled during large production runs.
The directory kira_interface contains the generated integral-family definitions and kinematic information for subsequent IBP reduction. The subdirectory PRall provides a combined configuration containing the selected integral families, while directories of the form reduce_PR<N> contain configurations for reductions associated with individual prototype families.
In the present example, the relevant prototype families are labelled PR15 through PR19. Their numerical identifiers depend on the generated prototype map and are not universal identifiers of the corresponding integral topologies.
Algebraic processing with FORM. The directory compute contains the scripts and configuration files for processing the generated amplitude:
auto-sum.frm collect_integrals.sh form.set
printPR.frm sum_parallel.sh tmp
The central FORM program is auto-sum.frm. It reads the generated diagram expressions, applies the user-defined algebraic procedures and projectors, and prepares the scalar-integral expressions required for the subsequent reduction.
Parallel processing is selected during diagram generation by setting parallel_form to a positive value in jobs.yaml. The supplied example uses parallel_form: 1, which generates the parallel processing scripts. The FORM calculation must subsequently be started explicitly.
For a parallel calculation, we enter the compute directory and execute
cd compute
./sum_parallel.sh -p100 Born
Here, Born denotes the projector defined in form/TreatAmplitude.prc. The option -p100 requests up to 100 parallel FORM processes and should be adjusted to the available computational resources.
After successful execution, the processed amplitude is stored in compute/sum1l.Born.sav.
Alternatively, serial processing requires setting parallel_form: 0 in jobs.yaml and regenerating the diagram output before running the following command from the compute directory:
form -d Projector=Born auto-sum.frm
The serial and parallel processing layouts should not be mixed. In particular, the serial command must not be executed on intermediate files already processed and removed by the parallel workflow.
Structure of the amplitude treatment. The supplied TreatAmplitude.prc procedures separate the process-dependent projection from the subsequent algebraic processing. The procedure takes three arguments specifying the loop order, the gauge choice passed to the Feynman-rule substitutions, and the projector name. In the example, the projector FF contracts the gluon polarization vectors with a Lorentz and color tensor to extract a scalar form factor. In the example, Born instead inserts the conjugate Born amplitude and implements the polarization and spin sums required for the interference with the generated amplitude. The projector name selected when starting the FORM calculation must agree with a projector defined in the procedure.
The remaining steps are largely common to the two examples. After the projection and the loop-order-dependent phase normalization, the procedure simplifies the color structures, applies the Feynman-rule substitutions and evaluates the Dirac traces. It then normalizes scalar propagators, performs partial fractioning where necessary, applies the momentum transformations supplied by DiaGen, and imposes momentum conservation and the kinematic relations. Factors independent of the loop momenta are extracted from the scalar propagator representation. Finally, the generated prototype-matching rules express the loop-dependent scalar products and propagators in terms of the selected integral families. When adapting an example to another process, the projector and its normalization are therefore the principal observable-dependent modifications. The common processing steps can generally be retained, provided the field conventions, kinematic substitutions and model-dependent algebra are compatible.
Preparation of IBP reductions. After the algebraic processing has finished, the scalar integrals appearing in the resulting expressions must be collected and assigned to the generated integral families.
This step is performed by executing
./collect_integrals.sh Born
from the compute directory. The argument Born identifies the previously processed projector.
The script collects the relevant scalar integrals and prepares the corresponding Kira job files using the integral-family definitions generated by DiaGen.
The reduction configurations are stored in the kira_interface directory. For the present example, the individual configurations correspond to the prototype families PR15 through PR19.
These configurations can subsequently be used to perform the IBP reductions with Kira, without requiring a separate manual reconstruction of the integral families from the original diagrams.
Choice of generation options. The example uses the following principal options of the generate_diagrams job:
loop children parallel_form
output_form draw_graphs draw_protos
incoming_fields outgoing_fields flag_loop_particles
The option loop: 1 selects the one-loop contribution to the process. The option children: 2 specifies a lower bound on the number of physical propagators retained during subprototype generation.
The choice of children influences the extent of the prototype map and therefore the computational cost of prototype construction and matching. A larger bound generally restricts the number of subprototypes considered, whereas a smaller bound permits a more extensive search for matching relations.
For matching the physical sectors generated for a given process and loop order, a practical choice is the smallest number of physical propagators among the sectors found in a preliminary run with a sufficiently large cutoff (see § 10). For large multiloop processes, the difference between a restricted and an extensive prototype search can be substantial, as discussed in § 9.
The option output_form selects the output format of the processed amplitude, while the initial diagram expressions remain FORM-compatible. The settings draw_graphs and draw_protos control graphical output. Both are enabled in the supplied example but can be disabled to avoid unnecessary overhead.
Finally, flag_loop_particles introduces symbolic counters for selected closed fermion loops. These counters can be used during the subsequent FORM processing to separate contributions according to their fermion-loop content.
Adapting the examples to a new process. For a process in an existing theory, one can start from the closest supplied example. In jobs.yaml, specify the incoming and outgoing fields, the loop order, and any restrictions on the generated diagrams. In config/model.yaml, add any missing fields and interactions, including the external wavefunctions required by the process. The template conventions are described in § 7. The ordering of external momenta in config/kinematics.yaml must agree with that of the external fields in the job file. The independent invariants, momentum-conservation relation, scalar-product rules, and mass replacements must be adapted consistently.
For a new observable, the FORM projector in TreatAmplitude.prc must be specified by the user. For a new theory, the declarations, Feynman-rule substitutions and, where applicable, the color-algebra and partial-fractioning procedures must also be adapted to the model. It is useful to validate the normalization and field conventions with a tree-level or other known low-order amplitude before generating higher-loop contributions. The generated diagram expressions and integral-family definitions can then be inspected separately before starting the algebraic processing and the subsequent IBP reduction, as in the workflow above.
Together, these steps demonstrate how DiaGen connects the generation of field-labelled Feynman diagrams with the construction of scalar integral families and the preparation of IBP reductions in a common workflow.
Graph reconstruction from propagator momenta
The conventional diagram-generation workflow starts with a graph and determines momenta that obey momentum conservation at its vertices. Conversely, DiaGen can reconstruct a connected scalar diagram from the momenta and mass labels of an existing set of propagators. We call this the inverse Kirchhoff problem. In particular, it allows graph representations to be recovered directly from integral-family sectors in the format used by Kira, without supplying a field-theory model or regenerating the amplitude. The object reconstructed is a scalar diagram in the sense of § 3.1, not a model-specific diagram.
Formulation of the inverse Kirchhoff problem
Suppose that the momenta of all proposed internal and external edges are specified by coefficient vectors in a common independent momentum basis,
Here counts all internal and external edges, is the th basis momentum, is the number of independent basis momenta, and is the integer coefficient of in the momentum of edge . For a connected graph with external legs, the basis consists of loop momenta and independent external momenta, so that . The input determines the edge momenta and mass labels , but not the endpoints of the edges. The task is to find the topology of a connected scalar diagram and its oriented incidence matrix satisfying
For an ordinary internal edge, the entries of at its two endpoints are and . All other entries vanish. Each external edge has one free internal endpoint and a degree-one external vertex, at which no conservation condition is imposed. A self-loop has cancelling incidences. Mass labels are carried along as edge attributes. They do not affect the momentum test.
With edges, Euler’s relation gives
where external degree-one vertices are not included in . The reconstruction assumes that the supplied symbols form an independent basis and that all reconstructed internal vertices have degree at least three. For vacuum graphs the corresponding relation is .
The inverse problem need not have a unique solution: different connected multigraphs can have the same specified momentum set. The implementation enumerates candidate incidence assignments and selects the first connected representative according to the ordering of scalar diagrams for the subsequent orientation step. This selection should not be confused with a general uniqueness theorem.
User interface and a two-loop example
The draw_diagrams job reads Kira integral-family and kinematics files. By default it processes all entries in the top_level_sectors lists of all families in the specified file. The relevant example configuration is stored in examples/kira_draw_all_top_sectors. The paths below are relative to a working directory containing the config/ subdirectory. A minimal jobs.yaml is
jobs:
- draw_diagrams:
integralfamilies: config/integralfamilies.yaml
output_dir: drawn_diagrams
output_format: both
The integralfamilies key gives the integral-family file. The optional kinematics key overrides the default path to kinematics.yaml in the same directory as that file. The optional sectors key restricts the calculation to explicitly specified family/sector pairs. The sector must be a subsector of one of the family’s top-level sectors. The external_masses list, if provided, assigns masses to external legs in incoming-then-outgoing order. By default these are zero. The output_dir default is drawn_diagrams. The output_format choices are edges, pdf, and both (the default).
For a concrete two-loop example relevant to , consider the following integral family, in which the first six entries are physical propagators and the seventh is an auxiliary denominator:
integralfamilies:
- name: SIX_LINE
top_level_sectors: [63]
propagators:
- ["k1", "M2"]
- ["k2", "0"]
- ["k1+p1", "M2"]
- ["k1-p2", "M2"]
- ["k1+k2+p1", "M2"]
- ["k1+k2-p2", "M2"]
- ["k1+k2", "0"] # auxiliary
The bitmask 63 = selects exactly the first six propagators. Therefore, the auxiliary seventh entry is not reconstructed as an edge. Five selected lines have mass label M2, and the line carrying is massless. The accompanying kinematics file reads
kinematics:
incoming_momenta: [p1, p2]
outgoing_momenta: [p3]
momentum_conservation: [p3, p1+p2]
Thus the external momenta entering the graph are , and , with . The three external edges and six selected internal propagators give . With independent symbols , Eq. (12) predicts five internal vertices and loops.
Writing the six selected propagator momenta as
the corresponding reconstruction is illustrated in Figure 5. Since there are unassigned incidences and five internal vertices of degree at least three, every internal vertex in this example must be trivalent. The reconstructed graph contains two independent cycles and no internal bridge (an internal edge whose removal would disconnect the graph).
Figure 5. Stepwise illustration of the inverse Kirchhoff reconstruction for the two-loop example corresponding to sector SIX_LINE/63. Panel (a) shows the three external edges before any internal vertices have been identified, with incoming momenta , and outgoing momentum . The six internal propagator momenta are given in Eq. (13). The auxiliary denominator is excluded. Panels (b)–(f) display one successful branch of the recursive search. In each step the red dot marks the internal vertex identified at that stage, and the signed momentum labels on the incident edges sum to zero. The successive local conservation combinations are in (b), in (c), in (d), in (e), and in (f). After the final step all edge incidences have been assigned and the connected graph is complete. Solid light-blue lines denote massless edges, black propagator lines carry mass label M2, and the dashed external line represents the Higgs leg. A separate post-processing step determines globally consistent edge orientations.
The supplied input also contains a FOUR_LINE family with top_level_sectors: [60, 51], representing additional sectors which the default job processes in the same way. To select individual sectors instead, one can use
jobs:
- draw_diagrams:
integralfamilies: config/integralfamilies.yaml
sectors:
- {family: SIX_LINE, sector: 63}
- {family: FOUR_LINE, sector: 60}
output_format: edges
Running either job with diagen jobs.yaml produces, for example, drawn_diagrams/SIX_LINE_63.edges. When PDF output is enabled, it also writes drawn_diagrams/SIX_LINE_63.pdf. With edge-list output it additionally writes the combined drawn_diagrams/diagrams.edges. The .edges format records the node count and an oriented edge list with mass labels, as well as comments identifying the momentum and the family/sector. External edges are included. The graphical output is an illustration of the reconstructed connectivity, whereas the edge list retains the explicit momentum annotations. PDF drawing requires Graphviz. The default job reconstructs the top-level sectors SIX_LINE/63, FOUR_LINE/60, and FOUR_LINE/51. A more involved example is provided in examples/kira_draw_all_ top_sectors_6L-5P. It reconstructs the top-level sector of a six-loop five-point family with 18 physical propagators, six massless and twelve massive (top-level sector 262143). The momentum assignment in this example is based on the six-loop graph used to illustrate spanning-tree routing in Fig. 4.1 of Ref. [39]. The remaining 27 entries are auxiliary propagators for irreducible scalar products and are not drawn.
Incidence-based reconstruction algorithm
The reconstruction begins by extracting the propagator momenta and mass labels of the selected sector and the external momenta from the input. After eliminating the dependent external momentum using momentum conservation, the momentum expressions are represented as integer coefficient vectors in the common basis of Eq. (10).
Incidence slots. An internal edge contributes two endpoint incidences, while an external edge contributes one unassigned internal incidence: the other endpoint is fixed to its own external degree-one vertex. Hence the initial list of unassigned incidence slots contains each internal edge index twice and each external edge index once, with the external indices preceding the internal ones. The number of internal vertices to be constructed is fixed by Eq. (12).
Recursive vertex search. The recursive search partitions the remaining slots into subsets representing internal vertices. Every proposed subset must contain at least three slots. Writing for the edge associated with incidence slot , the local necessary condition is
This condition is tested coefficient by coefficient in the chosen momentum basis. Fixing the sign of one chosen incidence (the overall sign of the sum is irrelevant) leaves at most sign assignments to test. The subsets are required to contain the first unused incidence, avoiding duplicate vertex-order permutations. The search also bounds the maximum subset size so that at least three incidences remain for each still-unconstructed vertex. Repeated subsets caused by duplicate internal-edge indices are skipped. For every acceptable subset the algorithm marks its slots as used, recurses on the remainder, and backtracks to explore alternative subsets, including after a complete candidate has been found.
Candidate scalar diagrams and representative selection. Once the prescribed number of vertices has been formed, a candidate scalar diagram is constructed only if every slot has been consumed. The incidences determine the topology, and the input mass labels complete the scalar diagram up to the momentum routing. Disconnected candidates are rejected. The surviving scalar diagrams are collected in an ordered set using a graph comparison that accounts for their mass labels. Equivalent candidates under this comparison are retained only once. The first representative in this ordering is selected for the subsequent orientation step. This does not imply that the supplied momentum information determines a mathematically unique graph.
Illustration of the recursive search. Figure 5 illustrates the reconstruction of the two-loop example. Initially, only the external edges with their fixed external endpoints are drawn. The internal propagator momenta are supplied by the integral-family definition. At each recursive step, a trial subset must contain the first still-unused incidence. Since the external indices occur first in the incidence list, the search starts with vertices adjacent to external legs. In this example, the first three accepted vertices are adjacent to , , and the outgoing Higgs leg, respectively. The next two involve only internal edges. This is not, however, a geometric growth algorithm: intermediate pieces need not be connected, as panel (d) illustrates. If a partial assignment cannot be completed, the search backtracks to examine alternatives. In panels (b)–(f), the red dot marks the newly identified vertex, and only its incident momenta are labelled, with signs chosen to give a vanishing sum. Once all incidences have been assigned, the candidate is checked for connectivity. The subsequent orientation procedure is described in § 5.4.
Momentum routing and consistent edge orientations
Topology reconstruction and momentum routing have related but distinct roles. During ordinary diagram generation, DiaGen assigns a new momentum routing from a graph using a spanning tree, as explained in § 3.2. In the inverse problem, by contrast, the momentum expressions are already specified: what remains after constructing the graph is to find a globally consistent orientation of every edge carrying those momenta.
The local test, Eq. (14), only proves that some choice of signs works at each vertex separately. It does not yet guarantee that the two incidences of a shared propagator carry opposite signs. After selecting a candidate scalar diagram, the algorithm therefore determines compatible edge orientations by a depth-first search through the graph. The search starts at an internal vertex adjacent to the first external edge (or at the first vertex for a vacuum graph), keeping one reference edge direction fixed to remove the overall reversal freedom. At each internal vertex the search respects edge orientations already settled at earlier vertices, explores orientations for the remaining incident edges, and tests exact coefficient-wise momentum conservation. It backtracks when the local constraint cannot be satisfied. External degree-one vertices are not subjected to conservation tests, and the orientation of self-loops is irrelevant. If no consistent set of orientations exists, an error is reported for the selected candidate. Otherwise, the reconstructed scalar diagram is returned with edge directions satisfying Eq. (11).
The six-line example makes this last distinction explicit: the labels in Figure 5 use opposite signs for each of at its two endpoints. In particular, the identity at could equally have been found with all signs reversed during the local search, but the global orientation step selects the compatible convention. The post-reconstruction procedure therefore checks and orients the supplied momentum assignment. It does not generate an independent set of loop momenta.
Scope and limitations
The implemented reconstruction is a graph-theoretic consistency test. It does not infer field content or validate whether an interaction is allowed by a given model. It assumes connected graphs without degree-two internal vertices. The draw_diagrams interface requires at least two external legs, although the underlying reconstruction algorithm also supports vacuum graphs. Selected sector entries must represent actual physical edges. Generic irreducible numerator entries cannot automatically be treated as propagator edges. The sector bitmask selects edges, and its set bits must therefore correspond to the intended physical denominators.
The YAML momentum parser supports signed sums of momentum symbols with coefficients and . Expressions with explicit multiplication or parentheses, such as 2*k1 or k1-(p1+p2), are not supported. Zero-momentum edges are rejected. The integral-family list is limited to 63 entries by the interface. These restrictions arise from the implemented reconstruction procedure, not from the Kira format. If the selected momenta cannot give rise to an admissible connected graph, the program reports inconsistent set of momenta.
Although eliminating duplicate subsets and bounding vertex degrees reduces redundant search, the incidence-partition problem remains combinatorial in the worst case. The resulting scalar diagram should consequently be interpreted as one consistent representation of the selected family sector, rather than as a uniquely determined diagram with model-specific field assignments.
Output interpretation
After executing the job file jobs.yaml, DiaGen produces output files stored in four different directories: amplitude, pictures, kira_interface, and compute.
The
amplitudedirectory contains the generated amplitude and the associated prototype definitions. The fileoutput.diagencontains the amplitude in a form suitable for subsequent processing with FORM. The filesPR<N>definition, where N is a nonnegative integer, contain the propagator definitions of the corresponding prototypes.The directory
picturescontains all figures illustrating individual diagrams and prototypes.The directory
kira_interfacecontains integral-family and kinematics definitions for the selected top-level prototype representatives. These are ready to be processed by Kira.The directory
computecontains scripts for the user-defined FORM treatment and projection of the amplitude.
The main output file output.diagen in the directory amplitude contains the amplitude generated with DiaGen. Each term in the amplitude is associated with a diagram and one or more candidate prototypes. This file is ready for further treatment with FORM. Each term is a product of Feynman rules as defined in the model file model.yaml in the directory config. DiaGen multiplies each term with a fermion sign and a symmetry factor corresponding to the diagram. All terms belonging to one fermion chain are written in the correct order.
An automatic FORM script auto-sum.frm is generated which takes the amplitude as input. The compute directory is generated by DiaGen, whereas the form directory containing the model-specific FORM procedures must be supplied by the user. The provided examples include suitable procedures, which may need to be adapted to the process under consideration. In particular, a projector has to be defined in TreatAmplitude.prc. In DiaGen the symbol DS is reserved for a scalar propagator. The user has to provide rules in FeynmanRules.prc to translate user-defined field functions as defined in the model file to DS functions.
An interface to Kira is established by automatically creating the necessary Kira config directory. For each top-level prototype an individual config directory is created. In the generated integralfamilies.yaml files, the physical propagators are listed first and the ISPs that complete the integral-family basis are written as bilinear entries, for example { bilinear: [ [ "k1", "p1" ], 0 ] }. The top-level sector contains only the physical propagators. For the combined Kira configuration PRall, the exported integral families are ordered by decreasing number of propagators in their designated top-level sector, with stable ordering for ties. This changes the order of family entries but not their denominator or mass definitions. Since family order can affect the choice between overlapping mappings, the ordering convention is part of the reproducible output configuration.
After successful execution of the FORM processing step, the generated scripts collect the scalar integrals required by the amplitude and prepare the corresponding Kira reduction jobs.
Model file model.yaml
In DiaGen, the file model.yaml specifies the field content, propagators, wavefunctions, and interaction vertices. These objects are given as template strings that may contain %-macros. During diagram generation, DiaGen assigns unique identifiers to nodes and edges, fixes an orientation for each edge (source target), and determines momenta, masses, field labels, and fermion chains. The templates are then instantiated by replacing the %-macros with the corresponding diagram-specific data. Figure 6 illustrates these ingredients for a representative diagram from the Getting-to-Know example.
Figure 6. Diagram information used to instantiate propagator, wavefunction, and vertex templates in model.yaml. Blue arrows indicate the chosen graph-edge orientations. Momentum arguments substituted into the templates follow the conventions of the corresponding propagators, external wavefunctions, and interaction vertices.
Internal propagator macros. Each internal edge connects a source node to a target node. The edge orientation fixes the graph conventions used for momentum routing and fermion flow. Internal propagator templates support the following macros:
%s: source node number,%t: target node number,%e: edge number,%p: momentum argument of the propagator,%m: propagator mass label,%n: canonical field name assigned to the edge (the second entry of thefieldpair),%c: fermion-chain index,%is,%it: index shortcuts associated with the source and target nodes, respectively.
The momentum supplied through %p follows the propagator conventions of the corresponding field. In particular, for anticommuting fields, its sign may differ from the source-to-target momentum shown in the graph representation.
For example, the propagator template DV(v%sl%e,v%tl%e,%p,%m) constructs Lorentz-index labels from the source node, target node, and edge number, while inserting the propagator momentum and mass.
External wavefunction macros. External wavefunctions use a separate set of macros:
%p: physical external momentum label,%m: mass label of the external field,%v: interaction node adjacent to the external edge,%l: external edge number,%c: fermion-chain index.
Here, %v refers to the interaction node, not to the degree-one external node. For example, the wavefunction template Eps(v%v%l%l,%p,cOli%l) produces Eps(v7l0,p1,cOli0) for the corresponding external leg in the example below. The macros available for external wavefunctions are not interchangeable with those of internal propagators.
Vertex macros (interaction templates). Each interaction vertex is assigned a unique number, and the attached legs are ordered and indexed starting from 1. Vertex templates support:
%v: interaction vertex number,%g: counterterm order assigned to the interaction vertex,%c: fermion-chain index,%ij: shorthand index object for leg ,%lj: edge number of leg ,%pj: momentum entering the interaction vertex through leg ,%mj: mass label of leg ,%nj: canonical field name of leg , rather than necessarily the particle or antiparticle identifier at that endpoint.
In the leg-dependent macros, denotes a single-digit leg index, not a literal character or an arbitrary multi-digit number. For example, %i3 constructs the index associated with the third leg, while %p3 supplies its momentum. The momentum arguments %pj (with replaced by the corresponding digit) are defined as incoming to the interaction vertex, independently of the source-to-target orientation of the graph edges.
These macros provide the diagram-specific information needed to construct interaction vertices, including their Lorentz and color structures.
Starting from the physical diagram in Figure 6a, DiaGen constructs the internal directed graph representation shown in Figure 6b. Nodes and edges carry unique identifiers, and each edge is assigned an orientation (source target). This orientation determines the graph momentum-routing conventions and is used in the treatment of fermion flow.
Given the process kinematics, DiaGen assigns momenta to the edges as illustrated in Figure 6c. The momentum arguments substituted into the model templates depend on their context.
For internal propagators, the momentum may differ by a sign from the oriented graph momentum, in particular for anticommuting fields. External wavefunctions receive the physical external momentum label, whereas momentum arguments in vertex templates are incoming to the corresponding interaction.
For example, the internal edge labelled 4: 4 -> 6 carries momentum in the graph description of the one-loop example, while the corresponding fermion propagator is written as SF(0,-k,M) in the generated amplitude. The difference reflects the propagator momentum convention and does not indicate an inconsistency in the graph routing.
Mass labels are illustrated in Figure 6d and field assignments in Figure 6e. For internal propagators these are accessible through %m and %n, respectively. Fermionic lines are organized into chains (Figure 6f), whose indices are available through %c.
Reproducibility and agent-driven workflows
DiaGen is deterministic: for a fixed program version and fixed input files (jobs.yaml, model.yaml, and kinematics.yaml), every run produces the same diagrams in the same order, with the same field assignments, edge orientations, momentum routings, fermion signs, symmetry factors, prototype labels, and integral-family definitions. We have verified this by running the examples of § 4 repeatedly in fresh working directories, including runs with modified memory-allocation settings, and comparing the resulting amplitude and kira_interface directories byte by byte.
Determinism is not automatic in programs of this kind. Graph algorithms often iterate over containers whose order depends on memory addresses, which change from run to run. While preparing this release, an AI coding agent tasked with checking the reproducibility claims of this paper found exactly such a dependence: fields and vertices were ordered by their addresses in memory. As a result, the diagram numbering within a topology, the orientation of closed fermion loops, and the corresponding momentum labels could differ between two runs of the same job, although the physical content — the number of diagrams and the set of sign and symmetry factors in each topology — was unchanged. The ordering now follows the order in which fields and vertices are defined in the model file.
Deterministic output makes DiaGen well suited as a building block in workflows in which an AI coding agent prepares inputs, runs the program, and processes its results:
Verification by comparison. Two runs can be compared with standard tools such as
diff -r. Any difference indicates a change in the input or in the program and never arises from chance.Regression tests. Reference outputs for the supplied examples can be stored and compared automatically after every modification of the code or the model files, including modifications proposed by an agent.
Separation of tasks. The agent writes and adapts model, kinematics, and
FORMfiles, while the combinatorial core — diagram generation, symmetry factors, fermion signs, and topology identification — is carried out by a tested deterministic program rather than generated anew for each calculation.Traceability. Diagram identifiers such as
d33and prototype labels such asPR19refer to the same objects in every run, so that results, logs, and discussions can refer to them unambiguously.
Determinism concerns repeatability, not correctness: an identical result can still be wrong if the model or the FORM procedures are wrong, and the checks recommended in § 10 remain necessary. Identifiers and orientations may change when the model, the job options, or the program version are changed. Results should therefore be quoted together with the DiaGen version and the input files used.
Benchmarks
Table 1 and Table 2 report the wall-clock run times for the specified example processes as a function of loop order. The timings characterize two different configurations of the prototype search. They should not be interpreted as a direct speed comparison with other diagram generators, since the amount of subprototype processing differs.
| Process | Loop order | 1 | 2 | 3 | 4 | 5 |
| < 1 s | < 1 s | < 1 s | 5 s | 1027 s | ||
| < 1 s | < 1 s | < 1 s | 36 s | – | ||
| < 1 s | < 1 s | 66 s | – | – | ||
| < 1 s | 5 s | – | – | – |
Table 1. Table 1: Wall-clock run times for the preliminary benchmark runs (children: 100) as a function of loop order.
| Process | Loop order | ||||
| 1 | 2 | 3 | 4 | 5 | |
| – | |||||
| – | – | ||||
| – | – | – |
Table 2. Wall-clock run times for the final benchmark runs as a function of loop order, with the cutoff set to the smallest physical sector found in the corresponding preliminary run.
The processes correspond to the example directories HeavyQuarkPropagator (), ggH (), ggQQBar (), and ggQQBarH () of the source distribution, with the loop order and the children setting adjusted as described below. All runs were performed on an x86-64 workstation equipped with an Intel Core i9-10980XE processor (18 physical cores, 36 hardware threads, base clock frequency of 3.0 GHz) and 125 GiB of system-reported memory, running openSUSE Leap 16.0. Diagram and prototype drawing were disabled in both configurations (draw_graphs: false and draw_protos: false).
In the preliminary configuration (Table 1), children is set to a high value, children: 100, to restrict the exploration of contracted subprototypes. This is useful for obtaining an initial diagram and integral-family representation at comparatively low cost.
For the final configuration (Table 2), the cutoff is chosen separately for each process and loop order. Specifically, children is set to the smallest number of physical propagators among the physical sectors identified in the preliminary run, as described in § 10. This is the largest cutoff that still permits contractions down to the smallest of these sectors, so that matching among the generated physical sectors is not excluded by the cutoff. The additional subprototype construction and matching increase the computational cost. Lower cutoffs may be necessary if mappings to further subsectors are required.
Best practice
Enable diagram and/or topology drawing during debugging to visually inspect the generated output. Note that rendering can significantly slow down the generation.
To choose the
childrencutoff for a production run, first perform a preliminary run with a value larger than the number of physical propagators in any generated prototype (e.g.children: 100for the examples considered here). This suppresses the generation of
contracted subprototypes. Determine the smallest number of physical propagators among the sectors obtained in this run. For example, inspect the top_level_sectors entries in the generated kira_interface/PRall/config/integralfamilies.yaml: the number of set bits in each sector identifier gives the number of physical propagators, excluding the auxiliary bilinears. Set children to for the production run. This is the optimal cutoff with respect to the range of contractions needed to match the generated physical sectors: a larger cutoff can miss such relations, whereas a smaller one additionally explores lower subsectors. If mappings involving sectors below are needed, lower the cutoff accordingly. Repeat the procedure when changing the process, loop order or diagram-selection criteria.
To validate that the symmetry factors implied by your Feynman rules agree with those used by DiaGen, generate a tree-level sample by setting
loop: 0. Comparingamplitude/output.diagenwith your expectations provides a direct consistency check.
When DiaGen is run by scripts or AI coding agents, keep the input files under version control, record the program version, and confirm reproducibility by running a job twice and comparing the output directories with
diff -r.
Report the chosen prototype-search cutoff alongside the resulting numbers of generated diagrams, retained prototypes, and exported top-level integral families. A smaller family collection is useful only when the mapping remains valid for all scalar integrals required by the calculation.
Installation
Obtaining DiaGen
The source code of DiaGen is available from the project’s public GitLab repository at https://gitlab.com/diagen-cpp/diagen. For reproducibility, we recommend using the release version 1.0 associated with this publication, available under the corresponding release tag in the repository. Development versions may contain additional features and changes not included in the release.
Prerequisites
Platform requirements
Linux x86_64 or macOS.
Compiler requirements
A C++ compiler supporting the C++14 standard.
Build system requirements
DiaGen is built with the Autotools build system.
Dependencies
DiaGen requires the following libraries:
GiNaCand its dependencyCLN,yaml-cpp,GMP,zlib.
The build system uses Autotools and pkg-config. When regenerating the build configuration, the corresponding pkg.m4 macros must be available.
Diagram and prototype visualization requires Graphviz, including neato. Additionally, Ghostscript (gs) is required to combine individual diagram and topology drawings into the files d-all.pdf and t-all.pdf, respectively. Without Ghostscript, individual drawings can still be generated, but the combined PDF files are not produced.
The supplied amplitude-processing examples require FORM and standard shell and text-processing utilities. Subsequent integration-by-parts reductions require Kira.
Dependencies can generally be installed using the system package manager. When using libraries from nonstandard installation directories, the compiler and linker search paths can be specified through CPPFLAGS and LDFLAGS, respectively, and PKG_CONFIG_PATH can be used to locate package metadata.
The libraries must be compatible with the target architecture and C++ application binary interface (ABI). Using exactly the same compiler for every dependency is not required, provided binary compatibility is maintained.
Compiling DiaGen with the Autotools build system
First run
autoreconf -i
and then compile and install with
./configure --prefix=/install/path
make
make install
where the optional --prefix argument sets the installation prefix.
The source distribution also contains the examples directory, which provides the configuration files and FORM procedures needed to reproduce the calculations discussed in this paper. These examples are not installed by make install. Users should copy the desired example directory from the unpacked source distribution to a writable working directory before running DiaGen.
Scope and limitations
The present diagram generator assumes a set of external fields and propagators with unambiguous field-to-conjugate-field pairing. Vacuum diagrams without external particles, mixed-field propagators, and Majorana-fermion contractions are not handled by the general diagram-assignment algorithm described here. These limitations concern the model classes supported directly by the program and should not be confused with restrictions of the subsequent FORM or IBP reduction steps.
Furthermore, the fermion-chain and sign-handling algorithms assume that each interaction traversed by a fermion chain contains a pair of anticommuting fields. More general multi-fermion contact interactions are not covered by the validated implementation and may require extensions of these algorithms.
Model-specific Lorentz structures, color algebra, and projector definitions are supplied through user-defined templates and FORM procedures. The program organizes the diagrammatic and scalar-integral structures, but it does not automatically validate the physical normalization of arbitrary model inputs. Similarly, graph-based matching identifies equivalences within the implemented representation and is not a proof of global minimality under all possible integral identities.
The graph-theoretical library also includes routines for enumerating heavy subgraphs for large-mass expansions and constructing reduced graphs. A user-facing expansion-by-subgraphs workflow, including the subsequent Taylor expansion and assembly of the amplitude, is outside the scope of this release. Similarly, although the generation options described in § 4.1 allow diagrams to be selected according to the field content of admissible cuts, the construction of individual cut diagrams and their adapted momentum routings is not yet exposed as a dedicated user workflow. Support for the generation and export of cut integral families is planned for a future release.
These restrictions define the scope of the present release. In particular, applications involving more general field mixing or nonstandard fermion contractions require additional validation and, where appropriate, extensions of the underlying generation rules.
Conclusions
We have presented DiaGen, a diagram-generation framework that connects model-level amplitudes to symmetry-aware representations of their scalar-integral content. Its distinctive component is the construction of a prototype map during generation, including graph-based matching, integral-level canonical comparison for vacuum and two-point prototypes, admissible subtopologies, and the momentum and index transformations needed to express contributions in common integral representations. The output combines FORM-readable amplitudes with integral-family and kinematic data suitable for subsequent IBP reduction. Conversely, the inverse Kirchhoff mode reconstructs connected scalar diagrams from integral-family sectors and determines orientations consistent with the supplied momenta.
The examples demonstrate the workflow and the measured cost of different prototype-search settings. The benchmarks also show why the scope of subprototype matching must be specified when quoting generation times. Further quantitative comparisons should separate diagram-generation cost from matching cost and assess the impact of the generated mappings on the downstream integral representation. Such tests provide a reproducible basis for evaluating the method as multiloop calculations become more demanding.
Because its output is deterministic and plain-text, DiaGen can serve as a reliable component of agent-driven workflows, in which AI coding agents orchestrate a calculation while exact steps such as diagram generation and topology identification are delegated to reproducible programs. We expect this division of labour to become increasingly important as such agents are adopted in precision calculations.
Acknowledgments
J.U. thanks Arnd Behring for insightful discussions on diagram generation with QGRAF, and Andrzej Czarnecki, who encouraged us to finalize this work. The work of M.C. was supported by the Deutsche Forschungsgemeinschaft (DFG) through the grant 396021762 - TRR 257: Particle Physics Phenomenology after the Higgs Discovery. The work of M.N. was supported by the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation program grant agreement 101019620 (ERC Advanced Grant TOPUP). The work of J.U. has been supported in part by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) Projektnummer 417533893/GRK2575 “Rethinking Quantum Field Theory” and by the European Union through the European Research Council under grant ERC Advanced Grant 101097219 (GraWFTy). The Feynman diagrams in this paper were drawn with FeynGame [56, 57, 58]. AI tools based on large language models (Claude by Anthropic and ChatGPT by OpenAI) assisted in writing and editing this paper. The authors reviewed and verified all content and take full responsibility for it.
References
- [1]A. Huss, J. Huston, S. Jones, M. Pellen and R. Röntsch, Les Houches 2023 – Physics at TeV Colliders: Report on the Standard Model Precision Wishlist, 2504.06689.arxiv.org/abs/2504.06689
- [2]P. Nogueira, Automatic Feynman graph generation, J. Comput. Phys. 105 (1993) 279.DOI
- [3]P. Nogueira, Feynman graph generation and propagator mixing, I, Comput. Phys. Commun. 269 (2021) 108103.DOI
- [4]T. Hahn and M. Perez-Victoria, Automatized one loop calculations in four-dimensions and D-dimensions, Comput. Phys. Commun. 118 (1999) 153 [hep-ph/9807565].
- [5]T. Hahn, Generating Feynman diagrams and amplitudes with FeynArts 3, Comput. Phys. Commun. 140 (2001) 418 [hep-ph/0012260].DOI
- [6]M. Borinsky, Feynman graph generation and calculations in the Hopf algebra of Feynman graphs, Comput. Phys. Commun. 185 (2014) 3317 [1402.2613].DOI
- [7]J. Braun, FeynGraph - A modern high-performance Feynman diagram generator, PoS LL2026 (2026) 070.DOI
- [8]J. Davies, T. Kaneko, C. Marinissen, T. Ueda and J. A. M. Vermaseren, FORM Version 5.0, 2601.19982.arxiv.org/abs/2601.19982
- [9]N. D. Christensen, P. de Aquino, C. Degrande, C. Duhr, B. Fuks, M. Herquet et al., A Comprehensive approach to new physics simulations, Eur. Phys. J. C 71 (2011) 1541 [0906.2474].DOI
- [10]A. Alloul, N. D. Christensen, C. Degrande, C. Duhr and B. Fuks, FeynRules 2.0 - A complete toolbox for tree-level phenomenology, Comput. Phys. Commun. 185 (2014) 2250 [1310.1921].
- [11]J. A. M. Vermaseren, New features of FORM, math-ph/0010025.DOI
- [12]B. Ruijl, T. Ueda and J. Vermaseren, FORM version 4.2, 1707.06453.arxiv.org/abs/1707.06453
- [13]T. van Ritbergen, A. N. Schellekens and J. A. M. Vermaseren, Group theory factors for Feynman diagrams, Int. J. Mod. Phys. A 14 (1999) 41 [hep-ph/9802376].DOI
- [14]W. R. Inc., “Mathematica, Version 13.1.”
- [15]T. Hahn, Loop calculations with FeynArts, FormCalc, and LoopTools, Acta Phys. Polon. B 30 (1999) 3469 [hep-ph/9910227].arxiv.org/abs/hep-ph/9910227
- [16]R. Mertig, M. Bohm and A. Denner, FEYN CALC: Computer algebraic calculation of Feynman amplitudes, Comput. Phys. Commun. 64 (1991) 345.DOI
- [17]V. Shtabovenko, R. Mertig and F. Orellana, New Developments in FeynCalc 9.0, Comput. Phys. Commun. 207 (2016) 432 [1601.01167].
- [18]V. Shtabovenko, R. Mertig and F. Orellana, FeynCalc 9.3: New features and improvements, Comput. Phys. Commun. 256 (2020) 107478 [2001.04407].DOI
- [19]V. Shtabovenko, R. Mertig and F. Orellana, FeynCalc 10: Do multiloop integrals dream of computer codes?, Comput. Phys. Commun. 306 (2025) 109357 [2312.14089].
- [20]V. Shtabovenko, FeynCalc 10.2 and FeynHelpers 2: Multiloop calculations streamlined, 2512.19858.arxiv.org/abs/2512.19858
- [21]M. Tentyukov and J. Fleischer, A Feynman diagram analyzer DIANA, Comput. Phys. Commun. 132 (2000) 124 [hep-ph/9904258].
- [22]R. Harlander, T. Seidensticker and M. Steinhauser, Complete corrections of Order alpha alpha-s to the decay of the Z boson into bottom quarks, Phys. Lett. B 426 (1998) 125 [hep-ph/9712228].
- [23]T. Seidensticker, Automatic application of successive asymptotic expansions of Feynman diagrams, in 6th International Workshop on New Computing Techniques in Physics Research: Software Engineering, Artificial Intelligence Neural Nets, Genetic Algorithms, Symbolic Algebra, Automatic Calculation, 5, 1999, hep-ph/9905298.
- [24]A. von Manteuffel and C. Studerus, Reduce 2 - Distributed Feynman Integral Reduction, 1201.4330.
- [25]J. Hoff, The Mathematica package TopoID and its application to the Higgs boson production cross section, J. Phys. Conf. Ser. 762 (2016) 012061 [1607.04465].
- [26]F. Feng, Y.-F. Xie, Q.-C. Zhou and S.-R. Tang, HepLib: A C++ library for high energy physics, Comput. Phys. Commun. 265 (2021) 107982 [2103.08507].DOI
- [27]M. Gerlach, F. Herren and M. Lang, tapir: A tool for topologies, amplitudes, partial fraction decomposition and input for reductions, Comput. Phys. Commun. 282 (2023) 108544 [2201.05618].DOI
- [28]Q.-f. Wu and Z. Li, FEAmGen.jl: A Julia program for Feynman Amplitude Generation, Comput. Phys. Commun. 301 (2024) 109230 [2310.07634].DOI
- [29]C. Duhr, P. Mukherjee and A. Vasquez, ANATAR: AN Automated Tool for higher-order Amplitude geneRation, JHEP 04 (2026) 199 [2509.13951].arxiv.org/abs/2509.13951
- [30]V. A. Smirnov, Applied Asymptotic Expansions in Momenta and Masses. Springer, 2002, 10.1007/3-540-44574-9.DOI
- [31]P. Maierhöfer, J. Usovitsch and P. Uwer, Kira—A Feynman integral reduction program, Comput. Phys. Commun. 230 (2018) 99 [1705.05610].DOI
- [32]J. Klappert, F. Lange, P. Maierhöfer and J. Usovitsch, Integral reduction with Kira 2.0 and finite field methods, Comput. Phys. Commun. 266 (2021) 108024 [2008.06494].DOI
- [33]F. Lange, J. Usovitsch and Z. Wu, Kira 3: integral reduction with efficient seeding and optimized equation selection, Comput. Phys. Commun. 322 (2026) 109999 [2505.20197].arxiv.org/abs/2505.20197
- [34]M. Czakon, J. Gluza and J. Hejczyk, Muon decay to one loop order in the left-right symmetric model, Nucl. Phys. B 642 (2002) 157 [hep-ph/0205303].DOI
- [35]M. Awramik and M. Czakon, Complete two loop bosonic contributions to the muon lifetime in the standard model, Phys. Rev. Lett. 89 (2002) 241801 [hep-ph/0208113].DOI
- [36]M. Awramik, M. Czakon, A. Freitas and G. Weiglein, Complete two-loop electroweak fermionic corrections to sin²θ_eff^lept and indirect determination of the Higgs boson mass, Phys. Rev. Lett. 93 (2004) 201805 [hep-ph/0407317].DOI
- [37]M. Awramik, M. Czakon, A. Freitas and G. Weiglein, Two-loop Fermionic Electroweak Corrections to the Effective Leptonic Weak Mixing Angle in the Standard Model, Nucl. Phys. B Proc. Suppl. 135 (2004) 119 [hep-ph/0408207].DOI
- [38]I. Dubovyk, A. Freitas, J. Gluza and J. Usovitsch, Third-order mixed electroweak-QCD corrections to the W-boson mass prediction from the muon lifetime, 2603.06571.
- [39]M. Niggetiedt, Quark Mass Effects in Form Factors and Hadronic Higgs Production, Ph.D. thesis, RWTH Aachen University, 2023. 10.18154/RWTH-2023-11198.DOI
- [40]C. W. Bauer, A. Frink and R. Kreckel, Introduction to the GiNaC framework for symbolic computation within the C++ programming language, J. Symb. Comput. 33 (2002) 1 [cs/0004015].
- [41]J. Vollinga, GiNaC: Symbolic computation with C++, Nucl. Instrum. Meth. A 559 (2006) 282 [hep-ph/0510057].DOI
- [42]B. Haible and R. B. Kreckel, “CLN – Class Library for Numbers.” http://www.ginac.de/CLN.
- [43]YAML, “YAML Ain’t Markup Language.” https://yaml.org.DOI
- [44]Nakanishi, Graph theory and feynman integrals, Gordon and Breach, 1971.
- [45]G. A. J. B. B. Nickel, D. Meiron, Compilation of 2-pt. and 4-pt. graphs for continuous spin models, 1977.
- [46]D. Batkovich, Y. Kirienko, M. Kompaniets and S. Novikov, GraphState - a tool for graph identification and labelling, 1409.8227.arxiv.org/abs/1409.8227
- [47]V. Magerya, “Alibrary.” https://github.com/magv/alibrary, 2021.
- [48]V. Magerya, “Feynson.” https://github.com/magv/feynson, 2020.
- [49]B. D. McKay, Practical graph isomorphism, Congressus Numerantium 30 (1981) 45.
- [50]B. D. McKay, Graph isomorphism, in Encyclopedia of Algorithms, M.-Y. Kao, ed., (Boston, MA), pp. 373–376, Springer US, (2008), DOI.
- [51]A. Pak, The Toolbox of modern multi-loop calculations: novel analytic and semi-analytic techniques, J. Phys. Conf. Ser. 368 (2012) 012049 [1111.0868].DOI
- [52]J. S. Hoff, Methods for multiloop calculations and Higgs boson production at the LHC, Ph.D. thesis, 2015. 10.5445/IR/1000047447.DOI
- [53]T. Peraro and L. Tancredi, Physical projectors for multi-leg helicity amplitudes, JHEP 07 (2019) 114 [1906.03298].
- [54]T. Peraro and L. Tancredi, Tensor decomposition for bosonic and fermionic scattering amplitudes, Phys. Rev. D 103 (2021) 054042 [2012.00820].DOI
- [55]L. Chen, A prescription for projectors to compute helicity amplitudes in D dimensions, Eur. Phys. J. C 81 (2021) 417 [1904.00705].DOI
- [56]R. V. Harlander, S. Y. Klein and M. Lipp, FeynGame, Comput. Phys. Commun. 256 (2020) 107465 [2003.00896].DOI
- [57]R. Harlander, S. Y. Klein and M. C. Schaaf, FeynGame-2.1 – Feynman diagrams made easy, PoS EPS-HEP2023 (2024) 657 [2401.12778].
- [58]L. Bündgen, R. V. Harlander, S. Y. Klein and M. C. Schaaf, FeynGame 3.0, Comput. Phys. Commun. 314 (2025) 109662 [2501.04651].
Machine contribution statement
This work lists 2 machine contributors.
Claude by Anthropic · AI contributor
- Roles
- Writing — review & editing
- Verification
- self-declared at submission
ChatGPT by OpenAI · AI contributor
- Roles
- Writing — review & editing
- Verification
- self-declared at submission
Recorded on the work at submission, not per version. Names and roles are shown as submitted; roles use the CRediT taxonomy.





