[BUG] Pass "fuse_consecutive_squeezes" causes output mismatch
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 834
- Forks
- 109
- Avg merge
- 6h 55m
- Merged PRs (30d)
- 2
Description
[BUG] Pass "fuse_consecutive_squeezes" causes output mismatch
Issue
Running the single pass fuse_consecutive_squeezes with onnxoptimizer 0.3.19 changes numerical outputs. A real model regresses only after this pass, while the original model runs 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
fuse_consecutive_squeezes_repro.tar.gz
tar -xzvf fuse_consecutive_squeezes_repro.tar.gz
cd fuse_consecutive_squeezes_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
fuse_consecutive_squeezes:
python optimize_model.py --case ./case_02867_seed42954792
(Writesmodel.opt.onnxnext tomodel.onnxin the case directory.)
- Differential test original vs optimized outputs using stored oracle inputs:
python diff_test.py --case ./case_02867_seed42954792
Observed results
- case_02867_seed42954792:
overall max_abs=4.883e-04,max_rel=6.431e-04; only one output tensor shows a small but reproducible mismatch, others match.
Expected
fuse_consecutive_squeezes should be semantics-preserving. Applying this pass alone should not change any output values. Please investigate why the optimized graph produces different outputs and whether the pass is incorrectly changing squeeze/unsqueeze ordering or shapes.
Differential Test Output Details
- case_02867_seed42954792
Case: case_02867_seed42954792
output[0]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 26)
output[1]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(4, 1)
output[2]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(4, 1)
output[3]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(4, 4)
output[4]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(34,)
output[5]: max_abs=4.883e-04, max_rel=6.431e-04, shape=(4,)
output[6]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(2, 1, 4)
output[7]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(4, 34)
output[8]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(34,)
output[9]: max_abs=0.000e+00, max_rel=0.000e+00, shape=()
output[10]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(34,)
output[11]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 2, 17)
output[12]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 2, 2)
output[13]: max_abs=0.000e+00, max_rel=0.000e+00, shape=(1, 1, 1, 3)
Overall: max_abs=4.883e-04, max_rel=6.431e-04
**Attachments**
- `README.md` (this document)
- `requirements.txt` (dependency versions)
- `optimize_model.py` (runs only `fuse_consecutive_squeezes` and saves `model.opt.onnx`)
- `diff_test.py` (runs original vs optimized with oracle inputs and reports max_abs/max_rel)
- `case_02867_seed42954792/` (contains `model.onnx` original model, `oracle.pkl` input data for both original and optimized models)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running optimize_model.py for case_02867_seed42954792, then use diff_test.py with model.onnx and oracle.pkl to reproduce the mismatch from fuse_consecutive_squeezes alone. Trace the pass implementation and its squeeze/unsqueeze transformations, using the reported output[5] difference as the check. Done means the optimized model matches the original outputs for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100