Skip to content

Remove need for _template.yaml#223

Open
evagroenendijk wants to merge 23 commits into
mainfrom
remove_template
Open

Remove need for _template.yaml#223
evagroenendijk wants to merge 23 commits into
mainfrom
remove_template

Conversation

@evagroenendijk
Copy link
Copy Markdown
Contributor

@evagroenendijk evagroenendijk commented May 23, 2025

Remove the need for _template.yaml as in issue #202

@evagroenendijk evagroenendijk self-assigned this May 23, 2025
@evagroenendijk evagroenendijk linked an issue May 23, 2025 that may be closed by this pull request
@felixhekhorn felixhekhorn added the enhancement New feature or request label May 26, 2025
@evagroenendijk
Copy link
Copy Markdown
Contributor Author

https://github.com/NNPDF/pineko/blob/f4097f29dec964e8b2c17818b502575ffa3444f0/tests/test_evolve.py#L55C1-L55C43

@scarlehoff Could I maybe just remove this test? I could make it check that the theory cards' Q0 is the same as the default one, but to me it seems a bit superfluous

@scarlehoff
Copy link
Copy Markdown
Member

Sure, shuffling around the _template and the operators might change which tests are needed.

Copy link
Copy Markdown
Contributor

@felixhekhorn felixhekhorn left a comment

Choose a reason for hiding this comment

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

some quick things I noticed last week

Comment thread src/pineko/template.py Outdated
Comment thread src/pineko/template.py Outdated
@scarlehoff scarlehoff self-requested a review May 19, 2026 12:34
@scarlehoff scarlehoff marked this pull request as ready for review May 19, 2026 12:35
Comment thread benchmarks/bench_regression.py Outdated
Comment thread src/pineko/opcard_template.py
Comment thread src/pineko/evolve.py Outdated
@evagroenendijk
Copy link
Copy Markdown
Contributor Author

@felixhekhorn The regression benchmark comparing convolved predictions failed, but the maximal relative difference is 0.03497747. Would you say it's close enough?

@scarlehoff
Copy link
Copy Markdown
Member

scarlehoff commented May 20, 2026

The template name should be removed from here:

"operator_card_template_name",

also the NEEDED_FILE (and then needs to be removed from scaffold.py)

Copy link
Copy Markdown
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.

This small of a relative difference is ok I'd say.

Comment thread src/pineko/template.py Outdated
Comment on lines +59 to +61
"ev_op_iterations": 60,
"evolution_method": "iterate-exact",
"inversion_method": "expanded",
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.

These should be sourced from the theory card and only from there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is the inversion method also set in the theory card? I can't find it in the current theory cards

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.

@felixhekhorn what about the inversion method?
I think for the evolution of the PDF we simply fix

truncated -> expanded
iterate-exact -> exact

Should we fix the same here? Or is this not relevant and we can use expanded in both cases?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For now I put

if "inversion_method" in tcard:
opconf = operators_card["configs"]
opconf["inversion_method"] = tcard["inversion_method"]
else:
opconf["inversion_method"] = opcard_template.CONSTANTS["configs"]["inversion_method"]
logger.warning(
"Inversion method not set in theory card, it's being set to default value "
f"{opcard_template.CONSTANTS['configs']['inversion_method']}. "
"Check if that is what you want."
)

But I can change it

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.

Let's see what Felix says.

Fwiw, in python this can be shortened to:

opconf["inversion_method"] = tcard.get("inversion_method", opcard_template.CONSTANTS["configs"]["inversion_method"])

