Skip to content

Add neopdf PDF interpolation backend#2478

Open
Radonirinaunimi wants to merge 10 commits into
masterfrom
neopdf-backend
Open

Add neopdf PDF interpolation backend#2478
Radonirinaunimi wants to merge 10 commits into
masterfrom
neopdf-backend

Conversation

@Radonirinaunimi

@Radonirinaunimi Radonirinaunimi commented Jun 1, 2026

Copy link
Copy Markdown
Member

The following introduces a PDF backend module so that one can in principle support any PDF interpolation library. Currently, LHAPDF and NeoPDF are supported and they can be used interchangeably given that they are numerically equivalent (bit-for-bit). (This eventually paves the way to a Conda-free dependency).

@scarlehoff

Copy link
Copy Markdown
Member

Thanks for this.

My main comment is that the validphys is already provider agnostic and the backend selecting code already exists: https://github.com/NNPDF/nnpdf/blob/master/validphys2/src/validphys/lhapdf_compatibility.py

I think what you did should be easy to modify so that it works similarly to pdfflow, without breaking it or adding a third way of changing the backend.

As to how to change the backend, I would put it in the profile. With pdfflow is just a "in case of failure finding lhapdf". Then we can eventually change the default.

(the conda dependence will be there 4ever for pandoc reasons I'm afraid :__)

Comment thread validphys2/src/validphys/neopdfset.py Outdated
for member in self.members:
vals = np.array(member.xfxQ2s(pids, xgrid, q2grid))
results.append(vals.reshape(nfl, nx, nq))
return np.array(results)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is repeating actually a lot of codes (which I'm strongly against)

As far as I can see you can do the same I did for pdfflow but the wrapper would be just 4 lines or so instead of an entire class.

Then the make_pdf in pdf_compatibility is the only place in which a choice needs to be made.

Most importantly, core.py should have no changes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @scarlehoff for having looked into this already. This is still very much in WIP (although things are already in place and working) and thus I am not entirely convinced yet about how to best implement the interface. However, I fully agree with you about the redundancy part and started addressing this in 484110. Now, the unnecessary modules/codes have been removed.

As to how to change the backend, I would put it in the profile. With pdfflow is just a "in case of failure finding lhapdf". Then we can eventually change the default.

Yes, I agree with this.

(the conda dependence will be there 4ever for pandoc reasons I'm afraid :__)

Yeah, which we may want to get rid of at some point... although the alternative is not so clear.

Comment thread pyproject.toml Outdated
docs = ["sphinxcontrib-bibtex", "sphinx-rtd-theme", "sphinx", "tabulate"]
qed = ["fiatlux"]
nolha = ["pdfflow", "lhapdf-management"]
neopdf = ["neopdf-hep"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
neopdf = ["neopdf-hep"]
neopdf = ["neopdf-hep", "lhapdf-management"]

I haven't maintained pdfflow in a while and you are actively maintaining neopdf. Perhaps it makes sense to change nolha to pdfflow and make neopdf be nolha.

"""
backend = os.environ.get(_BACKEND_ENV_VAR, "lhapdf").lower()

if backend not in _VALID_BACKENDS:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fwiw, to get the information from the profile just get_nnpdf_profile() is enough (from nnpdf_data::utils)

I'm not sure right now whether one can add variables at will without changing that function (in any case it would be trivial). The important thing is, don't add a new default to get_nnpdf_profile for pdf_backend but rather add explicitly to validphys/nnprofile_default.yaml pdf_backend: lhapdf.

The goal I have in mind is that people can start using neopdf there if they like and in a few months we try to swap the default and see what happens.

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.

2 participants