-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support non-zero shard to replicated
- Loading branch information
Showing
17 changed files
with
215 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
paddle/phi/core/distributed/auto_parallel/reshard_concat_functor.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "paddle/phi/core/distributed/auto_parallel/reshard_concat_functor.h" | ||
|
||
#include "paddle/phi/backends/all_context.h" | ||
#include "paddle/phi/core/dense_tensor.h" | ||
#include "paddle/phi/core/device_context.h" | ||
#include "paddle/phi/core/visit_type.h" | ||
#include "paddle/phi/kernels/concat_kernel.h" | ||
|
||
namespace phi { | ||
namespace distributed { | ||
|
||
DenseTensor ReshardConcatFunctor(const DeviceContext& dev_ctx, | ||
const std::vector<const DenseTensor*>& input, | ||
int64_t axis) { | ||
DenseTensor result; | ||
auto dtype = (*input.begin())->dtype(); | ||
|
||
if (phi::CPUContext::classof(&dev_ctx)) { | ||
PD_VISIT_ALL_TYPES( | ||
dtype, "Concat", ([&] { | ||
Concat<data_t>( | ||
static_cast<const CPUContext&>(dev_ctx), input, axis, &result); | ||
})); | ||
return result; | ||
} | ||
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) | ||
if (phi::GPUContext::classof(&dev_ctx)) { | ||
PD_VISIT_ALL_TYPES( | ||
dtype, "Concat", ([&] { | ||
Concat<data_t>( | ||
static_cast<const GPUContext&>(dev_ctx), input, axis, &result); | ||
})); | ||
return result; | ||
} | ||
#endif | ||
PADDLE_THROW(phi::errors::Unimplemented( | ||
"The concat in reshard only supported on CPU and GPU for now.")); | ||
} | ||
|
||
} // namespace distributed | ||
} // namespace phi |
30 changes: 30 additions & 0 deletions
30
paddle/phi/core/distributed/auto_parallel/reshard_concat_functor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
namespace phi { | ||
class DeviceContext; | ||
class DenseTensor; | ||
namespace distributed { | ||
|
||
DenseTensor ReshardConcatFunctor(const DeviceContext& dev_ctx, | ||
const std::vector<const DenseTensor*>& input, | ||
int64_t axis); | ||
|
||
} // namespace distributed | ||
} // namespace phi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.