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

Use python convolutions also for positivity predictions #1510

Merged
merged 6 commits into from
Feb 10, 2022

Conversation

scarlehoff
Copy link
Member

@scarlehoff scarlehoff commented Jan 31, 2022

For this I had to introduce a new attribute and an if condition in the predictions module. Another option is to create a fake op and fake cuts in the positivity spec class I guess.

The first commit includes only the if condition and the extra attribute to create a record of the cpp and the python version giving the same result, I'll push the change to PositivityResult later if that passes.

@scarlehoff scarlehoff changed the title Use python convolutions also for predictions Use python convolutions also for positivity predictions Jan 31, 2022
@Zaharid
Copy link
Contributor

Zaharid commented Jan 31, 2022

Could we make positivity be more like datasets without data instead? AFAICT a minimal step would be just declaring that they have OP=NULL and empty cuts for the moment, which would achieve a similar effect.

@scarlehoff
Copy link
Member Author

which would achieve a similar effect.

The problem is the cuts (and that they don't have fkspecs but fkspec but that's minimal ofc).

@Zaharid
Copy link
Contributor

Zaharid commented Jan 31, 2022

Can we make the cuts empty?

@scarlehoff
Copy link
Member Author

If #1506 goes through the same trick can be used here, yes (or whatever trick is used there after review)

@scarlehoff scarlehoff marked this pull request as draft February 1, 2022 13:18
@scarlehoff scarlehoff added the run-fit-bot Starts fit bot from a PR. label Feb 1, 2022
@scarlehoff
Copy link
Member Author

Marking this as draft because I would like to do #1506 first and would like to also add tests for the plots to ensure that bugs like the one shown in #1504 are avoided

@github-actions
Copy link

github-actions bot commented Feb 1, 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 😉!

@scarlehoff scarlehoff changed the base branch from master to allow_old_fit_with_bad_filters February 3, 2022 14:14
@scarlehoff scarlehoff marked this pull request as ready for review February 3, 2022 14:15
if len(self.fkspecs) > 1:
# The signature of the function does not accept operations either
# so more than one fktable cannot be utilized
raise ValueError("Positivity datasets can only contain one fktable")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

@scarlehoff scarlehoff Feb 3, 2022

Choose a reason for hiding this comment

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

I don't know why. But it seems to be the case (it is even called fkspec instead of fkspecs for positivity)

@scarlehoff
Copy link
Member Author

It was actually quite easy to make the Positivity behave as a normal Dataset, the only actual problems were due to things like fkspec vs fkspecs or commondata vs commondataspec but they seem to be perfectly compatible.

This allows for the removal of some of the specific functions for positivity (that were not used anywhere) since the generic ones can be used as well. One can go even a step forward and allow for operations on positivity but I haven't entered there.

@Zaharid
Copy link
Contributor

Zaharid commented Feb 3, 2022

Thinking in terms of #1500, a positivity should have everything that a theory prediction has (i.e. OP, a list of fktables) plus everything commondata has except for the actual data (same metadata, kinematics). cc @enocera

For now, it seems like a good idea to make it inherit from DatasetSpec as done here. But I'd get rid of the various gratuitous differences such as allowing only one fkspec, as these don't buy us very much.

@scarlehoff
Copy link
Member Author

But I'd get rid of the various gratuitous differences such as allowing only one fkspec, as these don't buy us very much.

Sadly those come from libNNPDF, but I agree, there should be no difference other than the actual data.

@Zaharid
Copy link
Contributor

Zaharid commented Feb 3, 2022

But I'd get rid of the various gratuitous differences such as allowing only one fkspec, as these don't buy us very much.

Sadly those come from libNNPDF, but I agree, there should be no difference other than the actual data.

But isn't the whole point of the exercise that we don't care any more?

@scarlehoff
Copy link
Member Author

But isn't the whole point of the exercise that we don't care any more?

Yes, we remove the things where libNNPDF is used little by little until it can be completely extirpated. But right now this ends whenever we have a libNNPDF class for which we have no substitute and, for positivity, that class happens to like single fktables:

return PositivitySet(cd, fk, self.maxlambda)

The same is true for the actual data, of course, but that accepts an fkset instead:

data = DataSet(cd, fkset, self.weight)

which is some combination of fktables:

fkset = FKSet(FKSet.parseOperator(self.op), fktables)

(also coming from libNNPDF)

Eventually both libNNPDF::PositivitySet and libNNPDF::DataSet will be replaced for inheritances of GenericDataHolder or whatever which won't have such inconsistencies in their signatures.

@Zaharid
Copy link
Contributor

Zaharid commented Feb 3, 2022

But why do we need to call the cpp class from python anymore? We don't have many whaky uses of it and seems to me it can be all replaced in one PR.

@Zaharid
Copy link
Contributor

Zaharid commented Feb 3, 2022

Do we even load it anywhere but here?

src/validphys/results.py
720:def positivity_predictions_data_result(pdf, posdataset):
722:    return PositivityResult.from_convolution(pdf, posdataset)

@scarlehoff
Copy link
Member Author

I don't know, but I'd rather wait until we have a substitute for the DataSet to create a PositivitySet that inherits from it rather than doing the PositivityOne first...

@Zaharid
Copy link
Contributor

Zaharid commented Feb 4, 2022

We can of course do it in two time, but seems to me having to change the interface negates many benefits of that. OTOH having a fully python positivity might help surface issues with the pure python approach.

@scarlehoff
Copy link
Member Author

Given that I broke completely positivity in #1504 and nothing broke until I looked at the comparefits I very much doubt that we'll see anything surface...

@Zaharid
Copy link
Contributor

Zaharid commented Feb 4, 2022

Given that I broke completely positivity in #1504 and nothing broke until I looked at the comparefits I very much doubt that we'll see anything surface...

I think that can be used as argument either way :)

But as said I'd favor forgetting about loading positivity sets via libnnpdf in vp, so we are more free to design the interface we like, in particular removing a couple of constraints from the current pr.

@scarlehoff
Copy link
Member Author

I think that can be used as argument either way :)

I don't see how.

Anyway, we do load positivity apparently exactly like we do with the datasets and given that they should be basically the same thing they probably should be changed at the same time: https://github.com/NNPDF/nnpdf/blob/master/validphys2/src/validphys/n3fit_data_utils.py and I would strongly prefer to do the datasets, which are the more general object, first.

Otherwise I will be creating some PositivitySetSpec that doesn't include a Cuts attribute and that uses commondataspec instead of commondata and that is completely incompatible with what should be the generic DataSetSpec.

@scarlehoff
Copy link
Member Author

Anyway, given that this one depends on #1506 we should finish that before we discuss on how to improve what's not yet done here x)

Base automatically changed from allow_old_fit_with_bad_filters to master February 5, 2022 09:48
@scarlehoff scarlehoff added run-fit-bot Starts fit bot from a PR. and removed run-fit-bot Starts fit bot from a PR. labels Feb 9, 2022
@scarlehoff
Copy link
Member Author

scarlehoff commented Feb 9, 2022

I should stop solving conflicts with the github editor because I do more harm than good...

@scarlehoff scarlehoff removed the run-fit-bot Starts fit bot from a PR. label Feb 9, 2022
@scarlehoff scarlehoff added the run-fit-bot Starts fit bot from a PR. label Feb 9, 2022
@github-actions
Copy link

github-actions bot commented Feb 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 😉!

@Zaharid
Copy link
Contributor

Zaharid commented Feb 10, 2022

As discussed I get the impression that the forced c++ compatibility can be dealt away swiftly, in a different PR. I think that should be done before the new commondata format is introduced as that should not be a prerequisite for any other work. But what is in here should be fine for now.

@scarlehoff scarlehoff removed the run-fit-bot Starts fit bot from a PR. label Feb 10, 2022
@scarlehoff scarlehoff merged commit 0160b26 into master Feb 10, 2022
@scarlehoff scarlehoff deleted the add_test_w_positivitiy branch February 10, 2022 15:22
@Zaharid Zaharid added the enhancement New feature or request label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
destroyingc++ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants