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

DeepTau - Do not call TF inference with empty grid #44455

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

valsdav
Copy link
Contributor

@valsdav valsdav commented Mar 18, 2024

PR description:

Fix DeepTau issue #44333

[2] Calling method for module DeepTauId/'hltHpsPFTauDeepTauProducerForVBFIsoTau'
Exception Message:
error while running session: INVALID_ARGUMENT: Incompatible shapes: [0,1,1,64] vs. [154]

The number of valid_grid_cells here is 0 for some events and this is creating a TF::Tensor with shape [0, 1, 1, N].

When this input is passed to a TF model executed on a CPU without AVX512F AVX512_VNNI, the model is executed and returns an empty output without complaining. When AVX512F AVX512_VNNI instructions are present, the TF executor complains.

This PR avoids calling the TF inference if empty inputs are detected.

The grid should never be empty. The issue will be followed up with Tau experts (enter here issue number..)

PR validation:

Works on the issue reproducer from #44333 (comment)

  • lxplus901 for AVX512
  • Pick event:
edmCopyPickMerge outputFile=pickevents.root eventsToProcess=367131:196942831 inputFiles=/store/data/Run2023C/DisplacedJet/RAW/v1/000/367/131/00000/9f3f571f-6dc9-4bda-a68b-5d1b9a5fc3ac.root
  • Run:
cmsDriver.py step2 --conditions auto:run3_hlt_relval --data --datatier FEVTDEBUGHLT --era Run3_2023 --eventcontent FEVTDEBUGHLT --filein file:pickevents.root --fileout file:step2.root --nStreams 4 --nThreads 8 --number -1 --process reHLT --python_filename step_2_cfg.py --step L1REPACK:Full,HLT:@relval2024 --accelerators cpu

@cmsbuild
Copy link
Contributor

cmsbuild commented Mar 18, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44455/39530

  • This PR adds an extra 28KB to repository

@cmsbuild
Copy link
Contributor

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

It involves the following packages:

  • RecoTauTag/HLTProducers (hlt)
  • RecoTauTag/RecoTau (reconstruction)

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

cms-bot commands are listed here

@valsdav
Copy link
Contributor Author

valsdav commented Mar 18, 2024

assign ml
type tau

@cmsbuild
Copy link
Contributor

New categories assigned: ml

@valsdav,@wpmccormack you have been requested to review this Pull request/Issue and eventually sign? Thanks

@valsdav
Copy link
Contributor Author

valsdav commented Mar 18, 2024

please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-e9b7b8/38241/summary.html
COMMIT: 6bb9279
CMSSW: CMSSW_14_1_X_2024-03-18-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/44455/38241/install.sh to create a dev area with all the needed externals and cmssw changes.

The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic:

You can see more details here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-e9b7b8/38241/git-recent-commits.json
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-e9b7b8/38241/git-merge-result

Comparison Summary

Summary:

@jfernan2
Copy link
Contributor

+1

@@ -732,7 +732,10 @@ void L2TauNNProducer::fillPatatracks(tensorflow::Tensor& cellGridMatrix,

std::vector<float> L2TauNNProducer::getTauScore(const tensorflow::Tensor& cellGridMatrix) {
std::vector<tensorflow::Tensor> pred_tensor;
tensorflow::run(L2cacheData_->session, {{inputTensorName_, cellGridMatrix}}, {outputTensorName_}, &pred_tensor);
// Check for empty input
if (cellGridMatrix.NumElements() != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

does cellGridMatrix.NumElements() == 0 guarantee that nTau is also 0, such that accessing pred_tensor[0] doesn't result in undefined behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is guaranteed because nTaus = cellGridMatrix.shape().dim_size(0), which is the same check, but I agree that it can be improved by wrapping all the snippet around a if (nTaus > 0).
If you wish I can rework it quickly

Copy link
Contributor

Choose a reason for hiding this comment

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

If you wish I can rework it quickly

perhaps leave a comment, if it's guaranteed let's not add more if branches.
Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

@valsdav will you apply the suggestion above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I'm about to push a commit with improvements 👍

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-e9b7b8/38263/summary.html
COMMIT: ba3ec51
CMSSW: CMSSW_14_1_X_2024-03-19-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/44455/38263/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@jfernan2
Copy link
Contributor

+1

@mmusich
Copy link
Contributor

mmusich commented Mar 19, 2024

+hlt

@valsdav
Copy link
Contributor Author

valsdav commented Mar 19, 2024

+ml

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @rappoccio, @antoniovilela, @sextonkennedy (and backports should be raised in the release meeting by the corresponding L2)

@antoniovilela
Copy link
Contributor

+1

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.

6 participants