From 65aea635cb2af653886e0e6b04e5ed02ae106a8c Mon Sep 17 00:00:00 2001 From: siranipour Date: Fri, 4 Jun 2021 08:34:31 +0100 Subject: [PATCH 1/5] Making n3fit use python pseudodata --- n3fit/src/n3fit/scripts/n3fit_exec.py | 11 +++++++---- validphys2/src/validphys/n3fit_data.py | 4 ++-- validphys2/src/validphys/pseudodata.py | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/n3fit/src/n3fit/scripts/n3fit_exec.py b/n3fit/src/n3fit/scripts/n3fit_exec.py index a39c02d214..b1446eeac9 100755 --- a/n3fit/src/n3fit/scripts/n3fit_exec.py +++ b/n3fit/src/n3fit/scripts/n3fit_exec.py @@ -26,10 +26,13 @@ actions_ = [] ) -N3FIT_PROVIDERS = ["n3fit.performfit", - "validphys.results", - "validphys.n3fit_data", - "n3fit.n3fit_checks_provider" +N3FIT_PROVIDERS = [ + "n3fit.performfit", + "n3fit.n3fit_checks_provider", + "validphys.results", + "validphys.n3fit_data", + "validphys.pseudodata", + "validphys.commondata", ] log = logging.getLogger(__name__) diff --git a/validphys2/src/validphys/n3fit_data.py b/validphys2/src/validphys/n3fit_data.py index 2d9a617285..6ae364159d 100644 --- a/validphys2/src/validphys/n3fit_data.py +++ b/validphys2/src/validphys/n3fit_data.py @@ -205,7 +205,7 @@ def generate_data_replica(data, replica_mcseed): def fitting_data_dict( data, - generate_data_replica, + make_replica, tr_masks, kfold_masks, t0set=None, @@ -258,7 +258,7 @@ def fitting_data_dict( t0pdfset = t0set.load_t0() spec_c.SetT0(t0pdfset) - expdata = generate_data_replica + expdata = make_replica datasets = common_data_reader_experiment(spec_c, data) diff --git a/validphys2/src/validphys/pseudodata.py b/validphys2/src/validphys/pseudodata.py index d17ebff702..ac4dd33abf 100644 --- a/validphys2/src/validphys/pseudodata.py +++ b/validphys2/src/validphys/pseudodata.py @@ -115,7 +115,7 @@ def read_fit_pseudodata(fitcontext, context_index): return data_indices_list -def make_replica(dataset_inputs_loaded_cd_with_cuts, seed=None): +def make_replica(dataset_inputs_loaded_cd_with_cuts, replica_mcseed): """Function that takes in a list of :py:class:`validphys.coredata.CommonData` objects and returns a pseudodata replica accounting for possible correlations between systematic uncertainties. @@ -153,7 +153,7 @@ def make_replica(dataset_inputs_loaded_cd_with_cuts, seed=None): 0.34843355, 0.34730928, 0.3090914 , 0.32825111, 0.3485292 , """ # Seed the numpy RNG with the seed. - rng = np.random.default_rng(seed=seed) + rng = np.random.default_rng(seed=replica_mcseed) # The inner while True loop is for ensuring a positive definite # pseudodata replica From 5d3ea7c3e56029c146446c028c359d3a741d3e9d Mon Sep 17 00:00:00 2001 From: siranipour Date: Fri, 4 Jun 2021 10:18:36 +0100 Subject: [PATCH 2/5] Correcting test syntax --- .../src/validphys/tests/test_pythonmakereplica.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/validphys2/src/validphys/tests/test_pythonmakereplica.py b/validphys2/src/validphys/tests/test_pythonmakereplica.py index 627de972de..4ebb7601ca 100644 --- a/validphys2/src/validphys/tests/test_pythonmakereplica.py +++ b/validphys2/src/validphys/tests/test_pythonmakereplica.py @@ -16,6 +16,8 @@ from validphys.tests.test_covmats import CORR_DATA +SEED = 123456 + SINGLE_SYS_DATASETS = [ {"dataset": "DYE886R"}, {"dataset": "D0ZRAP", "cfac": ["QCD"]}, @@ -42,7 +44,7 @@ def test_commondata_unchanged(data_config, dataset_inputs, use_cuts): pre_mkrep_sys_tabs = [deepcopy(cd.systematics_table) for cd in ld_cds] pre_mkrep_cd_tabs = [deepcopy(cd.commondata_table) for cd in ld_cds] - make_replica(ld_cds) + make_replica(ld_cds, SEED) for post_mkrep_cd, pre_mkrep_cv in zip(ld_cds, pre_mkrep_cvs): assert_series_equal(post_mkrep_cd.central_values, pre_mkrep_cv) @@ -63,13 +65,12 @@ def test_pseudodata_seeding(data_config, dataset_inputs, use_cuts): the random numbers are generated and used identically. """ - seed = 123456 config = dict(data_config) config["dataset_inputs"] = dataset_inputs config["use_cuts"] = use_cuts - ld_cds = API.dataset_inputs_loaded_cd_with_cuts(**config) - rep_1 = make_replica(ld_cds, seed=seed) - rep_2 = make_replica(ld_cds, seed=seed) + config["replica_mcseed"] = SEED + rep_1 = API.make_replica(**config) + rep_2 = API.make_replica(**config) np.testing.assert_allclose(rep_1, rep_2) @@ -80,7 +81,8 @@ def test_pseudodata_has_correct_ndata(data_config, dataset_inputs, use_cuts): config = dict(data_config) config["dataset_inputs"] = dataset_inputs config["use_cuts"] = use_cuts + config["replica_mcseed"] = SEED ld_cds = API.dataset_inputs_loaded_cd_with_cuts(**config) - rep = make_replica(ld_cds) + rep = API.make_replica(**config) ndata = np.sum([cd.ndata for cd in ld_cds]) assert len(rep) == ndata From 588ef75787e05194528fd5a19db38bb4323a1340 Mon Sep 17 00:00:00 2001 From: siranipour Date: Tue, 8 Jun 2021 16:47:20 +0100 Subject: [PATCH 3/5] Fixing test --- validphys2/src/validphys/tests/test_regressions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validphys2/src/validphys/tests/test_regressions.py b/validphys2/src/validphys/tests/test_regressions.py index 2acaf926da..6996347fcd 100644 --- a/validphys2/src/validphys/tests/test_regressions.py +++ b/validphys2/src/validphys/tests/test_regressions.py @@ -61,7 +61,7 @@ def test_mcreplica(data_config): seed = 123456 # Use no cuts because if filter rules change in the # future then this test will end up failing - rep = API.indexed_make_replica(**config, seed=seed) + rep = API.indexed_make_replica(**config, replica_mcseed=seed) return rep From 3b9aacf4beac220c55485cfa3e5363f5cad23cf5 Mon Sep 17 00:00:00 2001 From: siranipour Date: Wed, 9 Jun 2021 16:32:52 +0100 Subject: [PATCH 4/5] Fixing n3fit regression tests --- .../n3fit/tests/regressions/quickcard_1.json | 109 ++++++++++++----- .../n3fit/tests/regressions/quickcard_2.json | 111 +++++++++++++----- 2 files changed, 159 insertions(+), 61 deletions(-) diff --git a/n3fit/src/n3fit/tests/regressions/quickcard_1.json b/n3fit/src/n3fit/tests/regressions/quickcard_1.json index d0027d2958..94208e9d79 100644 --- a/n3fit/src/n3fit/tests/regressions/quickcard_1.json +++ b/n3fit/src/n3fit/tests/regressions/quickcard_1.json @@ -1,48 +1,97 @@ { - "preprocessing": "", + "preprocessing": [ + { + "fl": "sng", + "smallx": 1.1519856452941895, + "largex": 2.635816812515259, + "trainable": true + }, + { + "fl": "g", + "smallx": 1.1843736171722412, + "largex": 1.5618072748184204, + "trainable": true + }, + { + "fl": "v", + "smallx": 0.5399999022483826, + "largex": 2.0055015087127686, + "trainable": true + }, + { + "fl": "v3", + "smallx": 0.3049614429473877, + "largex": 2.6231420040130615, + "trainable": true + }, + { + "fl": "v8", + "smallx": 0.5784729719161987, + "largex": 2.1212551593780518, + "trainable": true + }, + { + "fl": "t3", + "smallx": 1.3452119827270508, + "largex": 1.7576805353164673, + "trainable": true + }, + { + "fl": "t8", + "smallx": 1.0689963102340698, + "largex": 1.9449496269226074, + "trainable": true + }, + { + "fl": "cp", + "smallx": 0.741088330745697, + "largex": 3.4628548622131348, + "trainable": true + } + ], "stop_epoch": 1000, "best_epoch": 1000, - "erf_tr": 33.213114420572914, - "erf_vl": 28.218009317727912, - "chi2": 21.431137768190297, + "erf_tr": 35.36870388454861, + "erf_vl": 29.485028718647204, + "chi2": 21.601274632695894, "pos_state": "POS_VETO", "arc_lengths": [ - 1.1068653239049326, - 1.4953119558272292, - 1.201799272013087, - 1.4270234891345712, - 1.1920037459864075 + 1.1068650193928187, + 1.495362525909499, + 1.2016360471427414, + 1.417299567086602, + 1.1920902042035828 ], "integrability": [ - 0.0026635357935483883, - 0.0026635357935447246, - 0.00014161983198945904, - 5.059403657913208, - 0.00397586848703213 + 0.002665607098606748, + 0.002665607098605749, + 0.00013836964808366936, + 5.058645844459534, + 0.0039739306957948806 ], "timing": { "walltime": { - "Total": 14.067598581314087, + "Total": 41.31889986991882, "start": 0.0, - "data_loaded": 0.3445882797241211, - "replica_set": 0.34477806091308594, - "replica_fitted": 14.066914319992065, - "replica_set_to_replica_fitted": 13.72213625907898 + "data_loaded": 0.033830881118774414, + "replica_set": 0.03406381607055664, + "replica_fitted": 41.31194734573364, + "replica_set_to_replica_fitted": 41.277883529663086 }, "cputime": { - "Total": 15.760098933, + "Total": 41.987736192999996, "start": 0.0, - "data_loaded": 1.3225217320000002, - "replica_set": 1.3239677300000001, - "replica_fitted": 15.759413147999998, - "replica_set_to_replica_fitted": 14.435445417999999 + "data_loaded": 0.020405508000000516, + "replica_set": 0.020640056000000406, + "replica_fitted": 41.984591997, + "replica_set_to_replica_fitted": 41.963951941000005 } }, "version": { - "keras": "2.4.0", - "tensorflow": "2.3.1, mkl=False", - "numpy": "1.18.5", - "nnpdf": "3.5.1439+g47c1a11a6-dev", - "validphys": "3.5.1439+g47c1a11a6-dev" + "keras": "2.3.0-tf", + "tensorflow": "2.2.0, mkl=False", + "numpy": "1.19.1", + "nnpdf": "4.0.1.316+gf0c7b34", + "validphys": "4.0.1.316+gf0c7b34" } -} +} \ No newline at end of file diff --git a/n3fit/src/n3fit/tests/regressions/quickcard_2.json b/n3fit/src/n3fit/tests/regressions/quickcard_2.json index ee06f8c7a8..9726bde86b 100644 --- a/n3fit/src/n3fit/tests/regressions/quickcard_2.json +++ b/n3fit/src/n3fit/tests/regressions/quickcard_2.json @@ -1,48 +1,97 @@ { - "preprocessing": "", + "preprocessing": [ + { + "fl": "sng", + "smallx": 1.102711796760559, + "largex": 2.700000047683716, + "trainable": true + }, + { + "fl": "g", + "smallx": 0.9399998784065247, + "largex": 1.6224322319030762, + "trainable": true + }, + { + "fl": "v", + "smallx": 0.7402178645133972, + "largex": 1.7066106796264648, + "trainable": true + }, + { + "fl": "v3", + "smallx": 0.21739234030246735, + "largex": 1.3615831136703491, + "trainable": true + }, + { + "fl": "v8", + "smallx": 0.7599998712539673, + "largex": 2.411074161529541, + "trainable": true + }, + { + "fl": "t3", + "smallx": 1.4385331869125366, + "largex": 2.29486083984375, + "trainable": true + }, + { + "fl": "t8", + "smallx": 1.0592598915100098, + "largex": 1.7743843793869019, + "trainable": true + }, + { + "fl": "cp", + "smallx": 0.22786737978458405, + "largex": 2.78507661819458, + "trainable": true + } + ], "stop_epoch": 1000, - "best_epoch": 998, - "erf_tr": 2.606570236771195, - "erf_vl": 3.0318090969458558, - "chi2": 1.5918478894589552, + "best_epoch": 999, + "erf_tr": 2.491444057888455, + "erf_vl": 2.8942466391656634, + "chi2": 1.6324648501268073, "pos_state": "POS_PASS", "arc_lengths": [ - 1.931689594079703, - 1.697054671644156, - 1.1340829034892161, - 32.891455584502694, - 1.1119670640240853 + 1.9364193786789174, + 1.5682913617806982, + 1.1399297208463033, + 31.118964175987294, + 1.1057977439528737 ], "integrability": [ - 0.02683432819322168, - 0.026834328193217516, - 0.0004258475692022756, - 20.328540325164795, - 0.028318760450927627 + 0.02547394391149188, + 0.025473943911492936, + 0.00041527650682848805, + 19.97365140914917, + 0.02800018619745881 ], "timing": { "walltime": { - "Total": 16.93633460998535, + "Total": 43.86756992340088, "start": 0.0, - "data_loaded": 0.34407711029052734, - "replica_set": 0.3442709445953369, - "replica_fitted": 16.935593366622925, - "replica_set_to_replica_fitted": 16.591322422027588 + "data_loaded": 0.03478097915649414, + "replica_set": 0.035103559494018555, + "replica_fitted": 43.86035966873169, + "replica_set_to_replica_fitted": 43.82525610923767 }, "cputime": { - "Total": 18.655240567, + "Total": 44.583864212, "start": 0.0, - "data_loaded": 1.317259243, - "replica_set": 1.3187306250000002, - "replica_fitted": 18.65449747, - "replica_set_to_replica_fitted": 17.335766845000002 + "data_loaded": 0.01997594100000022, + "replica_set": 0.020298879999999464, + "replica_fitted": 44.580285373, + "replica_set_to_replica_fitted": 44.559986493000004 } }, "version": { - "keras": "2.4.0", - "tensorflow": "2.3.1, mkl=False", - "numpy": "1.18.5", - "nnpdf": "3.5.1439+g47c1a11a6-dev", - "validphys": "3.5.1439+g47c1a11a6-dev" + "keras": "2.3.0-tf", + "tensorflow": "2.2.0, mkl=False", + "numpy": "1.19.1", + "nnpdf": "4.0.1.316+gf0c7b34-dev", + "validphys": "4.0.1.316+gf0c7b34-dev" } -} +} \ No newline at end of file From 0b21f84eac878a233f76c7dd286114c02766664e Mon Sep 17 00:00:00 2001 From: siranipour Date: Wed, 23 Jun 2021 15:34:55 +0100 Subject: [PATCH 5/5] Updating reference for bot --- .github/workflows/rules.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rules.yml b/.github/workflows/rules.yml index 91dbd587f9..a9b1b43345 100644 --- a/.github/workflows/rules.yml +++ b/.github/workflows/rules.yml @@ -10,7 +10,7 @@ on: env: N3FIT_MAXNREP: 20 # total number of replicas to fit POSTFIT_NREP: 16 # requested replicas for postfit - REFERENCE_SET: NNBOT-b4f0e2926-2021-05-13 # reference set for vp + REFERENCE_SET: NNBOT-d3034a7cc-2021-06-11 # reference set for vp CONDA_PY: 37 jobs: