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

Remove additional t0 flags #1626

Merged
merged 2 commits into from
Nov 15, 2022
Merged

Remove additional t0 flags #1626

merged 2 commits into from
Nov 15, 2022

Conversation

Zaharid
Copy link
Contributor

@Zaharid Zaharid commented Nov 9, 2022

The work on covariance matrices added new flags to control to t0 setting, namely use_t0_sampling and use_t0_fitting. These were undocumented, and caused bugs in validphys since t0pdfset could be set by either of them.

Remove both flags and mandate that the fitting covmat always uses t0 while the sampling covmat never uses it.

This removes some footguns and its backwards compatible.

It has the minor disadvantage that the fitting covmat implicitly requires use_t0=True, which is redundant, but it only really matters in n3fit and we set the flag there anyway.

@Zaharid
Copy link
Contributor Author

Zaharid commented Nov 9, 2022

Note this is less flexible than what we used to have as one cannot meaningfully override to use_t0: False in the fit runcard. But I don't think it matters.

@scarlehoff
Copy link
Member

But we might want to do fits without the t0 covmat, right? (for testing, show how important it is, etc)

@Zaharid
Copy link
Contributor Author

Zaharid commented Nov 9, 2022

I think when (if) there is a pressing need to run these tests, whoever does it should re-add the options making sure they are documented and tested properly.

It is easy enough to swap for an one off test modifying the source.

@scarlehoff scarlehoff added the run-fit-bot Starts fit bot from a PR. label Nov 9, 2022
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.

Please remove also the flags from the runcards and from the documentation.

I don't see any fits without the t0 other than very specific tests so I tend to agree with your last comment.

@@ -158,10 +158,8 @@ def from_yaml(cls, o, *args, **kwargs):
N3FIT_FIXED_CONFIG['use_scalevar_uncertainties'] = thconfig.get('use_scalevar_uncertainties', True)
#Sampling flags
if (sam_t0:=file_content.get('sampling')) is not None:
N3FIT_FIXED_CONFIG['use_t0_sampling'] = sam_t0.get('use_t0', False)
N3FIT_FIXED_CONFIG['separate_multiplicative'] = sam_t0.get('separate_multiplicative', True)
#Fitting flag
Copy link
Member

Choose a reason for hiding this comment

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

Is the only other flag of sampling separate_multiplicative @andreab1997 ?

If so it might make sense to remove this extra level.

Also, maybe in the same vein as removing the option to not use t0 we might want to remove the option of doing the sampling with the multiplicative uncertainties separated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this was the original proposal: it does not really make sense to separate the multiplicative uncertainties. However I think that @Zaharid was against. Are you still?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the only other flag of sampling separate_multiplicative @andreab1997 ?

To answer this question, yes so it makes sense to remove completely the sampling level

Copy link
Member

Choose a reason for hiding this comment

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

I would say let's remove both the sampling level and separate_multiplicative

return covmats.dataset_inputs_total_covmat
else:
return covmats.dataset_inputs_exp_covmat
return covmats.dataset_inputs_t0_exp_covmat
Copy link
Member

Choose a reason for hiding this comment

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

I would remove the else given the other changes.

Btw, why are we doing the import inside the method? Circular imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probable for no good reason anymore: At some point I wanted to make this file import quickly, but that ships has probably sailed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean exactly with removing the else? I would say we want support for enabling and disabling the theorycovmat. Not clear to me why there are two flags.

cc @andreab1997

Copy link
Member

@scarlehoff scarlehoff Nov 9, 2022

Choose a reason for hiding this comment

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

Just a stylistic comment, I would do

if this:
    return that
return thet

but it's unimportant, if you prefer the else leave it.

The two flags are there because the th covmat can be used in the fit or in the sampling.
Since seeing the difference was relevant at some point I think that should stay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two flags are there because the th covmat can be used in the fit or in the sampling.
Since seeing the difference was relevant at some point I think that should stay.

but the two flags are in the fitting action...

Copy link
Member

Choose a reason for hiding this comment

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

One to say that the th covmat is active and another two to decide whether it is active in sampling or fitting.

A bit like the use_t0 but in this case there is no the solution of "fitting without t0 is wrong, so let's remove the wrong option".

I guess that's the two flags you are referring to ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed you can decide to use the thcovmat in only one of the two places or in both and I believe that one of Stefano's student will actually try to have a look to the different fits you can get with these three options.

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

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 😉!

The work on covariance matrices added new flags to control to t0
setting, namely `use_t0_sampling` and `use_t0_fitting`. These were
undocumented, and caused bugs in validphys since t0pdfset could be set
by either of them.

Remove both flags and mandate that the fitting covmat always uses t0
while the sampling covmat never uses it.

This removes some footguns and its backwards compatible.

It has the minor disadvantage that the fitting covmat implicitly
requires use_t0=True, which is redundant, but it only really matters in
n3fit and we set the flag there anyway.
@Zaharid
Copy link
Contributor Author

Zaharid commented Nov 10, 2022

I'd like to merge this as is, and defer discussion of other aspects of the covmat setting.

Copy link
Contributor

@andreab1997 andreab1997 left a comment

Choose a reason for hiding this comment

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

For me it is even okay to merge. I am only confused about the flag use_t0. As far as I understood it should always be True (otherwise there will be an error), right? And, even if it is True we are only using t0 for the fitting covmat and never for the sampling covmat. Is my understanding correct? Because in this case I believe it is a bit confusing and we should probably just remove it and rely on the default behaviour.

@scarlehoff
Copy link
Member

I'd like to merge this as is, and defer discussion of other aspects of the covmat setting.

Ok, but please update the documentation and runcards.

@Zaharid
Copy link
Contributor Author

Zaharid commented Nov 10, 2022

use_t0 is for any generic covmat in vp. A a special case there are the sampling and fitting functions that as of this pr either always use it or never use it. As pointed above, the fitting covmat requires that use_t0 is explicitly set to True, but we do that in the fit, where it matters most. To me that is the only problem and too minor for me to bother.

@andreab1997 andreab1997 self-requested a review November 10, 2022 16:23
@scarlehoff scarlehoff removed the run-fit-bot Starts fit bot from a PR. label Nov 11, 2022
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.

I think once runcards/docs are updated this can be merged.

@Zaharid
Copy link
Contributor Author

Zaharid commented Nov 14, 2022

@scarlehoff which runcards and which docs? AFAICT the relevant docs are

https://docs.nnpdf.science/figuresofmerit/index.html?highlight=use_t0

which are correct now and were wrong before.

And the runcards as of 4.0 work as of now.

@scarlehoff
Copy link
Member

scarlehoff commented Nov 14, 2022

@Zaharid Zaharid mentioned this pull request Nov 14, 2022
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

@scarlehoff
Copy link
Member

Should I merge this @Zaharid ?

@Zaharid Zaharid merged commit 110f814 into master Nov 15, 2022
@Zaharid Zaharid deleted the not0flags branch November 15, 2022 12:57
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.

3 participants