-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[WIP] Upgrade Protobuf to v21.1 to accept Python Protobuf 4.21 #4242
Conversation
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: jcwchen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
mkdir build_source && cd build_source | ||
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PROTOBUF_PATH -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release | ||
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PROTOBUF_PATH -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider Python apps sharing messages with C++ using a native extension (see https://developers.google.com/protocol-buffers/docs/reference/python-generated#sharing-messages and #4274 (comment))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Xavier for the reminder! Yes it seems that the option PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
should be added.
Just try to understand more context: so current ONNX does not rely on this option with Protobuf 4.21.0+ (Sharing Messages Between Python and C++), but it would be useful for your PR #4274?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, every C++ function exposes with pybind11 receives an onnx graph as a serialized buffer and not the graph itself. (like check_model, shape_inference). I think this serialization / deserialization) has a significant cost and should be avoided. With the current version, removing any serialization in check_model would make it 2 or 3 times faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation of protobuf is not really clear about that mechanism. I wonder if this flag should be used when building protobuf for python as well as the version linked with onnx. Default version of protobuf is:
>>> import google.protobuf.internal.api_implementation as api
>>> api.Type()
'upb'
So even if PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
for onnx, it does not change the fact the python version is still using another one. Python sharing messages with C++ won't work.
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@@ -1,3 +1,3 @@ | |||
numpy >= 1.16.6 # TODO: update once TensorFlow 2.6 is end of life | |||
protobuf >= 3.12.2, <= 3.20.1 | |||
protobuf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf>=3.12.2 ?
) | ||
|
||
echo "Build protobuf from source on Windows." | ||
Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/protobuf-cpp-3.16.0.tar.gz -OutFile protobuf.tar.gz -Verbose | ||
Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/releases/download/v21.1/protobuf-cpp-3.21.1.tar.gz -OutFile protobuf.tar.gz -Verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/v21.1/
?
This is great! Out of curiosity, is there an ETA to mainline this change? Anything we can do to help expedite it? :) |
Good question. I hold on this PR because upstream frameworks like PyTorch and TensorFlow are still using Protobuf 3. It's safer to upgrade ONNX's Protobuf version after they have updated theirs. IIUC, TensorFlow will probably upgrade their Protobuf version in next quarter (reference), but I don't know when PyTorch will do so. Therefore at this moment I don't have concrete ETA that when ONNX will upgrade Protobuf, but ONNX will do so right after both PyTorch and TensorFlow have upgraded their Protobuf. |
Hi :) Is there any update on the timeline for this PR? As far as I have seen TF and Pytorch already closed your linked PRs. |
Although the linked PRs are closed, IIUC both PyTorch and TF are still using old Protobuf version. Recently ONNX has just upgraded its Protobuf to 3.20.2: #4629 for the upcoming ONNX 1.13 release. So this PR will be considered again for the next ONNX 1.14 release, which won't happen soon. |
To faster resolve merge conflict issue, I have another new PR to achieve this: #4956. Please comment there if anyone has concern or thought. I will close this one. Thanks! |
Description
Upgrade Protobuf to v21.1 to accept Python Protobuf 4.21
After upgrading to Protobuf 21. for building ONNX, ONNX with older Python Protobuf (<=3.20) will behave differently from ONNX with Python Protobuf (4.21): the output order for ONNX ModelProto will be different. To keep consistent behavior, the minimum supported Protobuf versiob would be 4.21 after this upgrade.
Motivation and Context
Closes #4239.