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

move per-run changes of L1-uGT emulator to beginRun (incl. loading of AXOL1TL model) #47070

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

missirol
Copy link
Contributor

@missirol missirol commented Jan 9, 2025

PR description:

This PR implements two improvements to the L1-uGT emulator. It goes in the direction of addressing #46740.

  • missirol@9dc135c moves several operations from L1TGlobalProducer::produce to L1TGlobalProducer::beginRun (these are operations that depend only on the L1T trigger menu, which (afaik) may only change during run transitions). In particular, this leads to building the map of "trigger conditions" (instances of classes inhering from ConditionEvaluation, one of them being AXOL1TLCondition) only once per run, as opposed to once per event.

  • missirol@fe94271 moves the initialisation of the hls4ml model in AXOL1TLCondition from its evaluateCondition method (used multiple times per event) to its constructor (called only a few times per run given missirol@9dc135c).

This PR requires cms-hls4ml/hls4mlEmulatorExtras#6, a simple improvement of the methods of the class hls4mlEmulatorExtras::ModelLoader in the hls4mlEmulatorExtras external (this update is available via cms-sw/cmsdist#9606).

(This PR will likely need to be rebased if #47030 is merged first.)

PR validation:

Validated in CMSSW_15_0_0_pre1 with the checks described in #46740 (comment).

If this PR is a backport, please specify the original PR and why you need to backport that PR. If this PR will be backported, please specify to which release cycle the backport is meant for:

N/A

…ditions

Move per-run operations which are currently
in L1TGlobalProducer::produce to L1TGlobalProducer::beginRun.

In particular, the creation of the "trigger conditions"
which is currently implemented in the method GlobalBoard::runGTL
is moved to a separate method named GlobalBoard::initTriggerConditions,
which is to be executed once per run
(as opposed to GlobalBoard::runGTL, which is executed once per event).
@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 9, 2025

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 9, 2025

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47070/43242

ERROR: Build errors found during clang-tidy run.

      |                        ^
src/L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h:82:33: note: member is declared here
--
src/L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc:66:18: error: no member named 'reset' in 'hls4mlEmulator::ModelLoader' [clang-diagnostic-error]
   66 |   m_model_loader.reset(cp.model_loader().model_name());
      |   ~~~~~~~~~~~~~~ ^
src/L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc:66:42: error: no member named 'model_name' in 'hls4mlEmulator::ModelLoader' [clang-diagnostic-error]
   66 |   m_model_loader.reset(cp.model_loader().model_name());
      |                        ~~~~~~~~~~~~~~~~~ ^
src/L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc:70:24: error: constructor for 'l1t::AXOL1TLCondition' must explicitly initialize the member 'm_model_loader' which does not have a default constructor [clang-diagnostic-error]
   70 | l1t::AXOL1TLCondition::AXOL1TLCondition(const l1t::AXOL1TLCondition& cp) : ConditionEvaluation() { copy(cp); }
      |                        ^
src/L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h:82:33: note: member is declared here
--
src/L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc:97:58: error: no member named 'model_name' in 'hls4mlEmulator::ModelLoader' [clang-diagnostic-error]
   97 |                                        << m_model_loader.model_name()
      |                                           ~~~~~~~~~~~~~~ ^
src/L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc:105:58: error: no member named 'model_name' in 'hls4mlEmulator::ModelLoader' [clang-diagnostic-error]
  105 |                                        << m_model_loader.model_name() << "\".";
      |                                           ~~~~~~~~~~~~~~ ^
Suppressed 761 warnings (757 in non-user code, 4 NOLINT).
--
gmake: *** [config/SCRAM/GMake/Makefile.coderules:129: code-checks] Error 2
gmake: *** [There are compilation/build errors. Please see the detail log above.] Error 2

if (m_saveAXOScore and m_storedAXOScore < 0 and cond.first == m_axoScoreConditionName and
not m_axoScoreConditionName.empty()) {
auto const* theCondition = dynamic_cast<AXOL1TLCondition*>(cond.second.get());
m_storedAXOScore = theCondition->getScore();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: as far as I understand, since condMap is a std::unordered_map, the order of the iterations in the loop is not known a priori, so if the L1T menu contains multiple instances of AXOL1TLCondition using different models, the choice of the model for which the score is saved is not well-defined either. As discussed in cms-sw/cmssw#45227 (comment), the current implementation of this score-saving logic is anyway based on the assumption that the L1T menu uses only a single AXOL1TL model, so what is implemented in this PR is arguably no worse than what is in master.

(My 2 cents is that one should consider removing this score-saving logic from the emulator, and just produce these score values via a dedicated plugin.)

Copy link
Contributor

Choose a reason for hiding this comment

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

(My 2 cents is that one should consider removing this score-saving logic from the emulator, and just produce these score values via a dedicated plugin.)

That was the very initial proposal, but in this case it is more difficult to map it to the version used in the L1 menu.
Do you have an idea whether one could read of the menu version in a producer upstream of the uGT emulator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand, everything about the L1T menu is known from (or, can be built from the info in) the EventSetup (e.g. from info in the GlobalTag), so one can access this kind of info in any producer "upstream of the uGT emulator". The only input which is needed "upstream of the uGT emulator" is the L1T objects.

(That said, I don't know how hard it would be to write such a plugin; I would need to look more closely at the details.)

@aloeliger
Copy link
Contributor

aloeliger commented Jan 10, 2025

Changes to the emulator infrastructure have been merged in: cms-hls4ml/hls4mlEmulatorExtras#6

@missirol
Copy link
Contributor Author

This PR requires cms-hls4ml/hls4mlEmulatorExtras#6, a simple improvement of the methods of the class hls4mlEmulatorExtras::ModelLoader in the hls4mlEmulatorExtras external.

The corresponding cmsdist update is in cms-sw/cmsdist#9606.

@smuzaffar
Copy link
Contributor

code-checks with cms.week1.PR_3baa1e1e/100.0-69c825376e90e94baba247811053046b

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47070/43259

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @missirol for master.

It involves the following packages:

  • L1Trigger/L1TGlobal (l1)

@aloeliger, @cmsbuild, @epalencia can you please review it and eventually sign? Thanks.
@Martin-Grunewald, @mmusich this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@artlbv
Copy link
Contributor

artlbv commented Jan 10, 2025

Just saw that, FYI @quinnanm

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

Successfully merging this pull request may close these issues.

5 participants