Fix MAXIMUM_PROTOBUF
size (2GiB, not 2GB)
#6556
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
While saving a model that was just barely under the 2GiB limit (using Optimum), I noticed that it was saved with the external data format, even though it should be able to be saved in a single file.
After further investigation, it was related to these lines, where the value of
.
onnx.MAXIMUM_PROTOBUF
is used to determine whether to use the external data format. This value is hardcoded to 2GB (=2*10^9
bytes), even though it should be 2GiB (=2*1024^3
), according to the protobuf documentation:Unless there is a specific onnx specification which limits this to 2GB (and not 2GiB), this PR may potentially fix a problem which has existed for a long time.
Motivation and Context
Allows certain models to be saved as a single
.onnx
file without the external data format, which were previously saved separately due to this misconfiguration.