onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

Fix ordering of value info in GraphProto creation

Open sspintel opened this issue 1 year ago • 10 comments
trafficstars

Description

Graph member value_info_ (unordered_set) is ordered before its values are added to the graph proto.

Motivation and Context

  • Without this ordering, the model proto used by the OpenVINO EP is not deterministic and varies across runs.
  • Since the model proto varies, it affects caching attempts by OpenVINO.

Q: If creating a vector to have ordered elements is costly, should we make value_info_ a std::set that is sorted according to NodeArg names?

Related PR about ordering initializers: https://github.com/microsoft/onnxruntime/pull/14631

sspintel avatar May 16 '24 05:05 sspintel

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, Linux QNN CI Pipeline

adrianlizarraga avatar May 21 '24 17:05 adrianlizarraga

Azure Pipelines successfully started running 9 pipeline(s).

azure-pipelines[bot] avatar May 21 '24 17:05 azure-pipelines[bot]

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows ARM64 QNN CI Pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, Windows x64 QNN CI Pipeline, Linux MIGraphX CI Pipeline, Big Models

adrianlizarraga avatar May 21 '24 17:05 adrianlizarraga

Azure Pipelines successfully started running 10 pipeline(s).

azure-pipelines[bot] avatar May 21 '24 17:05 azure-pipelines[bot]

/azp run ONNX Runtime React Native CI Pipeline, orttraining-amd-gpu-ci-pipeline

adrianlizarraga avatar May 21 '24 17:05 adrianlizarraga

Azure Pipelines successfully started running 2 pipeline(s).

azure-pipelines[bot] avatar May 21 '24 17:05 azure-pipelines[bot]

/azp run Linux Android Emulator QNN CI Pipeline

adrianlizarraga avatar May 21 '24 17:05 adrianlizarraga

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 21 '24 17:05 azure-pipelines[bot]

@skottmckay this is a similar issue as an issue discussed previously at https://github.com/microsoft/onnxruntime/pull/14631#discussion_r1101731248 any objections to this?

jywu-msft avatar May 22 '24 00:05 jywu-msft

@skottmckay this is a similar issue as an issue discussed previously at #14631 (comment) any objections to this?

I think it should be fine. Typical inferencing usage doesn't involve calling ToGraphProto so it will have limited effect elsewhere, so maybe not worth adding a param to ToGraphProto to control whether they are sorted or not

Please add comments to the code explaining why it is necessary to sort the values. Without context it seems like an unnecessary thing to do, and if I saw that my first temptation would be to delete it if the reason was not captured in a comment.

skottmckay avatar May 22 '24 00:05 skottmckay

Please add comments to the code explaining why it is necessary to sort the values. Without context it seems like an unnecessary thing to do, and if I saw that my first temptation would be to delete it if the reason was not captured in a comment.

@skottmckay Added comment that clarifies why this sorting is necessary

sspintel avatar May 22 '24 11:05 sspintel

/azp run Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed

adrianlizarraga avatar May 22 '24 16:05 adrianlizarraga

Azure Pipelines successfully started running 9 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 16:05 azure-pipelines[bot]

/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline

adrianlizarraga avatar May 22 '24 16:05 adrianlizarraga

Azure Pipelines successfully started running 9 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 16:05 azure-pipelines[bot]

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, Linux QNN CI Pipeline

adrianlizarraga avatar May 22 '24 16:05 adrianlizarraga

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows ARM64 QNN CI Pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, Windows x64 QNN CI Pipeline, Linux MIGraphX CI Pipeline, Big Models

adrianlizarraga avatar May 22 '24 16:05 adrianlizarraga

Azure Pipelines successfully started running 9 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 16:05 azure-pipelines[bot]

/azp run ONNX Runtime React Native CI Pipeline, orttraining-amd-gpu-ci-pipeline, Linux Android Emulator QNN CI Pipeline

adrianlizarraga avatar May 22 '24 16:05 adrianlizarraga

Azure Pipelines successfully started running 10 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 16:05 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 16:05 azure-pipelines[bot]

/azp run Big Models

adrianlizarraga avatar May 22 '24 18:05 adrianlizarraga

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 18:05 azure-pipelines[bot]

/azp run ONNX Runtime React Native CI Pipeline

adrianlizarraga avatar May 22 '24 19:05 adrianlizarraga

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 22 '24 19:05 azure-pipelines[bot]