Skip to content

Keep a merged Lorentz structure out of the UFO module, so customize_model accepts SMEFTatNLO-NLO - #182

Merged
oliviermattelaer merged 1 commit into
mainfrom
claude/customize-model-nlo-restriction
Sep 19, 2026
Merged

oliviermattelaer merged 1 commit into
mainfrom
claude/customize-model-nlo-restriction

Conversation

@oliviermattelaer

Copy link
Copy Markdown
Contributor

The refusal

MG7> import model SMEFTatNLO-NLO
MG7> customize_model --save=top          # then just `done`
Two restrictions of the model done with different input values do not lead
to the same model.  Difference(s) found for: interactions
...
InvalidCmd: customize_model can not be applied to this model.

Only from -NLO: from SMEFTatNLO, -NLO_no4q, -LO or sm it works. Found
while adding a customize_model step to the bsm tutorial (#165), which now
uses SMEFTatNLO-NLO.

What differed

Nothing physical. With ADMIN_DEBUG on, the two restrictions had the same
t t~ g g vertex, same couplings, same Lorentz structures but one:
FFVV1111 in the first build, FFVV1112 in the second. Neither name is in the
UFO — the restriction merges structures (RestrictModel.add_merge_lorentz) and
names the result.

Why the name moved

The first build leaked it. A UFO Lorentz registers itself in its
object_library.all_lorentz on construction — a module global, cached in
sys.modules for the rest of the process. RestrictModel.add_lorentz never
took its structure back out, so each import of the same restricted model
started with the previous one's merged structures already defined, grew by
them, and numbered its own one further on:

import_ufo.import_model(SMEFTatNLO, restrict=restrict_NLO.dat)   x3
  before:  658, 661, 664 Lorentz structures   (FFVV1111 left in the UFO module)
  after:   658, 658, 658

Instrumented: all three leaked structures per import come from
RestrictModel.add_lorentz; the 55 created by UFOMG5Converter.add_lorentz
don't, because it already swaps all_lorentz out while constructing. This
applies the same guarantee to the restriction's own structures.

Effect

  • customize_model --save from SMEFTatNLO-NLO goes through and writes its
    restriction card (checked on a copy of the model; main still refuses).
  • A long session — the tutorials, a script importing the same model twice — no
    longer carries one import's merged structures into the next.

Checked

  • New test in test_import_ufo.py: a merged structure lands in the model and
    not in the UFO library it was built from. It fails without the fix.
  • Every unit test file touching restrictions or import model (1464 tests):
    unchanged. The 3 TestRealRunNumbers failures need a madspace build this
    worktree doesn't have.

🤖 Generated with Claude Code

…odel accepts SMEFTatNLO-NLO

`import model SMEFTatNLO-NLO` then `customize_model --save=NAME` was refused
even with nothing changed:

  Two restrictions of the model done with different input values do not
  lead to the same model.  Difference(s) found for: interactions
  ...
  InvalidCmd: customize_model can not be applied to this model.

The two restrictions were the same model.  The t t~ g g vertex differed by
the name of one Lorentz structure -- FFVV1111 in the first, FFVV1112 in the
second -- a name neither in the UFO: the restriction merges structures
(RestrictModel.add_merge_lorentz) and names the result.

The name moved because the first build leaked it.  A UFO Lorentz registers
itself in its object_library's all_lorentz on construction, and that list is
a module global, cached in sys.modules for the rest of the process.
RestrictModel.add_lorentz never took its structure back out, so every
import of the same restricted model started with the previous one's merged
structures already defined, grew by them again, and numbered its own one
further on:

  import model SMEFTatNLO-NLO   658, then 661, then 664 Lorentz structures

UFOMG5Converter.add_lorentz already keeps its structures out of that list;
RestrictModel.add_lorentz now does the same, and the three imports give 658
each time.  customize_model --save from SMEFTatNLO-NLO goes through and
writes its restriction card.  It worked from SMEFTatNLO, -NLO_no4q, -LO and
sm already: those restrictions merge no structure.

Beyond customize_model, this also stops a long session -- the tutorials, a
script importing the same model twice -- from carrying one import's merged
structures into the next.

Test: a merged structure is added to the model and not to the UFO library it
was built from (fails without the fix).  The restriction-related unit tests
(1464) are otherwise unchanged; the three TestRealRunNumbers failures need a
madspace build this worktree does not have.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
oliviermattelaer added a commit that referenced this pull request Sep 18, 2026
The permutation check goes (`tutorial checks` is where the checks live); the
interference lesson now leads into a restriction of the reader's own:

  customize_model --save=top     at its question, the hint says what a top
                                 pair never sees and how to switch it off:
                                   set DIM64F2L all 0     two quarks, two leptons
                                   set DIM64F4L all 0     four leptons
                                 and warns off `set DIM6 all 0`: that block
                                 holds Lambda, and a zero scale divides by zero
                                 (which is what that looks like in practice)
  -> "SMEFTatNLO-top is loaded: 22 particles, 1875 interactions", and where
     the card was saved; plus the one thing to know -- customize_model starts
     again from the full model, so what -NLO had switched off comes back on
  import model SMEFTatNLO-top    the same restriction, loaded by name, which
                                 closes the tutorial with the EFT pitfalls

Needs the fix merged just before (#182): customize_model refused
SMEFTatNLO-NLO outright.  Checked live, on a copy of the model so the
restriction card is not written into the real one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@oliviermattelaer
oliviermattelaer merged commit f1a944f into main Sep 19, 2026
526 checks passed
@oliviermattelaer
oliviermattelaer deleted the claude/customize-model-nlo-restriction branch September 19, 2026 05:14
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.

1 participant