Skip to content

Add PyTorchAlpaka mini-batching support - #50794

Merged
cmsbuild merged 1 commit into
cms-sw:masterfrom
EmanueleCoradin:torch-batch-support
May 8, 2026
Merged

Add PyTorchAlpaka mini-batching support#50794
cmsbuild merged 1 commit into
cms-sw:masterfrom
EmanueleCoradin:torch-batch-support

Conversation

@EmanueleCoradin

Copy link
Copy Markdown
Contributor

This PR results from a collaboration with @valsdav. Thanks also to @Electricks94 for his help.

PR description:

This PR introduces native support for splitting a single SoA into multiple logical batches. TensorCollection now supports (batch_size, total_size) construction and computes per-batch offsets internally.

Validation

Validation is performed via dedicated mini-batch inference producers:

  • SimpleNetMiniBatch
  • TinyResNetMiniBatch

The latter reproduces the same inference as the non-batched implementations using the new batching API.
InspectionSink has been extended to compare outputs between the standard and the batched inference.
A relative difference check is enforced: |ref - batched| / ref < 1e-5

It can be run by:

cd src/PhysicsTools/PyTorchAlpakaTest/test/
cmsRun runPyTorchAlpakaTest.py --compareBatch -e 3

Notes / limitations

  • Batch size must be chosen to satisfy the alignment constraint.

@cmsbuild cmsbuild added this to the CMSSW_17_0_X milestone Apr 23, 2026
@EmanueleCoradin

Copy link
Copy Markdown
Contributor Author

type ngt

@cmsbuild

cmsbuild commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

cms-bot internal usage

@cmsbuild cmsbuild added the ngt label Apr 23, 2026
@cmsbuild

Copy link
Copy Markdown
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50794/49105

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50794/49114

@cmsbuild

Copy link
Copy Markdown
Contributor

Pull request #50794 was updated.

@cmsbuild

Copy link
Copy Markdown
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50794/49118

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50794/49119

@cmsbuild

Copy link
Copy Markdown
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-50794/49166

@cmsbuild

Copy link
Copy Markdown
Contributor

Pull request #50794 was updated. @cmsbuild, @fwyzard, @hjkwon260, @makortel, @valsdav, @y19y19 can you please check and sign again.

@EmanueleCoradin

Copy link
Copy Markdown
Contributor Author

@fwyzard , thanks for the review. I addressed the other comments, the only ones left are:

While unrelated to this PR, I would suggest changing all print() functions to emit the final message using the MessageLogger.
While (mostly) unrelated to this PR, I would suggest to use a single letter for the short options (e.g. `'-t' for the number of threads, etc).

Since PR #50790 is also modifying the InspectionSink, I’d prefer to address these points before merging whichever of #50794 or #50790 goes in last. Would that be OK?

@fwyzard

fwyzard commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

It's fine by me if those two points are addressed in a separate PR.

@fwyzard

fwyzard commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

please test

@cmsbuild

Copy link
Copy Markdown
Contributor

+1

Size: This PR adds an extra 24KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-927f37/52928/summary.html
COMMIT: 43bafa2
CMSSW: CMSSW_17_0_X_2026-04-28-1100/el8_amd64_gcc13
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/50794/52928/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 1 lines to the logs
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 53
  • DQMHistoTests: Total histograms compared: 4186963
  • DQMHistoTests: Total failures: 3
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 4186940
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 52 files compared)
  • Checked 227 log files, 197 edm output root files, 53 DQM output files
  • TriggerResults: no differences found

@mmusich

mmusich commented May 7, 2026

Copy link
Copy Markdown
Contributor

+heterogeneous

@fwyzard do you mind signing again?

@fwyzard

fwyzard commented May 7, 2026

Copy link
Copy Markdown
Contributor

+heterogeneous

@valsdav

valsdav commented May 7, 2026

Copy link
Copy Markdown
Contributor

+ml

@cmsbuild

cmsbuild commented May 7, 2026

Copy link
Copy Markdown
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. @ftenchini, @sextonkennedy, @mandrenguyen (and backports should be raised in the release meeting by the corresponding L2)

@mandrenguyen

Copy link
Copy Markdown
Contributor

+1

@cmsbuild
cmsbuild merged commit 49c66cf into cms-sw:master May 8, 2026
10 checks passed
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