onnx / onnx/optimizer

[BUG] The Pass “eliminate_nop_pad" causes output mismatch

Open
#261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
834
Forks
109
Avg merge
6h 55m
Merged PRs (30d)
2

Description

Issue
eliminate_nop_pad (onnxoptimizer 0.4.2) produces numerical differences between the optimized graph and oracle in case_02937_seed43509122. Only output tensors v17_0 (output[12]) and v49_0 (output[17]) differs.

Environment

  • Ubuntu 20.04
  • Python 3.10
  • onnx==1.19.0
  • onnxruntime==1.19.2
  • onnxoptimizer==0.4.2 (latest)

Repro steps (run from this folder)

  1. Download and unzip the attached archive below, then cd into the extracted directory

eliminate_nop_pad_repro.tar.gz

tar -xzvf eliminate_nop_pad_repro.tar.gz
cd eliminate_nop_pad_repro
  1. Create a Python 3.10 virtual environment and install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
  1. Optimize the problematic case with only eliminate_nop_pad:
python optimize_model.py --case case_02937_seed43509122
  1. Run the differential test to compare the optimized graph vs the oracle with ORT optimizations disabled:
python diff_test.py --case case_02937_seed43509122

Expected
All outputs should match the reference so diff_test.py prints “All outputs matched exactly.” NaN-laden tensors in other cases may trigger numpy warnings, but those are irrelevant because only case_02937 is being evaluated here, and disabling ORT graph optimizations keeps constant-fold warnings out of the log.

Differential Test Output Details

Case: case_02937_seed43509122
Mismatched outputs (optimized vs reference):
  v17_0 (output[12]): max_abs=1.221e-04, max_rel=7.163e-04, shape=(2, 1, 16, 2)
  v49_0 (output[17]): max_abs=1.221e-04, max_rel=9.747e-04, shape=(44, 1, 16, 46, 2)
Overall: max_abs=1.221e-04, max_rel=9.747e-04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running optimize_model.py and diff_test.py for case_02937_seed43509122 from the extracted reproduction directory. Trace the eliminate_nop_pad pass while comparing outputs v17_0 and v49_0 against the oracle. Done means diff_test.py reports “All outputs matched exactly.”

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.