Numerical stability of one-loop values
A one-loop value evaluated in binary64 (double precision) can lose digits where the loop reduction cancels: near forward or threshold kinematics, in strongly boosted frames, with many external legs. By default pyAmpliCol returns the value without any statement about its accuracy. This page shows how to ask for an accuracy estimate, how to make a value more accurate, and what each control costs. It applies to virtual corrections and to loop-induced processes alike; what a one-loop result contains is on One-loop matrix elements.
The controls at a glance
The loop numerators are reduced to master integrals by one of two backends, NinjaRS (integrand reduction) and TIRust (tensor-integral reduction) (Reduction backend). A point then passes four safeguards in this order; each acts only on what the previous one left.
| Safeguard | What it does | Default | Cost |
|---|---|---|---|
| Reduction checks | the backend refuses the parts of a point it cannot reduce reliably | on | part of every evaluation |
| Lane rescue | reduces a refused part again in double-double, then at 500 digits | on | only where a part is refused |
| Stability checks | evaluate the point again in other frames: an accuracy estimate | off | about 2.4 times a plain evaluation |
| Rescue policy | evaluates a point that misses its target again in higher precision | off (Python only) | the checks, plus higher levels where needed |
A point that no safeguard accepts is returned with its best available value and the status "best-effort" (Best-effort values of refused points). The first two are on and are switched off; the last two are off and are switched on:
| Safeguard | Python | evaluate option | Run card [evaluation] |
|---|---|---|---|
| Reduction checks | off: reduction_unchecked=True | off: --reduction-unchecked | off: reduction_unchecked = true |
| Lane rescue | off: lane_rescue=False | off: --no-lane-rescue | off: lane_rescue = false |
| Stability checks | on: stability_checks= | on: --stability-... | on: [evaluation.stability_checks] |
| Rescue policy | on: stability= | none | none |
The C, C++, Fortran and Rust interfaces have the first three, with the same defaults, and leave a higher precision to the caller.
Accuracy of a binary64 evaluation
An evaluation without stability checks makes no statement about the accuracy of its value: its status is "success" also where binary64 has lost digits. That happens in extreme kinematics:
- forward or backward scattering, below about \(\lvert t \rvert / s = 10^{-5}\) in the center-of-mass frame:
g g > a gis off by \(2 \times 10^{-6}\) at \(\lvert t \rvert / s = 10^{-5}\) and by \(2 \times 10^{-2}\) at \(10^{-7}\); - frames boosted by \(\gamma \gtrsim 200\) relative to the center of mass;
- nearly degenerate configurations: a pair near its threshold, a nearly planar \(2 \to 3\) point, many external gluons;
- light internal masses (squared masses or invariants below \(10^{-9}\) in the model’s units): keep the rescaled check, and use double-double where binary64 fails;
- strongly suppressed helicity rows of
evaluate_resolved(\(10^{-13}\) to \(10^{-21}\) of the largest row): evaluate them with 60 digits or more.
What to do: ask for the stability checks, evaluate events in their center-of-mass frame, and evaluate a flagged point again in double-double or arbitrary precision, by hand or with a rescue policy. The checks flag such points; at the points measured, the estimate was larger than the error. With an explicit reduction="ninjars", which has no per-point fallback, always ask for the checks on nearly planar \(2 \to 3\) points.
Ask for an accuracy estimate
The recommended stability checks are one rotation of the point, the reduction-direction check (every loop numerator reduced again in a reversed frame) and its rescaled variant (the same at rescaled inputs, which also evaluates the master integrals again):
from math import sqrt
from pyamplicol import ModelSource, Runtime, generate
from pyamplicol.api import VirtualStabilityChecks
def point(m, energy=500.0):
"""A 2 -> 2 point at 1 TeV; m is the mass of both final-state particles."""
p = sqrt(energy**2 - m**2)
return [[energy, 0, 0, energy], [energy, 0, 0, -energy],
[energy, 0.6 * p, 0, 0.8 * p], [energy, -0.6 * p, 0, -0.8 * p]]
loop_sm = ModelSource.from_path("loop_sm", restriction="no_widths")
generate("g g > t t~ [QCD]", "artifacts/stability_ttx", model=loop_sm,
mode="replace")
runtime = Runtime.load("artifacts/stability_ttx")
recommended = VirtualStabilityChecks(rotations=1, reduction_direction=True,
rescaled=True)
result = runtime.evaluate([point(173.0)], mu_r2=1000**2,
stability_checks=recommended)
estimate = result.stability[0]
print(f"{estimate.relative:.1e}", [name for name, _ in estimate.checks])
# 4.3e-14 ['rotation-0', 'reduction-rescaled']
The same checks from the command line, with points.json holding the point above, and as a run-card table that evaluate --card, Runtime.load(options=...) and the native interfaces read:
pyamplicol evaluate artifacts/stability_ttx --momenta points.json --mu-r2 1000000 \
--stability-rotations 1 --stability-reduction-direction --stability-rescaled
[evaluation.stability_checks]
rotation_count = 1 # number of default rotations
reduction_direction = true # reduce every loop numerator again, reversed
rescaled = true # ... at rescaled inputs
The command line prints the same numbers in a table “Stability estimates”. result.stability[i] is a VirtualStabilityEstimate:
| Field | Meaning |
|---|---|
relative | the largest relative estimate over the squared-order sectors, each against its largest Laurent coefficient: the number to compare with a target |
finite, single_pole, double_pole | the relative estimate of each Laurent coefficient |
checks, not_run | each check that ran with its own estimate; checks that could not run, with the reason |
absolute, magnitude, scale | per sector the absolute estimate \(E\) and the scale \(S\) of what cancelled; their largest ratio |
A coefficient with \(\lvert c \rvert \le E\) is zero within the estimate; zeros of loop-induced processes (Landau-Yang, Furry) are reported this way. For a loop-induced process the pole estimates are \(E/S\), because the poles vanish, and the estimate includes a rounding floor for what no check samples (floor_weight, Run card).
Rules for choosing checks:
- Each rotation costs about one more evaluation; the rescaled check adds a fifth to a third. The recommended set costs about 2.4 times a plain binary64 evaluation.
- Avoid a rotation about the beam axis (
"z:..."for beams along \(z\)): it leaves both incoming momenta unchanged and under-reports the error. - Only the rescaled check sees the rounding of the master integrals themselves. Keep it for loops with light internal masses, where one rotation alone has missed errors by orders of magnitude.
VirtualStabilityChecks(..., cross_backend=True)adds an evaluation on the other reduction backend, beside at least one other check (Python and the native interfaces only).- An estimate is not a bound: about 0.1 % of binary64 points lie above their estimate with the recommended set.
result.diagnostics[i].accuracy_established stays False under checks alone; a rescue policy sets it to True when the estimate meets the target. Some points stay False whatever the estimate: a point off its mass shells (Kinematics improvement), or a part of the value that cancels to nothing within its own rounding (the Born-zero helicity rows of a resolved g g > g g). diagnostics[i].uncertified names the reason, and a rescue policy evaluates such a point at its next level instead of accepting it.
Make a value more accurate
Evaluate in a higher arithmetic: arithmetic="double-double" (106 bits, about 32 digits) or arithmetic="arbitrary" with precision= digits (default 500). The same is --arithmetic and --precision on the command line and arithmetic and precision in [evaluation]. These arithmetics use pyAmpliCol’s own Symbolica key, without a personal license (Symbolica and licensing). Both cost more than binary64: use them for the points the checks flag, or let a rescue policy choose them.
# continues "Ask for an accuracy estimate"
exact = runtime.evaluate([point(173.0)], mu_r2=1000**2, arithmetic="double-double")
print(exact.values[0][0].finite)
# 0.717199970092900180310621688131353008807621824486587
Above binary64 the point is first made exactly physical in that arithmetic (Kinematics improvement); binary64 inputs become consistent, not more accurate. To go beyond binary64 accuracy, give momenta on shell and conserving to the digits you want: Decimal values or decimal strings in Python, JSON numbers with all their digits in a --momenta file.
Reduction backend
NinjaRS reduces each loop numerator by integrand reduction; TIRust reduces with tensor integrals, serving every helicity and color amplitude of a loop family with one set, which suits loop-induced processes. Both serve both process types and every arithmetic. Choose one with reduction= on Runtime.load or evaluate, --loop-reduction, or reduction in [evaluation]; the default is the artifact’s [loop] reduction, itself "auto" by default.
"auto"takes TIRust for a loop-induced process and NinjaRS for a virtual correction. A point TIRust refuses or fails is evaluated again on NinjaRS (the per-point fallback), and its diagnostic says so."ninjars"or"tirust"uses that backend for every point, with no fallback. A backend that cannot serve the call is refused before any point is evaluated (ReductionUnavailable, keyreduction-unavailable).
diagnostics[i].reduction records the requested and effective backend.
Target accuracy. reduction_target= (--reduction-target, [evaluation] reduction_target; default 1e-5) is the relative accuracy the backends aim for when they accept or reduce again a part of a point, every squared-order sector against its own size. It is a calibrated acceptance, not a certificate. Binary64 values keep a reduction error of up to about \(10^{-7}\), so a tighter target can be missed in binary64; a target far below what any arithmetic reaches makes refused parts climb every precision and costs time. A value that is not a finite positive number is refused.
Rescue policy
A rescue policy evaluates each point with stability checks and evaluates the points that miss their target again in a higher precision, from their original inputs. Pass stability=VirtualRescuePolicy() to evaluate, or to Runtime.load for every call that names no arithmetic, precision or checks of its own. It exists in Python only. Here the second point is nearly forward (\(\theta = 10^{-7}\)):
# continues "Ask for an accuracy estimate"
from math import cos, sin
from pyamplicol import VirtualRescuePolicy
def forward(m, theta, energy=500.0):
p = sqrt(energy**2 - m**2)
return [[energy, 0, 0, energy], [energy, 0, 0, -energy],
[energy, sin(theta) * p, 0, cos(theta) * p],
[energy, -sin(theta) * p, 0, -cos(theta) * p]]
rescued = runtime.evaluate([point(173.0), forward(173.0, 1e-7)], mu_r2=1000**2,
stability=VirtualRescuePolicy())
print(rescued.statuses, rescued.rescue_counts)
# ('success', 'rescued') {0: 1, 1: 1, 'not met': 0, 'best-effort': 0, 'failed': 0}
print(rescued.rescue[1].arithmetic, f"{rescued.stability[1].relative:.0e}")
# double-double 7e-16
The default policy has four levels, each with the target \(10^{-5}\) on the relative estimate, one fixed rotation and the rescaled reduction check: binary64, double-double, 57 digits, 500 digits. For a loop-induced process under "auto" a NinjaRS binary64 level follows the TIRust one. A call that names a backend (reduction="ninjars" or "tirust") runs every level on that backend.
How a batch runs:
- The first level evaluates every point.
- A point that fails, or whose estimate misses the target, is evaluated again at the next level from its original inputs.
- A point whose estimate grows instead of falling from one level to the next is a numerical zero: it keeps its value with the target not met, and its detail says
not escalated. - At the last level a point keeps its value; a point that failed everywhere is returned best-effort, or failed.
The result’s statuses read "success" (accepted at the first level), "rescued" (at a higher level), "best-effort" or "failed". rescue[i] records the level, the arithmetic, the target, whether it was met, and every attempt with its estimate and backend; rescue_counts counts the points per level, plus "not met", "best-effort" and "failed".
Build your own policy from VirtualRescueLevels, in non-decreasing precision:
# continues "Rescue policy"
from pyamplicol import VirtualRescueLevel
custom = VirtualRescuePolicy((
VirtualRescueLevel("double", reduction="tirust"),
VirtualRescueLevel("double", reduction="ninjars"),
VirtualRescueLevel("double-double", rotations=2, target=1e-7),
VirtualRescueLevel("arbitrary", 40, metric="finite"),
))
VirtualRescueLevel field | Default | Meaning |
|---|---|---|
arithmetic, precision | (required); 500 digits for "arbitrary" | the arithmetic of the level |
rotations | one fixed rotation | a number of default rotations, or rotations as text, e.g. "euler:0.1,0.2,0.3" |
reduction_check | "rescaled" | "none", "reversed" or "rescaled" |
target, metric | 1e-5, "relative" | the target on the estimate: "relative" per sector, "finite" on the finite part, or "scale" (\(E \le \text{target} \times S\), for values that may vanish) |
reduction | "auto" | the backend of the level; a named one has no per-point fallback |
Two levels at one precision must name different backends (as MadLoop’s MLReductionLib order), and only the last level may run without a check; both rules are enforced with a ValueError.
A policy owns the arithmetic, the precision and the checks of each level: together with arithmetic=, a non-default precision= or stability_checks= it is refused with a CompatibilityError, as on evaluate_resolved and the correlated calls. Under a load-time policy, stability_checks=VirtualStabilityChecks() asks for one plain call. A virtual correction is rescued with every pole selection, helicity selection and, at leading color, color-flow selection; a loop-induced process with poles="all" or "none" and helicity selections. An amplitude that vanishes at every point (loop-induced g g > z) fails on NinjaRS in arbitrary precision: keep TIRust, or use the "scale" metric. Never time a benchmark with a policy.
Lane rescue
A backend reduces a point in parts called lanes, one per loop family and Laurent coefficient (Glossary). When it refuses a lane in binary64, the lane rescue reduces that lane alone again in double-double, then at 500 digits; every other lane, and every point without a refused lane, keeps its value bit for bit. It is on by default. A lane refused at every precision fails its point, and the per-point fallback, the rescue policy or the best-effort value then act as usual.
- A rescued lane is about as accurate as an accepted binary64 lane, not double-double accurate; the point’s estimate covers the rescue.
- The first rescue of a runtime prepares the higher-precision reduction, once: from a fraction of a second up to about half a minute, and up to about 640 MB of memory.
lane_rescue=False(--no-lane-rescue,lane_rescue = false) gives pure binary64 evaluations, for instance to time binary64 alone; a point with a refused lane then fails.
diagnostics[i].lane_rescue gives the lanes served per precision.
Kinematics improvement
A point given in binary64 misses its mass shells and momentum conservation by binary64 rounding, and near a degenerate configuration the reduction can amplify that defect beyond the extra digits of a higher arithmetic. So before a point is evaluated in double-double or arbitrary precision, it is moved onto exact conservation and its exact mass shells in that arithmetic, as MadLoop’s ImprovePSPoint:
[evaluation]
kinematics_improvement = "z-shift" # or rescaling, projection, off
kinematics_improvement_binary64 = false # true: also improve binary64 evaluations
| Variant | What it does |
|---|---|
"z-shift" | MadLoop’s default (ImprovePSPoint = 2, beams along \(z\)), finished by the projection where the point is still inexact |
"rescaling" | MadLoop’s ImprovePSPoint = 1, finished by the projection |
"projection" | the minimal-norm projection onto the shells and conservation; exact in every frame |
"off" | no improvement |
The Python keywords (on Runtime.load and every evaluation) and the command-line options have the same names. Binary64 evaluations are unchanged unless you set the binary64 switch; an exact point is evaluated unchanged.
Do not switch the improvement off above binary64: a nearly forward point given in binary64 can then be served far off with no check flagging it.
For each point, diagnostics[i].kinematics records the improvement applied and the relative mass-shell defect of each leg (mass_shell). A point whose legs miss their masses by more than the target allows is still evaluated, but its accuracy is not established. An input too far from a physical point (a conservation defect above \(10^{-6}\) of the summed energies, a shell defect above \(10^{-2}\), or an improvement that would move it by more than \(10^{-2}\)) is evaluated as given, with the warning kinematics-not-improved. To use other bounds, improve the point yourself with pyamplicol.kinematics.improve(..., tolerances=...) and evaluate it with kinematics_improvement="off".
Best-effort values of refused points
A per-point refusal never interrupts a run by default. A point that no configured alternative accepts is evaluated once more without the backends’ own checks and returned with that value, its refusal and an uncertainty, under the status "best-effort". on_failure= (--on-failure, [evaluation] on_failure) chooses:
on_failure | A refused point |
|---|---|
"best-effort" (default) | returned with its best available value and an uncertainty |
"return" | returned as "failed", without a value, at no extra cost |
"raise" | raises EvaluationError |
diagnostics[i].reduction.best_effort is a VirtualBestEffort with the refusal, the relative uncertainty (None when none could be formed) and its source. The uncertainty always includes the recommended checks, run on the refused points only, whatever checks the call asked for; compare it with the call’s own estimate, which can be optimistic for such a value. Only refused points pay for the extra evaluation; under a rescue policy only the last level serves best-effort values.
Nothing is printed per point. result.warnings lists the best-effort and failed points as data, and result.emit_warnings() turns them into one Python warning, NumericalAccuracyWarning. Two refusals are not numerical and have no best-effort value: model parameters the artifact cannot take refuse the call, and a point whose scale crosses a counterterm branch is failed.
Unchecked timing mode
reduction_unchecked=True (--reduction-unchecked, [evaluation] reduction_unchecked = true; default off) drops the backends’ own acceptance and refusal checks, as the most optimistic settings of other one-loop providers do. Each backend then serves almost every point it can give a finite value for. The lane rescue, the per-point fallback, your stability checks and a rescue policy keep working on the unchecked values.
Use it to time the fastest path, never for physics without checks: unchecked values have been measured off by up to \(10^{-2}\) on TIRust and by many orders of magnitude on NinjaRS.
pyamplicol profile times this mode by default, with the lane rescue on; --checked times the checked mode (Profiling).
Measure accuracy over a sample
pyamplicol profile --stability measures how many digits a process keeps in binary64 over flat phase-space points, on both backends, against a double-double reference:
pyamplicol profile artifacts/stability_ttx --stability \
--stability-points 50 --n-core 2
...
| percentile | backend | true digits | |est-true| | est-true med |
| | | | min/med/max | |
...
| 10 % | NinjaRS * | 14.14 | 0.53 / 0.66 / 1.30 | -0.66 |
| | TIRust | 14.70 | 0.75 / 0.89 / 1.40 | -0.89 |
...
The true digits of a value \(v\) against the reference \(r\) are \(-\log_{10}\bigl(\lvert v - r \rvert / \lvert r \rvert\bigr)\) on the finite part, at most 15.95. The table gives them at the worst 1 per mil, 1 %, 10 %, 50 % and 100 % of the points, with the distance of the estimated digits; a second table counts the points the default checks flag and those they miss. The run uses the checked reduction with the lane rescue and one rotation, plus the rescaled check on TIRust’s points ([evaluation.stability_checks] replaces them); refused points enter with their best-effort values. --ground-truth arb takes a 500-digit reference and --samples-output keeps every point (Command-line options).
Limits
- The rescue policy exists in Python only (
VirtualRescuePolicy); the command line, the run card and the C, C++, Fortran and Rust interfaces return the estimate and leave a re-evaluation in higher precision to the caller. It does not apply to resolved or correlated calls. - An artifact whose loop numerators exceed rank \(N+2\) over \(N\) propagators (three or more insertions of effective operators) is reduced by TIRust alone, and its values carry no correctness claim.
- Every estimate is sampled, not proven. In double-double and arbitrary precision, the estimate that guards a point of
"auto"’s NinjaRS fallback is not a bound: strongly suppressed helicity rows near exactly forward kinematics can be served beyond their own target. - A NinjaRS lane whose cancellation was catastrophic keeps about 8 correct digits when it is rescued in binary64; one that loses more than about 100 bits and is not zero comes back near zero, marked
uncertified.
See also
- One-loop matrix elements: what a one-loop result contains.
- Run card: every runtime option.
- Refusals and errors: every refusal key.
- One-loop engine internals: how the safeguards work, with the measurements behind these rules.