(also because I think right now you are overwritting the whole of opconf with `operator_card["configs"] I think, is that what you want?)

If the inversion method is irrelevant and can be set constant, I think the warning is not necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

truncated -> expanded
iterate-exact -> exact

this is a choice which seems consistent, but is not necessary. I think we can assume this mapping as default here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll change it to that then!

Comment thread src/pineko/template.py Outdated
Copy link
Copy Markdown
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 meant to request changes 😅

@felixhekhorn
Copy link
Copy Markdown
Contributor

@felixhekhorn The regression benchmark comparing convolved predictions failed, but the maximal relative difference is 0.03497747. Would you say it's close enough?

I'm quite worried by this

Your theory has a different evolution method than the default(iterate-exact vs truncated).The evolution method will be set to the default value iterate-exact, check if this is what you want
Warning! The number of iteration in the theory and template is different, (60 vs 1).The number of iterations will be set to default value 60, check if this is what you want

this sounds like we can no longer run actually truncated - i.e. we can no longer reproduce 4.0. If that would be true that must be changed. This might well explain the difference we observe. We want to enforce consistent settings, i.e. "if method=truncated then iterations=1", but we don't want to enforce method=exact everywhere.

@scarlehoff
Copy link
Copy Markdown
Member

This has to do with the comment I left. We just want to ensure that the evolution settings are coming from the theory not from a constant setting.

@evagroenendijk
Copy link
Copy Markdown
Contributor Author

@felixhekhorn The regression benchmark comparing convolved predictions failed, but the maximal relative difference is 0.03497747. Would you say it's close enough?

I'm quite worried by this

Your theory has a different evolution method than the default(iterate-exact vs truncated).The evolution method will be set to the default value iterate-exact, check if this is what you want
Warning! The number of iteration in the theory and template is different, (60 vs 1).The number of iterations will be set to default value 60, check if this is what you want

this sounds like we can no longer run actually truncated - i.e. we can no longer reproduce 4.0. If that would be true that must be changed. This might well explain the difference we observe. We want to enforce consistent settings, i.e. "if method=truncated then iterations=1", but we don't want to enforce method=exact everywhere.

You're right! I think here I ran the benchmark while using iterate-exact (which I hardcoded into template.py). But as Juan suggested I will now let the evolution method be totally determined by the theory card. Then it would also do truncated evolution

Comment thread src/pineko/configs.py
"fktables",
"ekos",
]
NEEDED_FILES = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be removed entirely?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At first I did that, but then I thought it would be useful to leave it in case at any point there is another adjustment to the code that needs some files. It's what I thought, but let me know if you think differently

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.

I would remove unnecessary code and then re-add it if needed given past experiences with having a very big graveyard of code

Comment thread src/pineko/evolve.py Outdated
Comment thread src/pineko/evolve.py
@@ -266,14 +266,15 @@

# Choose the evolution method according to the theory if the key is included
if "ModEv" in tcard:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a friend of early exits in code, since they safe indents - thus I suggests

if "ModEv" not in tcard:
    raise ValueError("blub")
# no explicit `else` needed nor the associated indentation

same for "IterEv" I would say

Comment thread src/pineko/evolve.py
Comment on lines 288 to 295
if (
operators_card["configs"]["evolution_method"] == "truncated"
and operators_card["configs"]["ev_op_iterations"] > 1
):
logger.warning(
"Warning! You are setting evolution_method=truncated with ev_op_iterations>1,"
"are you sure that's what you want?"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can never happen now with this structure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point

Comment thread src/pineko/evolve.py
opconf["ev_op_iterations"] = 1
operators_card["configs"]["evolution_method"] = "truncated"
operators_card["configs"]["ev_op_iterations"] = 1
operators_card["configs"]["inversion_method"] = "expanded"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you maybe add a # TODO there saying something like "we impose a default now, but we may at later point allow the user to choose (e.g. via CLI)"

Copy link
Copy Markdown
Contributor Author

@evagroenendijk evagroenendijk May 22, 2026

Choose a reason for hiding this comment

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

It's now already possible to determine these from the CLI (when doing "pineko theory opcards ..." and when doing "pineko opcard ... ")

edit: ah no, I'm sorry I was confused and talking about the other settings! I can add the to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove operator_cards (and _template.yaml)

4 participants