Closed shamith2 closed 1 day ago
@kunal-vaishnavi, could you take a look at symbolic shape inference works on phi-3 models.
The uploaded Phi-3 ONNX models already have been symbolic shape inferenced with dynamic axes.
The symbolic shape inference for most quantization operators is defined in each operator's spec.
Here is the list of supported operators whose shapes can be symbolically inferred in the SymbolicShapeInference.infer_shapes
tool.
@kunal-vaishnavi, thanks for the response. I have a few questions and comments from my side:
From my understanding, this is how Netron visualizes shape inferenced operators after running the model through the SymbolicShapeInference.infer_shapes
tool, which I was not able to do for the phi-3 model (this subgraph is from a different onnx model):
I do not see MatMulNBits
operator in the list of supported operators you shared for the SymbolicShapeInference.infer_shapes
tool, which might be a reason why SymbolicShapeInference.infer_shapes
tool is giving out the error
Were you able to successfully shape infer the phi-3 model for all operators? I am not able to do it with release version of onnxruntime 1.18.0. Which version of onnxruntime are you using?
The attached Phi-3 ONNX model is not shape inferred for all the operators. Couple of operators might have symbolic shape inferenced with dynamic axes. The vast majority of the operators are not shape inferenced. For example, here is one of the subgraphs of the model that is not shape inferenced, visualized in Netron. From my understanding, this is how Netron visualizes shape inferenced operators after running the model through the
SymbolicShapeInference.infer_shapes
tool, which I was not able to do for the phi-3 model (this subgraph is from a different onnx model).
You can find the shape inference by clicking on the operator and pressing the '+' icon next to the right of each input name and output name. Here is an example.
I do not see MatMulNBits operator in the list of supported operators you shared for the SymbolicShapeInference.infer_shapes tool, which might be a reason why SymbolicShapeInference.infer_shapes tool is giving out the error
Yes, your error occurs because symbolic shape inference for MatMulNBits
isn't implemented in SymbolicShapeInference.infer_shapes
. We can add MatMulNBits
to fix this.
Were you able to successfully shape infer the phi-3 model for all operators? I am not able to do it with release version of onnxruntime 1.18.0. Which version of onnxruntime are you using?
The uploaded Phi-3 ONNX models are created via ONNX Runtime GenAI's model builder. The shape inferences for their operators are created here in the model builder using onnx.helper.make_tensor_value_info
and added to the ModelProto
here.
Describe the issue
I am running into this error when I run
SymbolicShapeInference.infer_shapes()
function on Phi 3 mini onnx model optimized for CPU. From my understanding, looks likeinfer_shapes()
is not able to infer shape forMatMulNBits
op (https://github.com/microsoft/onnxruntime/blob/rel-1.18.0/docs/ContribOperators.md#com.microsoft.MatMulNBits)This issue might not be limited to Phi-3. I suspect this has to do with the operator domain. Does the
infer_shapes()
automatically work on operators fromcom.microsoft
domain?I made the input and output dims of the onnx model static before performing shape inference using
update_inputs_outputs_dims()
from https://github.com/onnx/onnx/blob/main/onnx/tools/update_model_dims.pyError:
To reproduce
Download Model:
Packages:
Code:
Urgency
No response
Platform
Windows
OS Version
11
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.18.0
ONNX Runtime API
Python
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response