-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
onnxoptimizer eliminate_nop_concat causes output mismatch
Issue
Hi, maintainers. Running the single pass eliminate_nop_concat with onnxoptimizer 0.3.19 changes numerical outputs. Two real models regress after this pass only, while the original models run correctly with the same oracle inputs.
Environment
- Ubuntu 20.04
- Python 3.10
- onnx==1.19.0
- onnxruntime==1.23.2
- onnxoptimizer==0.3.19 (latest)
Repro steps (run from this folder)
- Download and unzip the attached archive, then
cdinto the extracted directory
eliminate_nop_concat_repro.tar.gz
tar -xzvf eliminate_nop_concat_repro.tar.gz
cd eliminate_nop_concat_repro
- Create a Python environment (Python 3.10) and install dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt
- Optimize a case with only
eliminate_nop_concat:
python optimize_model.py --case ./case_00531_seed24456008python optimize_model.py --case ./case_03379_seed47009320
(Writesmodel.opt.onnxnext tomodel.onnxin each case directory.)
- Differential test original vs optimized outputs using stored oracle inputs:
python diff_test.py --case ./case_00531_seed24456008python diff_test.py --case ./case_03379_seed47009320
Observed results
- case_00531_seed24456008:
overall max_abs=1.953e-03,max_rel=5.995e-04(one output tensor differs; others match). - case_03379_seed47009320: large drift,
overall max_abs=1.614e+04,max_rel=1.918e+01; multiple outputs diverge. - ORT logs warnings about missing constant folding kernels (Cos/Floor/Tan/Resize); these are present for both original and optimized runs and are not fatal, but optimized outputs still mismatch.
Expected
eliminate_nop_concat should be semantics-preserving. Applying this pass alone should not change any output values. Please investigate why the optimized graphs for the above cases produce different outputs and whether the pass is incorrectly modifying concat inputs/axes or tensor ordering.
Differential Test Output Details
- case_00531_seed24456008
Case: case_00531_seed24456008
output[0]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 2, 1)
output[1]: max_abs=0.000e+00, max_rel=0.000e+00, shape=()
output[2]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 1, 1)
output[3]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(7, 23, 56, 1, 2)
output[4]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 2)
output[5]: max_abs=0.000e+00, max_rel=0.000e+00, shape=()
output[6]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(7, 23, 56, 1, 1)
output[7]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(7, 23, 56, 1, 1)
output[8]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(7, 23, 1, 1, 1)
output[9]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(9016,)
output[10]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(7, 23, 56, 1, 1)
output[11]: max_abs=1.953e-03, max_rel=5.995e-04, shape=(7, 23, 56, 1, 1)
Overall: max_abs=1.953e-03, max_rel=5.995e-04
- case_03379_seed47009320
Case: case_03379_seed47009320
output[0]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1)
output[1]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(32, 1)
output[2]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 42, 41, 1, 32)
output[3]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 41, 1, 32)
output[4]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 41, 1, 32)
output[5]: max_abs=1.191e-01, max_rel=1.284e+00, shape=(1, 45, 41, 1, 32)
output[6]: max_abs=1.614e+04, max_rel=1.918e+01, shape=(1, 45, 41, 1, 32)
output[7]: max_abs=1.225e+01, max_rel=1.284e+00, shape=(45, 41, 1, 32)
output[8]: max_abs=8.339e-01, max_rel=1.322e+01, shape=(45, 41, 1)
output[9]: max_abs=7.356e-01, max_rel=1.224e+01, shape=(45, 41, 1)
output[10]: max_abs=8.339e-01, max_rel=1.322e+01, shape=(45, 41, 1)
output[11]: max_abs=8.339e-01, max_rel=1.322e+01, shape=(45, 41, 1, 1)
Overall: max_abs=1.614e+04, max_rel=1.918e+01
Attachments
README.md(this document)requirements.txt(dependency versions)optimize_model.py(runs onlyeliminate_nop_concatand savesmodel.opt.onnx)diff_test.py(runs original vs optimized with oracle inputs and reports max_abs/max_rel)case_00531_seed24456008/(containsmodel.onnxwhich is original model,oracle.pklwhich is the input data of both original and optimized model)case_03379_seed47009320/(containsmodel.onnx,oracle.pkl)
Metadata
Metadata
Assignees
Labels
No labels