Skip to content

[Build] ONNX Optimizer: The pass "lift_lexical_references" pass fails and produces invalid model #26870

@C1ri007

Description

@C1ri007

Describe the issue

lift_lexical_references pass fails and produces invalid model — unresolved value references and missing tensor elem_type

Describe the bug
Hi ONNX Runtime maintainers, thanks for the project!

When optimizing a valid ONNX model named model.onnx using only the lift_lexical_references pass, the pass crashes with unresolved value references and the optimized model becomes invalid.

Environment

OS: Ubuntu 20.04 LTS
Python: 3.10.18
onnx: 1.19.0
onnxruntime: 1.23.2
onnxoptimizer: 0.3.19 (latest)

Attachments:
left_lexical_references_repro.tar.gz

  • README.md (Details to reproduce this bug)
  • requirements.txt (dependency versions)
  • optimize_model.py (runs lift_lexical_references and saves model.opt.onnx ,althrough the pass lift_lexical_references FAILED to generate an optimized model)
  • the minimal failing folder ./case_00057_seed20702402 containing model.onnx, oracle.pkl (input data of onnx model).

Thanks for your help!

Urgency

This issue is urgent for me because I’m running differential testing on the ONNX Optimizer, and the failing lift_lexical_references pass blocks my workflow.
And I’m eager to help and contribute fixes back to the community. Please let me know how I can assist with debugging or validating a patch. Thank you!

Target platform

Linux

Build script

To Reproduce
left_lexical_references_repro.tar.gz

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

tar -xzvf lift_lexical_references_repro.tar.gz
cd lift_lexical_references_repro
  1. 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
  1. Run the lift_lexical_references pass on the case model and save
python optimize_model.py --case ./case_00057_seed20702402

Expected: model.opt.onnx is written.
Actual: the pass fails with unresolved value references and no model.opt.onnx is produced.

Error / output

Expected behavior

  • There should be an optimized model which is named as model.opt.onnx and should remain a valid ONNX model after lift_lexical_references optimization.
  • ONNX Runtime should be able to create an InferenceSession for model.opt.onnx.

Actual behavior

Optimizer fails with:

RuntimeError: Unresolved value references: m3.bias,m3.weight,m5.bias,m5.weight,m6.bias,m6.running_mean,m6.running_var,m6.weight,m8.bias,m8.running_mean,m8.running_var,m8.weight,v17_0,v24_0,

Visual Studio Version

No response

GCC / Compiler Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildbuild issues; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions