Skip to content

[tmva][sofie] Fix TMVA_SOFIE_ONNX tensor name for current PyTorch#21546

Open
Neeraj-x0 wants to merge 1 commit intoroot-project:masterfrom
Neeraj-x0:fix/sofie-onnx-tutorial-tensor-name
Open

[tmva][sofie] Fix TMVA_SOFIE_ONNX tensor name for current PyTorch#21546
Neeraj-x0 wants to merge 1 commit intoroot-project:masterfrom
Neeraj-x0:fix/sofie-onnx-tutorial-tensor-name

Conversation

@Neeraj-x0
Copy link
Copy Markdown
Contributor

The tutorial hardcoded tensor name '16weight' which was generated by an older
PyTorch version. Current PyTorch Sequential modules produce tensors named
'0weight', '2weight', '4weight' (dot stripped by SOFIE).

Updated TMVA_SOFIE_ONNX.C to use '0weight' and regenerated Linear_16.onnx
using current PyTorch to keep tutorial and test model in sync.

Fixes: tutorial crash with runtime_error on GetTensorShape('16weight')

This Pull request:

Changes or fixes:

  • Replaced hardcoded tensor name 16weight with 0weight in TMVA_SOFIE_ONNX.C
  • Updated all print statements referencing the tensor name for consistency
  • Regenerated tmva/sofie/test/input_models/Linear_16.onnx using current PyTorch

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #21545

Copilot AI review requested due to automatic review settings March 10, 2026 07:22
@Neeraj-x0 Neeraj-x0 requested review from couet and lmoneta as code owners March 10, 2026 07:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the TMVA SOFIE ONNX tutorial and its companion test artifact to align with tensor naming produced by current PyTorch/ONNX exports (e.g., 0.weight0weight after SOFIE name cleaning), fixing a runtime crash when querying tensor shapes/types.

Changes:

  • Updated the tutorial macro to query 0weight instead of the obsolete 16weight.
  • Updated tutorial print statements to match the new tensor name.
  • Regenerated tmva/sofie/test/input_models/Linear_16.onnx using a current PyTorch export.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
tutorials/machine_learning/TMVA_SOFIE_ONNX.C Updates the hardcoded tensor queried by the tutorial to match current PyTorch naming.
tmva/sofie/test/input_models/Linear_16.onnx Updates the test ONNX model artifact to match current PyTorch export output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tutorials/machine_learning/TMVA_SOFIE_ONNX.C Outdated
@Neeraj-x0 Neeraj-x0 force-pushed the fix/sofie-onnx-tutorial-tensor-name branch from 36bd605 to 62f73f0 Compare March 10, 2026 07:28
@siliataider siliataider requested a review from sanjibansg March 10, 2026 09:01
@guitargeek guitargeek changed the title tutorials/ml: fix TMVA_SOFIE_ONNX tensor name for current PyTorch [tmva][sofie] Fix TMVA_SOFIE_ONNX tensor name for current PyTorch Mar 25, 2026
Copy link
Copy Markdown
Collaborator

@sanjibansg sanjibansg left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks, I would wait for the CI Jobs verification before we could merge this.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Test Results

    20 files      20 suites   2d 22h 28m 7s ⏱️
 3 830 tests  3 823 ✅  1 💤  6 ❌
69 337 runs  69 274 ✅ 18 💤 45 ❌

For more details on these failures, see this check.

Results for commit f05a1c1.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

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

CI did not pass

@Neeraj-x0
Copy link
Copy Markdown
Contributor Author

CI did not pass

Working on it — the fix requires regenerating Linear_16.onnx with a fixed seed and updating the reference values in TestCustomModelsFromONNX.cxx alongside the clang-format fixes. Will push shortly.

@couet couet removed their request for review March 27, 2026 16:34
@guitargeek guitargeek added the clean build Ask CI to do non-incremental build on PR label Apr 14, 2026
The tutorial hardcoded tensor name '16weight' which was generated by
an older PyTorch version. Current PyTorch Sequential modules produce
tensors named '0weight', '2weight', '4weight' (dot stripped by SOFIE).

Updated TMVA_SOFIE_ONNX.C to use '0weight' and regenerated Linear_16.onnx
using current PyTorch to keep tutorial and test model in sync.

Fixes: tutorial crash with runtime_error on GetTensorShape('16weight')
@guitargeek guitargeek force-pushed the fix/sofie-onnx-tutorial-tensor-name branch from 62f73f0 to f05a1c1 Compare April 14, 2026 12:42
@guitargeek
Copy link
Copy Markdown
Contributor

In that case the CI should pass with a clean build. I have triggered one, and also rebased your commits on top of ROOT master. Will merge once the CI passes.

Copy link
Copy Markdown
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

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

Tests still fail even when doing a clean rebuild of everything in the CI. @Neeraj-x0, can you please take a look?

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

Labels

clean build Ask CI to do non-incremental build on PR in:SOFIE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tmva][sofie] TMVA_SOFIE_ONNX.C tutorial fails with modern PyTorch due to tensor name mismatch

5 participants