From 66f02cc0f44482b2aab77e55d22ff275151d4719 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Mon, 9 Oct 2023 10:19:23 +0200 Subject: [PATCH 1/4] add a failing bench --- benchmarks/eko/benchmark_iveverse_matching.py | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 benchmarks/eko/benchmark_iveverse_matching.py diff --git a/benchmarks/eko/benchmark_iveverse_matching.py b/benchmarks/eko/benchmark_iveverse_matching.py new file mode 100644 index 000000000..18f715c10 --- /dev/null +++ b/benchmarks/eko/benchmark_iveverse_matching.py @@ -0,0 +1,107 @@ +import pathlib + +import numpy as np +import pytest +from banana import toy + +from eko import EKO +from eko.io import runcards +from eko.io.types import ReferenceRunning +from eko.runner.managed import solve +from ekobox import apply + +here = pathlib.Path(__file__).parent.absolute() +MC = 1.51 +C_PID = 4 + +# theory settings +th_raw = dict( + order=[3, 0], + couplings=dict( + alphas=0.118, + alphaem=0.007496252, + scale=91.2, + num_flavs_ref=5, + max_num_flavs=6, + ), + heavy=dict( + num_flavs_init=4, + num_flavs_max_pdf=6, + intrinsic_flavors=[], + masses=[ReferenceRunning([mq, np.nan]) for mq in (MC, 4.92, 172.5)], + masses_scheme="POLE", + matching_ratios=[1.0, 1.0, np.inf], + ), + xif=1.0, + n3lo_ad_variation=(0, 0, 0, 0, 0, 0, 0), + matching_order=[2, 0], +) + +# operator settings +op_raw = dict( + mu0=1.65, + xgrid=[0.0001, 0.001, 0.01, 0.1, 1], + mugrid=[(MC, 3), (MC, 4)], + configs=dict( + evolution_method="truncated", + ev_op_max_order=[1, 0], + ev_op_iterations=1, + interpolation_polynomial_degree=4, + interpolation_is_log=True, + scvar_method="exponentiated", + inversion_method="exact", + n_integration_cores=0, + polarized=False, + time_like=False, + ), + debug=dict( + skip_singlet=False, + skip_non_singlet=False, + ), +) + + +@pytest.mark.isolated +def BenchmarkInverseMatching(): + th_card = runcards.TheoryCard.from_dict(th_raw) + op_card = runcards.OperatorCard.from_dict(op_raw) + + eko_path2 = here / "test2.tar" + eko_path2.unlink(missing_ok=True) + solve(th_card, op_card, eko_path2) + + th_card.matching_order = [1, 0] + eko_path1 = here / "test1.tar" + eko_path1.unlink(missing_ok=True) + solve(th_card, op_card, eko_path1) + + eko_output1 = EKO.read(eko_path1) + eko_output2 = EKO.read(eko_path2) + op1_nf3 = eko_output1[(MC**2, 3)] + op2_nf3 = eko_output2[(MC**2, 3)] + op1_nf4 = eko_output1[(MC**2, 4)] + op2_nf4 = eko_output2[(MC**2, 4)] + + # test that nf=4 operators are the same + np.testing.assert_allclose(op1_nf4.operator, op2_nf4.operator) + + with pytest.raises(AssertionError): + np.testing.assert_allclose(op2_nf3.operator, op2_nf4.operator) + + with pytest.raises(AssertionError): + np.testing.assert_allclose(op1_nf3.operator, op1_nf4.operator) + + with pytest.raises(AssertionError): + np.testing.assert_allclose(op1_nf3.operator, op2_nf3.operator) + + pdf1 = apply.apply_pdf(eko_output1, toy.mkPDF("ToyLH", 0)) + pdf2 = apply.apply_pdf(eko_output2, toy.mkPDF("ToyLH", 0)) + + # test that different PTO matching is applied correctly + np.testing.assert_allclose( + pdf1[(MC**2, 4)]["pdfs"][C_PID], pdf2[(MC**2, 4)]["pdfs"][C_PID] + ) + with pytest.raises(AssertionError): + np.testing.assert_allclose( + pdf1[(MC**2, 3)]["pdfs"][C_PID], pdf2[(MC**2, 3)]["pdfs"][C_PID] + ) From c712cad1c1c30244411db5f29bee0ceef1bb617a Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Mon, 9 Oct 2023 10:38:08 +0200 Subject: [PATCH 2/4] fix bench name --- benchmarks/eko/benchmark_iveverse_matching.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/eko/benchmark_iveverse_matching.py b/benchmarks/eko/benchmark_iveverse_matching.py index 18f715c10..7ca3b1a6a 100644 --- a/benchmarks/eko/benchmark_iveverse_matching.py +++ b/benchmarks/eko/benchmark_iveverse_matching.py @@ -62,7 +62,7 @@ @pytest.mark.isolated -def BenchmarkInverseMatching(): +def benchmark_inverse_matching(): th_card = runcards.TheoryCard.from_dict(th_raw) op_card = runcards.OperatorCard.from_dict(op_raw) From e0d74a75b6ab1f7606e48e9d2568cd8f32ad34ca Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Mon, 9 Oct 2023 16:13:24 +0200 Subject: [PATCH 3/4] add fix and correct file name --- ...mark_iveverse_matching.py => benchmark_inverse_matching.py} | 0 src/eko/runner/parts.py | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) rename benchmarks/eko/{benchmark_iveverse_matching.py => benchmark_inverse_matching.py} (100%) diff --git a/benchmarks/eko/benchmark_iveverse_matching.py b/benchmarks/eko/benchmark_inverse_matching.py similarity index 100% rename from benchmarks/eko/benchmark_iveverse_matching.py rename to benchmarks/eko/benchmark_inverse_matching.py diff --git a/src/eko/runner/parts.py b/src/eko/runner/parts.py index 9df80a4a8..ce540d861 100644 --- a/src/eko/runner/parts.py +++ b/src/eko/runner/parts.py @@ -150,9 +150,8 @@ def match(eko: EKO, recipe: Matching) -> Operator: op.compute() binfo = blowup_info(eko) - nf_match = op.nf - 1 if recipe.inverse else op.nf res, err = matching_condition.MatchingCondition.split_ad_to_evol_map( - op.op_members, nf_match, recipe.scale, **binfo + op.op_members, op.nf, recipe.scale, **binfo ).to_flavor_basis_tensor(qed=binfo["qed"]) return Operator(res, err) From 91e59c728d8a563bebb9fefcf5667173afcd5db1 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Tue, 10 Oct 2023 15:52:50 +0200 Subject: [PATCH 4/4] minor fix on docstring --- src/eko/evolution_operator/operator_matrix_element.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index c25252675..1a287b9aa 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -185,8 +185,12 @@ class OperatorMatrixElement(Operator): configuration managers : dict managers - segment: Segment - path segment + nf: int + number of active flavor below threshold + q2: float + squared matching scale + is_backward: bool + True for backward matching L: float :math:`\ln(\mu_F^2 / m_h^2)` is_msbar: bool