Skip to content

rusticol-core: native high-precision evaluation for contracted-color replay; constants at working precision - #26

Open
lsimon125 wants to merge 4 commits into
MadGraphTeam:loopfrom
lsimon125:replay-multiprecision
Open

lsimon125 wants to merge 4 commits into
MadGraphTeam:loopfrom
lsimon125:replay-multiprecision

Conversation

@lsimon125

Copy link
Copy Markdown

Summary

Two fixes to NativeRuntime::evaluate_with_precision (feature symbolica-runtime) for compiled artifacts.

  1. Contracted-color topology replay in double-double and arbitrary precision. Full-colour (and NLC) pure-gluon
    processes always use the contracted-color topology replay, and run_double/run_float rejected it ("compiled/eager
    contracted-color topology replay currently exposes f64"). run_generic_with_color_topology_replay now evaluates the
    materialized sectors at every replay relabelling in the generic precision, routes their summed groups to the physical
    groups (gather_color_topology_replay_generic, mirroring gather_color_topology_replay_samples) and contracts them
    (reduce_color_topology_replay_generic). The group contraction of evaluate_raw_sums_generic is factored into
    contract_groups_generic and shared; run_generic_materialized and the replay share the extracted stage evaluation
    evaluate_generic_stages.

  2. Artifact constants at the working precision. Above 32 digits the results had binary64 accuracy, padded with
    digits, for every compiled artifact (with or without replay). The generic path converted binary64 constants
    (normalization, colour weights, model parameters, masses, source-state factors, replay weights, process-group
    factor) with T::from(f64), i.e. a 53-bit numerica Float, and a Float product is rounded to the smaller
    precision of its factors. RusticolHighPrecisionNumber::from_f64_constant now converts them at the working
    precision (Float::with_val(binary_precision, value); unchanged for DoubleFloat); the generic source fill uses
    masses converted the same way via CarrierMasses. Unit crossing signs and phases are unchanged (numerica
    multiplies by ±1 without rounding).

The constants themselves remain the artifact's binary64 values (as before); this change only stops them from capping
the precision of everything they multiply.

Tests

rust/crates/rusticol-core/tests/compiled_color_topology_replay_precision.rs (runs when
RUSTICOL_COMPILED_COLOR_REPLAY_ARTIFACT points to
pyamplicol generate 'g g > g g' DIR --color-accuracy full --execution-mode compiled): exact massless integer points;
ratios of totals between points cancel the couplings and must equal the exact tree-level ratios of
9/2 (3 − tu/s² − su/t² − st/u²) to ≤ 1e-27 at 32 digits and ≤ 1e-58 at 64 digits; totals agree with binary64 to
≤ 1e-12.

Ratios to the exact analytic values:

before after
g g > g g, 32 digits error: replay exposes f64 4e-33, 7e-33
g g > g g, 64 digits error: replay exposes f64 within 1e-58 (test passes)
u d > u d (no replay), 40 / 64 / 100 digits 1.5e-16 each 5.1e-40 / 2.1e-64 / 5.7e-101
u d > u d, u u~ > g g, 32 digits 4.8e-32, 8.7e-32 unchanged

Run on loop at bae3b9e plus these two commits (candidate build, artifact from that generator): the new test
passes at 32 and 64 digits; compiled_binary64_with_symbolica passes; the 152 rusticol-core unit tests matching
generic/precision/double/float/exact/replay pass (with PYAMPLICOL_TEST_PYTHON set for the Python-producer
round trip). The ratio values in the table were measured with the same two commits on 79df367 and the
u d > u d / u u~ > g g artifacts of that generator.

cargo check -p rusticol-core with default features, symbolica-runtime and loop-v2: no new warnings.

🤖 Generated with Claude Code

lsimon125 and others added 2 commits October 25, 2026 16:45
…e-double and arbitrary precision

Full-colour (and NLC) pure-gluon processes always use the contracted-color
topology replay, and `run_double`/`run_float` rejected it ("compiled/eager
contracted-color topology replay currently exposes f64"), so
`evaluate_with_precision` failed for them.

`run_generic_with_color_topology_replay` evaluates the materialized sectors at
every replay relabelling in the generic precision, routes their summed groups
to the physical groups (`gather_color_topology_replay_generic`, the
counterpart of `gather_color_topology_replay_samples`) and contracts them
(`reduce_color_topology_replay_generic`). The group contraction of
`evaluate_raw_sums_generic` moves into `contract_groups_generic`, shared by
both; `run_generic_materialized` and the replay share the extracted stage
evaluation `evaluate_generic_stages`.

`tests/compiled_color_topology_replay_precision.rs` (artifact from
`RUSTICOL_COMPILED_COLOR_REPLAY_ARTIFACT`) compares ratios of g g > g g totals
between exact massless integer points with the exact tree-level ratios at 32
digits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Arbitrary-precision evaluation (`evaluate_with_precision` above 32 digits)
returned binary64 accuracy padded with digits. The generic path converts the
artifact's binary64 constants (normalization, colour weights, model
parameters, masses, source-state factors, replay weights, process-group
factor) with `T::from(f64)`, which gives a 53-bit numerica `Float`; a `Float`
product is rounded to the smaller precision of its factors, so every result
was rounded to binary64.

`RusticolHighPrecisionNumber::from_f64_constant` converts such a constant at
the working precision (`Float::with_val(binary_precision, value)`; unchanged
for `DoubleFloat`), and the generic source fill uses masses converted the same
way (`CarrierMasses`). Unit crossing signs and phases are left as they are:
numerica multiplies by +-1 without rounding.

The replay test now also checks 64 digits against the exact tree-level ratios.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion of the contracted-color topology replay

`evaluate_resolved_with_precision` on a full-colour (or NLC) pure-gluon
artifact, which always uses the contracted-color topology replay, fell through
`run_resolved_generic` to the paths without the replay relabellings and
returned wrong components without an error: for g g > g g at one point the
32-digit resolved total was 6.36 against 915.33 in binary64.

`run_resolved_generic_with_color_topology_replay` is the generic-precision
counterpart of `run_resolved_f64_with_color_topology_replay_unprofiled`: it
gathers the physical groups of every replay relabelling (the loop of
`run_generic_with_color_topology_replay`, now shared as
`gather_generic_color_topology_replay`) and contracts them per physical
helicity in T (`reduce_color_topology_replay_generic_resolved`). The helicity
bookkeeping of the binary64 reduction (members of each physical group with
their weights, selected positions, contraction entries) moves into
`ColorReplayResolvedLayout`, shared by both precisions.

The replay test now also checks, at 32 and 64 digits, that the components sum
to the unresolved total, agree with binary64, are parity symmetric, and that a
helicity selector returns its component alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lsimon125

Copy link
Copy Markdown
Author

Added 15a52ee: resolved (per-helicity) double-double and arbitrary-precision evaluation of the contracted-color topology replay.

evaluate_resolved_with_precision on a full-colour pure-gluon artifact fell through run_resolved_generic to paths without the replay relabellings and returned wrong components without an error (g g > g g, one point: 32-digit resolved total 6.36 against 915.33 in binary64). The new run_resolved_generic_with_color_topology_replay is the generic counterpart of the binary64 resolved replay; the helicity bookkeeping is shared between the two precisions (ColorReplayResolvedLayout). The replay test now also checks at 32 and 64 digits that the components sum to the total, agree with binary64, are parity symmetric, and that a helicity selector returns its component alone.

…y-precision contractions

The artifact stores every colour-contraction weight both in binary64 and as an
exact rational (`exact_weight`, e.g. 64/3 for u u~ > g g at full colour), but
the native generic-precision contractions used the binary64 value, so every
double-double or arbitrary-precision |M|^2 with a non-dyadic weight carried a
constant relative error of order 1e-16 (g g > g g at full colour: 4.9e-17;
u u~ > g g: 2^-54). Ratios between points cancel it, which is why the replay
test did not see it.

`ColorContractionEntry` now carries the exact weight (`ExactColorWeight`,
numerators and denominators below 2^85), parsed from the manifest and checked
against the binary64 weight; the four generic contractions convert it at the
working precision (`color_weight_generic`). Binary64 paths and synthesized
entries (Walsh blocks, eager lowering) are unchanged.

The replay test now checks absolute values: the 32- and 64-digit totals,
divided by the runtime's binary64 normalization factor, equal the exact colour
sum 16 N^2 (N^2 - 1)(3 - tu/s^2 - su/t^2 - st/u^2) (observed 1e-31 and
6.6e-58).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lsimon125

Copy link
Copy Markdown
Author

Added 01ce7a6: exact colour weights in the double-double and arbitrary-precision contractions.

The artifact stores each colour-contraction weight both in binary64 and as an exact rational (exact_weight), but the native generic-precision contractions used the binary64 value. Every double-double or arbitrary-precision |M|² with a non-dyadic weight therefore carried a constant relative error of about 1e-16 (g g > g g full colour: 4.9e-17; u u~ > g g: 2^-54), which ratios between points cannot see. ColorContractionEntry now carries the exact weight (parsed from the manifest and checked against the binary64 value), and the four generic contractions convert it at the working precision. Binary64 paths are unchanged. The replay test now also checks absolute values against the exact colour sum (observed 1e-31 at 32 digits and 6.6e-58 at 64 digits). All 1133 rusticol-core lib tests pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant