Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QED tests #1738

Merged
merged 41 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cf8afeb
Add theories 398 397 to theory.db
niclaurenti May 22, 2023
70458a3
Merge branch 'master' into QED-tests
niclaurenti Jun 12, 2023
c6914a1
Merge branch 'master' into qed-tests
niclaurenti Jun 13, 2023
fcc3e8e
Add qed test in test_evolven3fit.py
niclaurenti Jun 13, 2023
5e7176e
Add qed test in test_fit
niclaurenti Jun 13, 2023
0af3004
Add qed test in test_fit 2
niclaurenti Jun 13, 2023
2256664
Refector QED tests
niclaurenti Jun 14, 2023
5a319fc
Fix test
niclaurenti Jun 14, 2023
9758018
Add fiatlux precision in the runcard
niclaurenti Jun 14, 2023
0a926fd
Rename abs_err -> eps_base
niclaurenti Jun 14, 2023
32e1a86
Use .json from linux machine
niclaurenti Jun 14, 2023
e2954ae
Fix very small bug in interp1d
niclaurenti Jun 14, 2023
3d1783d
Download theoryIDs
niclaurenti Jun 15, 2023
296e2d4
Add whitelines
niclaurenti Jun 16, 2023
22085f9
Merge branch 'qed-tests' of github.com:NNPDF/nnpdf into qed-tests
niclaurenti Jun 16, 2023
7585eea
Load theoryID from fit
niclaurenti Jun 16, 2023
57a5343
Use test theory in test_compute
niclaurenti Jun 16, 2023
077e2ed
Fix charm mass in test
niclaurenti Jun 16, 2023
388be7b
speed up photon computation in test
niclaurenti Jun 16, 2023
ddc57d3
Fix charm mass in test again
niclaurenti Jun 16, 2023
dba334a
Fix testing of alpha
niclaurenti Jun 16, 2023
3fa81ba
Fix test_compute
niclaurenti Jun 16, 2023
bb3a1fd
Add test on photon computation
niclaurenti Jun 16, 2023
3901ba5
Remove unused dependencies
niclaurenti Jun 16, 2023
f3de6b0
Polish test
niclaurenti Jun 16, 2023
7550e2d
Polish test again
niclaurenti Jun 16, 2023
98d919f
Pass test theory to test_structurefunctions.py
niclaurenti Jun 16, 2023
4b0ed9c
Run isort and black on test_structurefunctions.py
niclaurenti Jun 16, 2023
5ede6f4
Test init parameters of test_structurefunctions.py
niclaurenti Jun 16, 2023
52e9130
Run isort and black on test_structurefunctions.py
niclaurenti Jun 16, 2023
370d0dd
Use API to install pdfset
niclaurenti Jun 16, 2023
b97450d
Refactor test_structurefunctions.py and add docstrings
niclaurenti Jun 16, 2023
3e548a8
Small modification
niclaurenti Jun 16, 2023
b40db35
Use FIATLUX_DEFAULT from photon.compute
niclaurenti Jun 16, 2023
0958b08
Remove unused import
niclaurenti Jun 16, 2023
61c5bb9
Remove variable NNPDF40
niclaurenti Jun 19, 2023
53d7c73
Add comment
niclaurenti Jun 19, 2023
502997f
Merge branch 'master' into qed-tests
niclaurenti Jun 19, 2023
d5a48f9
Check installation of error pdf in test
niclaurenti Jun 19, 2023
1e237da
Call black and isort
niclaurenti Jun 19, 2023
1e105cd
Fix last commit
niclaurenti Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion n3fit/runcards/examples/Basic_runcard_qed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ datacuts:

############################################################
theory:
theoryid: 522 # database id
theoryid: 523 # database id
scarlehoff marked this conversation as resolved.
Show resolved Hide resolved

############################################################
trvlseed: 1551864071
Expand Down Expand Up @@ -169,3 +169,4 @@ fiatlux:
luxset: NNPDF40_nnlo_as_01180
additional_errors: true # should be set to true only for the last iteration
luxseed: 1234567890
eps_base: 1e-2
93 changes: 93 additions & 0 deletions n3fit/src/n3fit/tests/regressions/quickcard_qed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#
# Configuration file for n3fit regression tests
# This runcard includes two DIS datasets, one Hadronic dataset
# and two positivity datasets
#

############################################################
description: n3fit regression test

############################################################
# frac: training fraction
# ewk: apply ewk k-factors
# sys: systematics treatment (see systypes)
dataset_inputs:
- { dataset: NMC, frac: 0.5 }
- { dataset: SLACP_dwsh, frac: 0.5}
- { dataset: CMSZDIFF12, frac: 0.5, cfac: ['QCD'], sys: 10 }
- { dataset: ATLASTTBARTOT8TEV, frac: 1.0, cfac: ['QCD'] }

############################################################
datacuts:
t0pdfset: NNPDF40_nnlo_as_01180 # PDF set to generate t0 covmat
q2min : 3.49 # Q2 minimum
w2min : 12.5 # W2 minimum
combocuts : NNPDF31 # NNPDF3.0 final kin. cuts
jetptcut_tev : 0 # jet pt cut for tevatron
jetptcut_lhc : 0 # jet pt cut for lhc
wptcut_lhc : 30.0 # Minimum pT for W pT diff distributions
jetycut_tev : 1e30 # jet rap. cut for tevatron
jetycut_lhc : 1e30 # jet rap. cut for lhc
dymasscut_min: 0 # dy inv.mass. min cut
dymasscut_max: 1e30 # dy inv.mass. max cut
jetcfactcut : 1e30 # jet cfact. cut

############################################################
theory:
theoryid: 398 # database id

############################################################
genrep: True # on = generate MC replicas, False = use real data
trvlseed: 3
nnseed: 2
mcseed: 1

load: "weights.h5"

parameters: # This defines the parameter dictionary that is passed to the Model Trainer
nodes_per_layer: [15, 10, 8]
activation_per_layer: ['sigmoid', 'sigmoid', 'linear']
initializer: 'glorot_normal'
optimizer:
optimizer_name: 'RMSprop'
learning_rate: 0.00001
clipnorm: 1.0
epochs: 1100
positivity:
multiplier: 1.05
initial: 1.5
stopping_patience: 0.10 # percentage of the number of epochs
layer_type: 'dense'
dropout: 0.0
threshold_chi2: 10.0

fitting:
fitbasis: NN31IC # EVOL (7), EVOLQED (8), etc.
basis:
- { fl: sng, smallx: [1.05,1.19], largex: [1.47,2.70] }
- { fl: g, smallx: [0.94,1.25], largex: [0.11,5.87] }
- { fl: v, smallx: [0.54,0.75], largex: [1.15,2.76] }
- { fl: v3, smallx: [0.21,0.57], largex: [1.35,3.08] }
- { fl: v8, smallx: [0.52,0.76], largex: [0.77,3.56] }
- { fl: t3, smallx: [-0.37,1.52], largex: [1.74,3.39] }
- { fl: t8, smallx: [0.56,1.29], largex: [1.45,3.03] }
- { fl: cp, smallx: [0.12,1.19], largex: [1.83,6.70] }

############################################################
positivity:
posdatasets:
- { dataset: POSF2U, maxlambda: 1e6 } # Positivity Lagrange Multiplier
- { dataset: POSDYS, maxlambda: 1e5 }

integrability:
integdatasets:
- {dataset: INTEGXT8, maxlambda: 1e2}

############################################################
debug: true

fiatlux:
luxset: NNPDF40_nnlo_as_01180
additional_errors: true # should be set to true only for the last iteration
luxseed: 1234567890
eps_base: 1e-2
95 changes: 95 additions & 0 deletions n3fit/src/n3fit/tests/regressions/quickcard_qed_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"preprocessing": [
{
"fl": "sng",
"smallx": 1.1307647228240967,
"largex": 2.6348154544830322,
"trainable": true
},
{
"fl": "g",
"smallx": 1.1853630542755127,
"largex": 1.5627975463867188,
"trainable": true
},
{
"fl": "v",
"smallx": 0.5399999022483826,
"largex": 2.004500150680542,
"trainable": true
},
{
"fl": "v3",
"smallx": 0.3061824142932892,
"largex": 2.624323606491089,
"trainable": true
},
{
"fl": "v8",
"smallx": 0.5774596929550171,
"largex": 2.120253801345825,
"trainable": true
},
{
"fl": "t3",
"smallx": 1.3441987037658691,
"largex": 1.7566683292388916,
"trainable": true
},
{
"fl": "t8",
"smallx": 1.04995858669281,
"largex": 1.945939064025879,
"trainable": true
},
{
"fl": "cp",
"smallx": 0.7400740385055542,
"largex": 3.461853504180908,
"trainable": true
}
],
"stop_epoch": 1100,
"best_epoch": 1099,
"erf_tr": 31.486101150512695,
"erf_vl": 28.4218692779541,
"chi2": 19.611825942993164,
"pos_state": "POS_VETO",
"arc_lengths": [
1.035533162554303,
1.1953713068471692,
1.0881025884095246,
1.3414978876721764,
1.0839843290638607
],
"integrability": [
0.002653829054906187,
0.002653829054905521,
0.0002567724250169823,
3.2896786332130423,
0.003927801561079747
],
"timing": {
"walltime": {
"Total": 58.37841296195984,
"start": 0.0,
"replica_set": 0.3208029270172119,
"replica_fitted": 58.37802076339722,
"replica_set_to_replica_fitted": 58.057217836380005
},
"cputime": {
"Total": 61.517351913999995,
"start": 0.0,
"replica_set": 2.813359167999998,
"replica_fitted": 61.516948647,
"replica_set_to_replica_fitted": 58.703589479
}
},
"version": {
"keras": "2.11.0",
"tensorflow": "2.11.0, mkl=False",
"numpy": "1.22.4",
"nnpdf": "4.0.6.846+g0a926fdf1",
"validphys": "4.0.6.846+g0a926fdf1"
}
}
95 changes: 95 additions & 0 deletions n3fit/src/n3fit/tests/regressions/quickcard_qed_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"preprocessing": [
{
"fl": "sng",
"smallx": 1.1090763807296753,
"largex": 2.683891534805298,
"trainable": true
},
{
"fl": "g",
"smallx": 0.9399998784065247,
"largex": 1.6250606775283813,
"trainable": true
},
{
"fl": "v",
"smallx": 0.7499998211860657,
"largex": 1.7267229557037354,
"trainable": true
},
{
"fl": "v3",
"smallx": 0.21201331913471222,
"largex": 1.3532426357269287,
"trainable": true
},
{
"fl": "v8",
"smallx": 0.7599998712539673,
"largex": 2.390087127685547,
"trainable": true
},
{
"fl": "t3",
"smallx": 1.4388009309768677,
"largex": 2.2958621978759766,
"trainable": true
},
{
"fl": "t8",
"smallx": 1.0386217832565308,
"largex": 1.7531665563583374,
"trainable": true
},
{
"fl": "cp",
"smallx": 0.24638080596923828,
"largex": 2.7976953983306885,
"trainable": true
}
],
"stop_epoch": 1100,
"best_epoch": 1099,
"erf_tr": 3.5809452533721924,
"erf_vl": 3.6826603412628174,
"chi2": 2.141340732574463,
"pos_state": "POS_VETO",
"arc_lengths": [
1.3194883264768875,
1.1995146017416334,
1.054266019685804,
5.074692492247958,
1.0689068380364566
],
"integrability": [
0.02917606895789332,
0.029176068957894374,
0.0003924771135637162,
12.764093160629272,
0.02982003148645135
],
"timing": {
"walltime": {
"Total": 57.77593541145325,
"start": 0.0,
"replica_set": 0.31868839263916016,
"replica_fitted": 57.77560114860535,
"replica_set_to_replica_fitted": 57.45691275596619
},
"cputime": {
"Total": 60.771742980000006,
"start": 0.0,
"replica_set": 2.6913169609999983,
"replica_fitted": 60.771408723,
"replica_set_to_replica_fitted": 58.080091762
}
},
"version": {
"keras": "2.11.0",
"tensorflow": "2.11.0, mkl=False",
"numpy": "1.22.4",
"nnpdf": "4.0.6.846+g0a926fdf1",
"validphys": "4.0.6.846+g0a926fdf1"
}
}
4 changes: 3 additions & 1 deletion n3fit/src/n3fit/tests/test_evolven3fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ def test_eko_utils(tmp_path):
assert_allclose(list(eko_op.operator_card.raw["mugrid"]), op_card_dict["mugrid"])


@pytest.mark.parametrize("fitname", ["Basic_runcard_3replicas_lowprec_399"])
@pytest.mark.parametrize("fitname", ["Basic_runcard_3replicas_lowprec_399", "Basic_runcard_qed_3replicas_lowprec_398"])
def test_perform_evolution(tmp_path, fitname):
"""Test that evolven3fit_new is able to utilize the current eko in the respective theory.
In addition checks that the generated .info files are correct
"""
fit = API.fit(fit=fitname)
_ = API.theoryid(theoryid=fit.as_input()['theory']['theoryid'])
# Move the fit to a temporary folder
tmp_fit = tmp_path / fitname
shutil.copytree(fit.path, tmp_fit)
Expand All @@ -185,3 +186,4 @@ def test_perform_evolution(tmp_path, fitname):
info = check_lhapdf_info(tmp_info)
for datpath in tmp_nnfit.glob("replica_*/*.dat"):
check_lhapdf_dat(datpath, info)

19 changes: 11 additions & 8 deletions n3fit/src/n3fit/tests/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
log = logging.getLogger(__name__)
REGRESSION_FOLDER = pathlib.Path(__file__).with_name("regressions")
QUICKNAME = "quickcard"
QUICKNAME_QED = "quickcard_qed"
EXE = "n3fit"
REPLICA = "1"
EXPECTED_MAX_FITTIME = 130 # seen mac ~ 180 and linux ~ 90
Expand Down Expand Up @@ -64,22 +65,22 @@ def test_initialize_seeds():
assert len({replica_mcseed(rep, 1, True) for rep in same_replicas}) == 1


def auxiliary_performfit(tmp_path, replica=1, timing=True, rel_error=2e-3):
def auxiliary_performfit(tmp_path, runcard=QUICKNAME, replica=1, timing=True, rel_error=2e-3):
"""Fits quickcard and checks the json file to ensure the results have not changed.
"""
quickcard = f"{QUICKNAME}.yml"
quickcard = f"{runcard}.yml"
# Prepare the runcard
quickpath = REGRESSION_FOLDER / quickcard
weightpath = REGRESSION_FOLDER / f"weights_{replica}.h5"
# read up the previous json file for the given replica
old_json = load_data(REGRESSION_FOLDER / f"{QUICKNAME}_{replica}.json")
old_json = load_data(REGRESSION_FOLDER / f"{runcard}_{replica}.json")
# cp runcard and weights to tmp folder
shutil.copy(quickpath, tmp_path)
shutil.copy(weightpath, tmp_path / "weights.h5")
# run the fit
sp.run(f"{EXE} {quickcard} {replica}".split(), cwd=tmp_path, check=True)
# read up json files
full_json = tmp_path / f"{QUICKNAME}/nnfit/replica_{replica}/{QUICKNAME}.json"
full_json = tmp_path / f"{runcard}/nnfit/replica_{replica}/{runcard}.json"
new_json = load_data(full_json)
# Now compare to regression results, taking into account precision won't be 100%
equal_checks = ["stop_epoch", "pos_state"]
Expand All @@ -101,14 +102,16 @@ def auxiliary_performfit(tmp_path, replica=1, timing=True, rel_error=2e-3):


@pytest.mark.darwin
def test_performfit(tmp_path):
auxiliary_performfit(tmp_path, replica=2, timing=False, rel_error=1e-1)
@pytest.mark.parametrize("runcard", [QUICKNAME, QUICKNAME_QED])
def test_performfit(tmp_path, runcard):
auxiliary_performfit(tmp_path, runcard=runcard, replica=2, timing=False, rel_error=1e-1)


@pytest.mark.linux
@pytest.mark.parametrize("replica", [1, 2])
def test_performfit_and_timing(tmp_path, replica):
auxiliary_performfit(tmp_path, replica=replica, timing=True)
@pytest.mark.parametrize("runcard", [QUICKNAME, QUICKNAME_QED])
def test_performfit_and_timing(tmp_path, runcard, replica):
auxiliary_performfit(tmp_path, runcard=runcard, replica=replica, timing=True)


@pytest.mark.skip(reason="Still not implemented in parallel mode")
Expand Down
Binary file modified nnpdfcpp/data/theory.db
Binary file not shown.
Loading
Loading