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

Sum covmats from various point prescriptions #2198

Merged
merged 40 commits into from
Nov 18, 2024
Merged

Conversation

RoyStegeman
Copy link
Member

@RoyStegeman RoyStegeman commented Nov 5, 2024

We now have various sources of uncertainty as the default option (IHOU DIS, IHOU DGLAP, MHOU 7pt) and various other sources of uncertainty that we regularly use. This number will only grow as we use the theory covariance method for the determination/implementation of higher twist, alphas, mtop, etc.

To avoid an exponentially growing pointprescriptions.yaml as a result of having to implement a new point prescription for each combination of uncertainties that we sum, this PR enables to put a list of point_prescriptions in the n3fit runcard instead of a single point_prescription. These point prescriptions each have their own associated covmat where then the sum of them is stored.

We also store the individual covmats because the theory covariance method involves recomputing the theory covmat of the relevant parameter, so it's a good consistency check to see if the same is reproduced e.g. in case a different commit is used between fit and post-fit analysis using the theory covariance method.

As a proof of concept here is a N3LO QED+MHOU fit report comparing the current master branch to this branch: https://vp.nnpdf.science/B8uVm8CQQPK1LDNJoKdvJg==/

To see that the covmats are the same for both fits, you can use the following script

Code snippet
import numpy as np
from validphys.api import API
import pandas as pd

one_covmat_fit = API.fit(fit="241104-02-rs-n3lo-mhou-qed") # done with current master
multiple_covmat_fit = API.fit(fit="241104-01-rs-n3lo-mhou-qed-sumcovmat") # done with update_th_covmat branch

one_covmat = pd.read_csv(
  one_covmat_fit.path / "tables/datacuts_theory_theorycovmatconfig_theory_covmat_custom.csv",
  index_col=[0, 1, 2],
  header=[0, 1, 2],
  sep="\t|,",
  engine="python",
).fillna(0)

summed_covmat = pd.read_csv(
  multiple_covmat_fit.path / "tables/datacuts_theory_theorycovmatconfig_theory_covmat_custom.csv",
  index_col=[0, 1, 2],
  header=[0, 1, 2],
  sep="\t|,",
  engine="python",
).fillna(0)

print(np.allclose(one_covmat, summed_covmat, rtol=1e-2))

It does break backward compatibility and old runcards can not be used to run n3fit, though old fits can still be analyzed in the same way since the name of the theory covmat has not changed.

In particular the following changes impact how to write an n3fit runcard:

  1. the point_prescription key is no longer supported and only point_prescriptions is, which takes a list of point prescriptions. Of course, that list can contain only a single point prescription.
  2. theoryids are always read from scalevariationtheoryids.yaml so there is no need to explicitly declare it each time, i.e. no more
theoryids:
    from_: scale_variation_theories
  1. some point prescriptions that are sums of various sources of uncertainty have been removed and are now only available as the sum of other point prescriptions, for a translation table from previously implemented point prescriptions in terms of the new see the bottom of pointprescriptions.yaml.

Copy link
Contributor

@giacomomagni giacomomagni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RoyStegeman, it looks much nicer now!

This prescription could also be removed as is the same as covmat_3pt, no?

def covmat_3rpt(name1, name2, deltas1, deltas2):
"""Returns theory covariance sub-matrix for 3pt renormalisation
scale variation *only*, given two dataset names and collections
of scale variation shifts"""
if name1 == name2:
s = 0.5 * (np.outer(deltas1[0], deltas2[0]) + np.outer(deltas1[1], deltas2[1]))
else:
s = 0.25 * (np.outer((deltas1[0] + deltas1[1]), (deltas2[0] + deltas2[1])))
return s

@RoyStegeman RoyStegeman force-pushed the update_th_covmat branch 2 times, most recently from ce9600d to 62893d6 Compare November 13, 2024 10:07
@scarlehoff scarlehoff self-assigned this Nov 13, 2024
Copy link
Member

@scarlehoff scarlehoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RoyStegeman I think this is really good and very much needed.

Since it will be easy to make mistakes here... could you add some tests (using the scale variations theories already used in the tests). Perhaps you can just use a few different versions of 3pt to make them run faster.

Checking things like ["3pt", "7pt"] produces the same result as ["7pt", "3pt"] for instance.

validphys2/src/validphys/config.py Outdated Show resolved Hide resolved
validphys2/src/validphys/config.py Outdated Show resolved Hide resolved
validphys2/src/validphys/config.py Show resolved Hide resolved
validphys2/src/validphys/config.py Outdated Show resolved Hide resolved
validphys2/src/validphys/config.py Outdated Show resolved Hide resolved
validphys2/src/validphys/config.py Outdated Show resolved Hide resolved
conda build creates a new env ignoring the version of python in the original environment.
@scarlehoff scarlehoff added the run-fit-bot Starts fit bot from a PR. label Nov 16, 2024
@scarlehoff
Copy link
Member

Other than the tests this looks good. I'm submitting the bot just in case there is an expected change in behaviour somewhere.

It does break backward compatibility and old runcards can not be used to run n3fit, though old fits can still be analyzed in the same way since the name of the theory covmat has not changed.

This is important, would it be possible to catch early the error in the old fit and print a message saying what to change? Since some students may want to reproduce eg NNPDF40_nnlo_as_mhou and will notice it doesn't work and stop there. We don't need to catch every possible variation, but it should be able to tell you what to do for the few fits we have released.

Copy link

Greetings from your nice fit 🤖 !
I have good news for you, I just finished my tasks:

Check the report carefully, and please buy me a ☕ , or better, a GPU 😉!

@RoyStegeman
Copy link
Member Author

This is important, would it be possible to catch early the error in the old fit and print a message saying what to change?

Yes I wasn't sure it would be necessary, but it's also quick to add so I'll do that

@RoyStegeman
Copy link
Member Author

@scarlehoff I added some tests and the error if people use an old runcard, if you're happy I think this can be merged

@scarlehoff scarlehoff merged commit 375b6e8 into master Nov 18, 2024
6 checks passed
@scarlehoff scarlehoff deleted the update_th_covmat branch November 18, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-fit-bot Starts fit bot from a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants