Skip to content

Upgrade protobuf to 4.21.x #49168

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

Merged
merged 47 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9c5433f
upgrade protobuf to 3.19.0 in cmake
pangyoki Jul 31, 2022
46fee37
recover protobuf python version
pangyoki Aug 2, 2022
2eaa5ba
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
pangyoki Sep 5, 2022
8936be4
fix distribute compile
pangyoki Sep 5, 2022
57d3d28
fix
pangyoki Sep 5, 2022
166a8e6
fix framework.data_feed_pb2
pangyoki Sep 26, 2022
6e6781f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
pangyoki Sep 26, 2022
e9559c5
fix macos ifdef
pangyoki Sep 26, 2022
dac9d9c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
pangyoki Oct 19, 2022
4ab81ef
fix lite
pangyoki Oct 19, 2022
3c917bc
debug
risemeup1 Jan 3, 2023
6472685
test
risemeup1 Jan 5, 2023
9af85b4
update protoc from 3.19.0 t0 3.20.0
risemeup1 Jan 5, 2023
45ddb5f
test
risemeup1 Jan 6, 2023
2b321f9
debug
risemeup1 Jan 6, 2023
290d621
test
risemeup1 Jan 6, 2023
0d8b4ad
test
risemeup1 Jan 6, 2023
36e3be8
debug
risemeup1 Jan 6, 2023
9540763
debug
risemeup1 Jan 8, 2023
461a5f7
debug
risemeup1 Jan 8, 2023
d6ac6ab
debug
risemeup1 Jan 11, 2023
53d586b
test
risemeup1 Jan 16, 2023
8df27c9
test
risemeup1 Jan 16, 2023
f5bfedb
debug
risemeup1 Jan 16, 2023
62afefc
update protocol from 3.20.0 to 4.21.12
risemeup1 Jan 17, 2023
1f917b3
modify graph_brpc_client.h
risemeup1 Jan 17, 2023
a3419f9
modify graph_brpc_client.h
risemeup1 Jan 17, 2023
ee84d4b
test
risemeup1 Jan 31, 2023
8754fa9
test
risemeup1 Jan 31, 2023
ad98b03
test
risemeup1 Jan 31, 2023
6f33c4c
fix third_party cache problem on build ci
risemeup1 Feb 1, 2023
4fd60cb
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
risemeup1 Feb 1, 2023
51beac2
fix build_ci_problem
risemeup1 Feb 6, 2023
5ac619f
updata proto
risemeup1 Feb 6, 2023
d752353
test
risemeup1 Feb 7, 2023
8e2cd11
test
risemeup1 Feb 7, 2023
d68be19
test
risemeup1 Feb 7, 2023
5d3a118
test
risemeup1 Feb 7, 2023
37d44ac
test
risemeup1 Feb 7, 2023
660622f
test
risemeup1 Feb 7, 2023
09c0b39
test
risemeup1 Feb 8, 2023
096fd88
fix coverage failed test
risemeup1 Feb 9, 2023
1dc7d2e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
risemeup1 Feb 9, 2023
59bbe6c
try to fix test_exe_fleet_model_run
risemeup1 Feb 9, 2023
3375564
fix cinn bug
risemeup1 Feb 9, 2023
dfaf0aa
fix windows compile problem
risemeup1 Feb 10, 2023
76c16d8
fix python/requirements
risemeup1 Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions cmake/external/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ if(NOT WITH_CINN)
endif()

if(NOT CINN_GIT_TAG)
# 2023.01.28 commit
set(CINN_GIT_TAG 1449890f7724babf2a343c6f8073bd28a7bbc683)
# 2023.01.12 commit
set(CINN_GIT_TAG 04cbe3ca3cd17a8267a229ce7ab8d8b8b63c7f4e)
endif()

message(STATUS "CINN version: " ${CINN_GIT_TAG})
Expand All @@ -40,10 +40,7 @@ set(CINN_OPTIONAL_ARGS
-DWITH_MKL_CBLAS=${WITH_MKL}
-DWITH_MKLDNN=${WITH_MKL}
-DPUBLISH_LIBS=ON
-DWITH_TESTING=ON
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
-DPYTHON_LIBRARIES=${PYTHON_LIBRARIES})
-DWITH_TESTING=ON)
set(CINN_BUILD_COMMAND ${CMAKE_COMMAND} --build . --target cinnapi -j)
set(CINN_BINARY_DIR ${CINN_PREFIX_DIR}/src/external_cinn-build)
set(CINN_LIB_NAME "libcinnapi.so")
Expand Down
12 changes: 10 additions & 2 deletions cmake/external/lite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
${LITE_PREFIX_DIR}/src/extern_lite/cmake/os/armlinux.cmake
UPDATE_COMMAND ""
BUILD_COMMAND ${LITE_BUILD_COMMAND}
INSTALL_COMMAND ""
INSTALL_COMMAND
cp ${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.cc
${LITE_PREFIX_DIR}/src/extern_lite-build/lite/core/ && cp
${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h
${LITE_PREFIX_DIR}/src/extern_lite-build/lite/core/
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS}
Expand Down Expand Up @@ -169,7 +173,11 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
"s?NNadapter_bridges_path = os.path.abspath('..')+\"\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?NNadapter_bridges_path = os.path.abspath(\'..\')+\"\/extern_lite\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?"
${LITE_PREFIX_DIR}/src/extern_lite//lite/tools/cmake_tools/record_supported_kernel_op.py
BUILD_COMMAND ${LITE_BUILD_COMMAND}
INSTALL_COMMAND ""
INSTALL_COMMAND
cp ${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.cc
${LITE_PREFIX_DIR}/src/extern_lite-build/lite/core/ && cp
${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h
${LITE_PREFIX_DIR}/src/extern_lite-build/lite/core/
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS}
Expand Down
26 changes: 13 additions & 13 deletions cmake/external/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function(protobuf_generate_python SRCS)
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --python_out
${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --python_out ${PADDLE_BINARY_DIR}
-I${PADDLE_SOURCE_DIR} ${ABS_FIL}
DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
COMMENT "Running Python protocol buffer compiler on ${FIL}"
VERBATIM)
Expand Down Expand Up @@ -236,24 +236,24 @@ function(build_protobuf TARGET_NAME BUILD_FOR_HOST)

if(WITH_ASCEND AND NOT WITH_ASCEND_CXX11)
set(PROTOBUF_REPOSITORY https://gitee.com/tianjianhe/protobuf.git)
set(PROTOBUF_TAG v3.8.0)
set(PROTOBUF_TAG v21.12)
elseif(WITH_ASCEND_CL AND NOT WITH_ASCEND_CXX11)
set(PROTOBUF_REPOSITORY https://gitee.com/tianjianhe/protobuf.git)
set(PROTOBUF_TAG v3.8.0)
set(PROTOBUF_TAG v21.12)
elseif(WITH_IPU)
set(PROTOBUF_REPOSITORY ${GIT_URL}/protocolbuffers/protobuf.git)
set(PROTOBUF_TAG d750fbf648256c7c631f51ffdbf67d7c18b0114e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASCEND和IPU这些新硬件设备应该不用改tag吧?不过新硬件设备上编译时可能没有走这些分支。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该不用

set(PROTOBUF_TAG v21.12)
elseif(WIN32)
set(PROTOBUF_REPOSITORY ${GIT_URL}/protocolbuffers/protobuf.git)
# Change the tag to support building with vs2019
set(PROTOBUF_TAG 01a05a53f40ca2ac5f0af10c6cc0810bee39b792)
set(PROTOBUF_TAG v21.12)
else()
set(PROTOBUF_REPOSITORY ${GIT_URL}/protocolbuffers/protobuf.git)
set(PROTOBUF_TAG 9f75c5aa851cd877fb0d93ccc31b8567a6706546)
set(PROTOBUF_TAG v21.12)
if(WITH_GPU)
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 12.0)
set(PROTOBUF_TAG 2dc747c574b68a808ea4699d26942c8132fe2b09)
set(PROTOBUF_TAG v21.12)
endif()
endif()
endif()
Expand Down Expand Up @@ -321,17 +321,17 @@ function(build_protobuf TARGET_NAME BUILD_FOR_HOST)
endfunction()

if(WITH_ASCEND OR WITH_ASCEND_CL)
set(PROTOBUF_VERSION 3.8.0)
set(PROTOBUF_VERSION 21.12)
elseif(WITH_IPU)
set(PROTOBUF_VERSION 3.6.1)
set(PROTOBUF_VERSION 21.12)
elseif(WITH_ARM_BRPC)
set(PROTOBUF_VERSION 3.7.1-baidu-ee-common)
set(PROTOBUF_VERSION 21.12-baidu-ee-common)
else()
set(PROTOBUF_VERSION 3.1.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不重要,这里windows上的PROTOBUF_VERSION不是21.12?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,还是之前的低版本protobuf_version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否需要为windows加一个PROTOBUF_VERSION的判断逻辑?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,我下一个PR加一下,这样更好

set(PROTOBUF_VERSION 21.12)
if(WITH_GPU)
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 12.0)
set(PROTOBUF_VERSION 3.16.0)
set(PROTOBUF_VERSION 21.12)
endif()
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,8 @@ function(paddle_protobuf_generate_cpp SRCS HDRS)
add_custom_command(
OUTPUT "${_protobuf_protoc_src}" "${_protobuf_protoc_hdr}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} -I${CMAKE_CURRENT_SOURCE_DIR}
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}" ${ABS_FIL}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} -I${PADDLE_SOURCE_DIR} --cpp_out
"${PADDLE_BINARY_DIR}" ${ABS_FIL}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoc编译的时候,推荐使用根目录,然后以绝对路径import文件

# Set `EXTERN_PROTOBUF_DEPEND` only if need to compile `protoc.exe`.
DEPENDS ${ABS_FIL} ${EXTERN_PROTOBUF_DEPEND}
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/distributed/fleet_executor/dist_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,15 @@ bool DistModel::PrepareFleetExe() {
executor_desc_ = FleetExecutorDesc();
executor_desc_.set_cur_rank(config_.local_rank);
std::unordered_map<int64_t, int64_t> id_to_rank;

for (int i = 0; i < config_.nranks; ++i) {
RankInfo *rank_info = executor_desc_.add_cluster_info();
rank_info->set_rank(i);
if (config_.nranks == 1) {
rank_info->set_ip_port("");
} else {
rank_info->set_ip_port(config_.trainer_endpoints[i]);
}
rank_info->set_ip_port(config_.trainer_endpoints[i]);
id_to_rank.insert({i, i});
}
Expand Down
4 changes: 3 additions & 1 deletion paddle/fluid/distributed/ps/service/graph_brpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ class GraphPsService_Stub : public PsService_Stub {
}
virtual ~GraphPsService_Stub() {}

GraphPsService_Stub(const GraphPsService_Stub&);
GraphPsService_Stub& operator=(const GraphPsService_Stub&);

// implements PsService ------------------------------------------
GraphBrpcService* graph_service;
std::shared_ptr<::ThreadPool> task_pool;
::google::protobuf::RpcChannel* local_channel;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GraphPsService_Stub);
void service(::google::protobuf::RpcController* controller,
const ::paddle::distributed::PsRequestMessage* request,
::paddle::distributed::PsResponseMessage* response,
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/ir/is_test_pass_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <gtest/gtest.h>

#include "paddle/fluid/framework/ir/is_test_pass.h"
#ifdef _WIN32
#if defined _WIN32 || defined __APPLE__
#undef FALSE
#undef TRUE
#endif
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/op_def.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ limitations under the License. */

syntax = "proto2";

import "framework.proto";
import "paddle/fluid/framework/framework.proto";
package paddle.framework.proto;

message OpDef {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/pass_desc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ limitations under the License. */

syntax = "proto2";

import "framework.proto";
import "paddle/fluid/framework/framework.proto";
package paddle.framework.proto;

// Describes one subsitute subgraph.
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/trainer_desc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ limitations under the License. */

syntax = "proto2";
option optimize_for = LITE_RUNTIME;
import "data_feed.proto";
import "framework.proto";
import "paddle/fluid/framework/data_feed.proto";
import "paddle/fluid/framework/framework.proto";
package paddle.framework;

message TrainerDesc {
Expand Down
10 changes: 4 additions & 6 deletions paddle/fluid/operators/graph_khop_sampler_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ inline __device__ bool AttemptInsert(
static_cast<unsigned int>(-1),
static_cast<unsigned int>(id));
if (key == -1 || key == id) {
atomicMin(
reinterpret_cast<unsigned long long int*>(&key_index[pos]), // NOLINT
static_cast<unsigned long long int>(index)); // NOLINT
atomicMin(reinterpret_cast<unsigned int*>(&key_index[pos]), // NOLINT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need to change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多谢review,这个之前实验的时候改的数据类型,忘了改回来,下个PR把这个改回来。

static_cast<unsigned int>(index)); // NOLINT
return true;
} else {
return false;
Expand All @@ -43,9 +42,8 @@ inline __device__ bool AttemptInsert(
static_cast<unsigned long long int>(-1), // NOLINT
static_cast<unsigned long long int>(id)); // NOLINT
if (key == -1 || key == id) {
atomicMin(
reinterpret_cast<unsigned long long int*>(&key_index[pos]), // NOLINT
static_cast<unsigned long long int>(index)); // NOLINT
atomicMin(reinterpret_cast<unsigned int*>(&key_index[pos]), // NOLINT
static_cast<unsigned int>(index)); // NOLINT
return true;
} else {
return false;
Expand Down
2 changes: 1 addition & 1 deletion paddle/infrt/paddle/framework.proto
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ message ProgramDesc {
repeated BlockDesc blocks = 1;
optional Version version = 4;
optional OpCompatibleMap op_compatible_map = 3;
}
}
1 change: 0 additions & 1 deletion paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,6 @@ function build_pr_and_develop() {
mkdir ${PADDLE_ROOT}/build/pr_whl && cp ${PADDLE_ROOT}/build/python/dist/*.whl ${PADDLE_ROOT}/build/pr_whl
rm -f ${PADDLE_ROOT}/build/python/dist/*.whl && rm -f ${PADDLE_ROOT}/build/python/build/.timestamp


git fetch upstream develop
git checkout develop
dev_commit=`git log -1|head -1|awk '{print $2}'`
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import multiprocessing
import sys
import logging
from .proto import framework_pb2

from .proto import framework_pb2, data_feed_pb2


from . import core
from . import unique_name
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requests>=2.20.0
numpy>=1.13
protobuf>=3.1.0, <=3.20.2
protobuf>=3.1.0
Pillow
decorator
astor
Expand Down