Skip to content

Commit 07f55f0

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into support_scalar_type
2 parents 2fad9d0 + 43622a2 commit 07f55f0

File tree

277 files changed

+6765
-6930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+6765
-6930
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ paddle/fluid/operators/ops_extra_info.cc
99
paddle/phi/api/backward/backward_api.h
1010
paddle/phi/api/backward/sparse_bw_api.h
1111
paddle/phi/api/include/api.h
12+
paddle/phi/api/include/operants_base.h
13+
paddle/phi/api/include/operants_manager.h
1214
paddle/phi/api/include/sparse_api.h
1315
paddle/phi/api/include/strings_api.h
16+
paddle/phi/api/include/tensor_operants.h
1417
paddle/phi/api/lib/api.cc
1518
paddle/phi/api/lib/dygraph_api.*
1619
paddle/phi/api/lib/backward_api.cc
20+
paddle/phi/api/lib/operants_manager.cc
1721
paddle/phi/api/lib/sparse_api.cc
1822
paddle/phi/api/lib/strings_api.cc
1923
paddle/phi/api/lib/sparse_bw_api.cc
24+
paddle/phi/api/lib/tensor_operants.cc
2025
paddle/phi/extension.h
2126
paddle/phi/include/*
2227
paddle/phi/infermeta/generated.*

cmake/external/cinn.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ if(NOT WITH_CINN)
1717
endif()
1818

1919
if(NOT CINN_GIT_TAG)
20-
# 2023.02.09 commit
21-
set(CINN_GIT_TAG 63cf4267a0f8756df61b0dca5fb30bf3748ba2f4)
20+
# 2023.02.16 commit
21+
set(CINN_GIT_TAG ec7f1a87b195b9586e69f9f30a2b647dcf8b9def)
2222
endif()
2323

2424
message(STATUS "CINN version: " ${CINN_GIT_TAG})

cmake/external/cutlass.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ ExternalProject_Add(
3434
PREFIX ${CUTLASS_PREFIX_DIR}
3535
UPDATE_COMMAND ""
3636
CONFIGURE_COMMAND ""
37-
BUILD_COMMAND ""
37+
BUILD_COMMAND
38+
mkdir -p
39+
${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/build/generated/gemm
40+
&& ${PYTHON_EXECUTABLE} -B
41+
${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/gather_gemm_scatter_generator.py
42+
"${THIRD_PARTY_PATH}/cutlass/src/extern_cutlass/tools/library/scripts/"
43+
"${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/build"
44+
"${CMAKE_CUDA_COMPILER_VERSION}"
3845
INSTALL_COMMAND ""
3946
TEST_COMMAND "")
4047

cmake/external/mkldnn.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(MKLDNN_INC_DIR
2121
"${MKLDNN_INSTALL_DIR}/include"
2222
CACHE PATH "mkldnn include directory." FORCE)
2323
set(MKLDNN_REPOSITORY ${GIT_URL}/oneapi-src/oneDNN.git)
24-
set(MKLDNN_TAG 9b186765dded79066e0cd9c17eb70b680b76fb8e)
24+
set(MKLDNN_TAG 2089770c4818be8933c5e9d1dd3cbaeba1457667)
2525

2626
# Introduce variables:
2727
# * CMAKE_INSTALL_LIBDIR

cmake/external/xpu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(XPU_PROJECT "extern_xpu")
77
set(XPU_API_LIB_NAME "libxpuapi.so")
88
set(XPU_RT_LIB_NAME "libxpurt.so")
99

10-
set(XPU_BASE_DATE "20230215")
10+
set(XPU_BASE_DATE "20230220")
1111
set(XPU_XCCL_BASE_VERSION "1.0.8")
1212

1313
if(NOT DEFINED XPU_BASE_URL)

cmake/inference_lib.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,8 @@ add_dependencies(fluid_lib_dist ${platform_lib_deps})
448448
copy(
449449
fluid_lib_dist
450450
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h
451-
${src_dir}/${module}/details/*.h
452451
${PADDLE_BINARY_DIR}/paddle/phi/api/profiler/*.pb.h
453-
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/dynload
454-
${dst_dir}/${module}/details ${dst_dir}/${module})
452+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/dynload ${dst_dir}/${module})
455453

456454
set(module "string")
457455
copy(

cmake/third_party.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ if(TARGET extern_protobuf)
301301
list(APPEND third_party_deps extern_protobuf)
302302
endif()
303303

304-
if(WITH_PYTHON)
304+
if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
305305
include(external/python) # find python and python_module
306306
include(external/pybind11) # download pybind11
307307
list(APPEND third_party_deps extern_pybind)

paddle/extension.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ limitations under the License. */
1616

1717
// All paddle apis in C++ frontend
1818
#include "paddle/phi/api/all.h"
19+
// Python bindings for the C++ frontend
20+
#ifndef PADDLE_ON_INFERENCE
21+
#include "paddle/utils/pybind.h"
22+
#endif

paddle/fluid/distributed/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(WITH_PYTHON)
77
file(MAKE_DIRECTORY
88
${PADDLE_BINARY_DIR}/python/paddle/distributed/fleet/proto)
99
set(PSLIB_PROTO_DSTPATH
10-
"${PADDLE_SOURCE_DIR}/python/paddle/fluid/incubate/fleet/parameter_server/pslib/"
10+
"${PADDLE_SOURCE_DIR}/python/paddle/incubate/fleet/parameter_server/pslib/"
1111
)
1212
if(NOT WIN32)
1313
add_custom_command(

paddle/fluid/eager/grad_node_info.cc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,68 @@ void GradNodeBase::SetGradOutMeta(
326326
}
327327
}
328328

329+
void GradNodeBase::SetGradOutMeta(
330+
const std::vector<const paddle::experimental::Tensor*>& fwd_in,
331+
size_t slot_rank) {
332+
size_t slot_size = fwd_in.size();
333+
PADDLE_ENFORCE_LE(
334+
slot_rank,
335+
(bwd_out_meta_.size() - 1),
336+
paddle::platform::errors::InvalidArgument(
337+
"Slot Rank should less equal than bwd_out_meta_ size, "
338+
"since bwd_out_meta_ is designed to hold as same num as "
339+
"backward outputs."));
340+
auto& metas = bwd_out_meta_.at(slot_rank);
341+
// Init stop gradient vector before use to avoid push back
342+
if (metas.size() < slot_size) {
343+
metas.resize(slot_size);
344+
}
345+
for (size_t i = 0; i < slot_size; i++) {
346+
const auto& fwd_in_tensor = (*fwd_in[i]);
347+
auto& meta = metas[i];
348+
auto* fwd_in_meta = egr::EagerUtils::nullable_autograd_meta(fwd_in_tensor);
349+
// Set Stop_gradient
350+
if (fwd_in_meta) {
351+
meta.SetStopGradient(fwd_in_meta->StopGradient());
352+
}
353+
// Set Adj Edges
354+
if (fwd_in_meta && !fwd_in_meta->StopGradient()) {
355+
auto node = fwd_in_meta->GetMutableGradNode();
356+
if (!node || !node.get()) {
357+
fwd_in_meta->SetGradNode(
358+
std::make_shared<egr::GradNodeAccumulation>(fwd_in_meta));
359+
}
360+
VLOG(3) << "Add Edges for slot: " << slot_rank << ", the Edge is from "
361+
<< this->name() << " (addr: " << this << ") "
362+
<< " to " << fwd_in_meta->GetMutableGradNode()->name()
363+
<< " (addr: " << fwd_in_meta->GetMutableGradNode().get() << ")";
364+
365+
meta.SetEdge(fwd_in_meta->GetMutableGradNode(),
366+
fwd_in_meta->OutRankInfo());
367+
}
368+
// Record TensorMeta
369+
if (fwd_in_tensor.impl() && fwd_in_tensor.impl().get()) {
370+
if (phi::DenseTensor::classof(fwd_in_tensor.impl().get())) {
371+
// Only Copy Meta
372+
phi::DenseTensor* dense_tensor =
373+
static_cast<phi::DenseTensor*>(fwd_in_tensor.impl().get());
374+
PADDLE_ENFORCE_NE(dense_tensor->dtype(),
375+
phi::DataType::UNDEFINED,
376+
paddle::platform::errors::Fatal(
377+
"Attempting to copy DenseTensorMeta "
378+
"with phi::DataType::UNDEFINED,"
379+
"which is illegal."));
380+
meta.SetTensorMeta(dense_tensor->meta());
381+
meta.SetPlace(fwd_in_tensor.place());
382+
}
383+
} else {
384+
VLOG(7)
385+
<< "Unable to initialize the DenseTensorMeta of GradSlotMeta with "
386+
"non-DenseTensor argument.";
387+
}
388+
}
389+
}
390+
329391
void GradNodeBase::SetDefaultGradInOutMeta() {
330392
PADDLE_ENFORCE((bwd_out_meta_.size() == 1) && (bwd_in_meta_.size() == 1),
331393
paddle::platform::errors::PreconditionNotMet(

paddle/fluid/eager/grad_node_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ class GradNodeBase {
223223

224224
void SetGradOutMeta(const std::vector<paddle::experimental::Tensor>& fwd_in,
225225
size_t slot_rank);
226+
void SetGradOutMeta(
227+
const std::vector<const paddle::experimental::Tensor*>& fwd_in,
228+
size_t slot_rank);
226229
void SetGradOutMeta(const paddle::experimental::Tensor& fwd_in,
227230
size_t slot_rank);
228231
/**

paddle/fluid/eager/to_static/run_program_op_func.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,31 @@ inline void run_program_ad_func(
9393
grad_node->SetStepScope(step_scope);
9494

9595
// Set Grad out rank as same as fwd input and set stop gradient to bwd
96-
grad_node->SetGradOutMeta(x, /*slot id*/ 0);
96+
// NOTE(@xiongkun): Not every tensor in x(list of tensor) is required
97+
// gradient. for example: x[1] is not used for output, the x[1] is ignored.
98+
99+
auto* forward_global_block = PADDLE_GET_CONST(
100+
paddle::framework::BlockDesc*, attrs.at("forward_global_block"));
101+
auto* backward_global_block = PADDLE_GET_CONST(
102+
paddle::framework::BlockDesc*, attrs.at("backward_global_block"));
103+
std::vector<const paddle::experimental::Tensor*> x_require_grad;
104+
for (size_t i = 0; i < x.size(); ++i) {
105+
auto& name = x[i].name();
106+
if (forward_global_block->HasVar(name) ||
107+
backward_global_block->HasVar(name)) {
108+
x_require_grad.push_back(&x[i]);
109+
}
110+
}
111+
112+
grad_node->SetGradOutMeta(x_require_grad, /*slot id*/ 0);
97113
grad_node->SetGradOutMeta(params, /*slot id*/ 1);
98114

99-
bool use_interpretorcore =
100-
PADDLE_GET_CONST(bool, attrs.at("use_interpretorcore"));
101115
VLOG(2) << "clear_no_grad_edges.";
102-
if (use_interpretorcore) {
103-
auto* forward_global_block = PADDLE_GET_CONST(
104-
paddle::framework::BlockDesc*, attrs.at("forward_global_block"));
105-
auto* backward_global_block = PADDLE_GET_CONST(
106-
paddle::framework::BlockDesc*, attrs.at("backward_global_block"));
107-
clear_no_grad_edges_with_partial_block(params,
108-
forward_global_block,
109-
backward_global_block,
110-
grad_node.get(),
111-
/*slot id*/ 1);
112-
113-
} else {
114-
auto* global_block = PADDLE_GET_CONST(paddle::framework::BlockDesc*,
115-
attrs.at("global_block"));
116-
clear_no_grad_edges(params, global_block, grad_node.get(), /*slot id*/ 1);
117-
}
116+
clear_no_grad_edges_with_partial_block(params,
117+
forward_global_block,
118+
backward_global_block,
119+
grad_node.get(),
120+
/*slot id*/ 1);
118121

119122
grad_node->SetGradInMeta(deref_out, 0);
120123

0 commit comments

Comments
 (0)