-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
model:transformerissues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.issues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.
Description
Describe the issue
When running inference on an ONNX model with ONNXRuntime, I observe inconsistent results between sessions, even when using the same input data. The inconsistency appears when optimizations are enabled (with certain optimization levels). When optimization is disabled (ORT_DISABLE_ALL), the results are consistent.
- Actual Behavior
AssertionError:
Not equal to tolerance rtol=0.001, atol=0.001
Mismatched elements: 16 / 61828 (0.0259%)
x: array([[[[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],...
y: array([[[[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],...
To reproduce
- Download the model
- Run the script:
import onnx
import onnxruntime as ort
import numpy as np
from onnxruntime.transformers import optimizer
model_path = "inconsis8.onnx"
sess_options = ort.SessionOptions()
sess_options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
this_provider_list = ort.get_available_providers()
original_session = ort.InferenceSession(model_path, sess_options, providers=this_provider_list)
input_data = {"v1_0": np.random.rand(41, 1, 1, 26).astype(np.float16)}
output_names = [output.name for output in original_session.get_outputs()]
original_result = original_session.run(output_names, input_data)
optimized_session = ort.InferenceSession(model_path, providers=this_provider_list)
optimized_result = optimized_session.run(output_names, input_data)
for r1, r2 in zip(original_result, optimized_result):
np.testing.assert_allclose(r1, r2, atol=1e-3, rtol=1e-3)Urgency
No response
Platform
Linux
OS Version
Ubuntu 20.04
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
ONNX Runtime API
Python
Architecture
X64
Execution Provider
CUDA
Execution Provider Library Version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
model:transformerissues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.issues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.