Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model saved with offline basic optimizations will not load - ShapeInferenceError #21325

Open
ivberg opened this issue Jul 11, 2024 · 1 comment
Assignees
Labels
platform:windows issues related to the Windows platform

Comments

@ivberg
Copy link
Contributor

ivberg commented Jul 11, 2024

Describe the issue

We were attempting to use offline optimization to optimize a model, save it, then load it using later with optimizations disabled.
https://onnxruntime.ai/docs/performance/model-optimizations/graph-optimizations.html#onlineoffline-mode

However, the resulting model with basic optimizations results in an error and will not load with ShapeInferenceError

To reproduce

  1. We used Phi Silicia SLM model
  2. Save the model offline with basic optimizations - https://onnxruntime.ai/docs/performance/model-optimizations/graph-optimizations.html#basic-graph-optimizations
  3. In this case we wanted extended data support saved offline so here was the APIs used
    session_options.SetGraphOptimizationLevel(ORT_ENABLE_BASIC); 
    const ORTCHAR_T* optimized_model_path = ORT_TSTR("model.extdata.basic_opt.onnx");
    session_options.SetOptimizedModelFilePath(optimized_model_path);
    session_options.AddConfigEntry(kOrtSessionOptionsOptimizedModelExternalInitializersFileName, "model.extdata.basic_opt.onnx.data");
    session_options.AddConfigEntry(kOrtSessionOptionsOptimizedModelExternalInitializersMinSizeInBytes, "10");
  1. In another code after getting the saved offline model load it
    session_options.SetGraphOptimizationLevel(ORT_DISABLE_ALL);
    session = Ort::Session(env, filemodelpath, session_options);
  1. The program will exit or at least I didn't see an error
  2. If you enable logging you will see errors like this "Node (/model/attn_mask_reformat/input_ids_subgraph/Reshape) Op (Reshape) [ShapeInferenceError] Cannot parse data from external tensors. Please load external data into raw data for tensor: /model/attn_mask_reformat/input_ids_subgraph/Concat_3/output_0"

Urgency

This does block performance investigations, experiments, and workarounds to attempt to work around other ONNX bugs.

Platform

Windows

OS Version

11

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.18.1

ONNX Runtime API

C++

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@github-actions github-actions bot added the platform:windows issues related to the Windows platform label Jul 11, 2024
@yufenglee
Copy link
Member

Looks like a model serialization issue with external data file. @pranavsharma, could you please help take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows issues related to the Windows platform
Projects
None yet
Development

No branches or pull requests

3 participants