Skip to content

Commit 1d978a9

Browse files
committed
delete setup_ops_base.py
1 parent 8b8d109 commit 1d978a9

File tree

7 files changed

+37
-56
lines changed

7 files changed

+37
-56
lines changed

build.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ EGG_DIR="fastdeploy.egg-info"
3434

3535
# custom_ops directory config
3636
OPS_SRC_DIR="custom_ops"
37-
OPS_TMP_DIR_BASE="tmp_base"
3837
OPS_TMP_DIR="tmp"
3938

4039
# command line log config
@@ -71,25 +70,20 @@ function copy_ops(){
7170
PY_VERSION="py${PY_MAIN_VERSION}.${PY_SUB_VERSION}"
7271
SYSTEM_VERSION=`${python} -c "import platform; print(platform.system().lower())"`
7372
PROCESSOR_VERSION=`${python} -c "import platform; print(platform.processor())"`
74-
WHEEL_BASE_NAME="fastdeploy_base_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
7573
WHEEL_NAME="fastdeploy_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
7674
WHEEL_CPU_NAME="fastdeploy_cpu_ops-${OPS_VERSION}-${PY_VERSION}-${SYSTEM_VERSION}-${PROCESSOR_VERSION}.egg"
7775
is_rocm=`$python -c "import paddle; print(paddle.is_compiled_with_rocm())"`
7876
if [ "$is_rocm" = "True" ]; then
7977
DEVICE_TYPE="rocm"
80-
mkdir -p ../fastdeploy/model_executor/ops/base
81-
cp -r ./${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
8278
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gpu
83-
echo -e "BASE and ROCM ops have been copy to fastdeploy"
79+
echo -e "ROCM ops have been copy to fastdeploy"
8480
return
8581
fi
86-
mkdir -p ../fastdeploy/model_executor/ops/base
8782
is_cuda=`$python -c "import paddle; print(paddle.is_compiled_with_cuda())"`
8883
if [ "$is_cuda" = "True" ]; then
8984
DEVICE_TYPE="gpu"
90-
cp -r ./${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
9185
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/gpu
92-
echo -e "BASE and CUDA ops have been copy to fastdeploy"
86+
echo -e "CUDA ops have been copy to fastdeploy"
9387
return
9488
fi
9589

@@ -112,9 +106,8 @@ function copy_ops(){
112106
if_corex=`$python -c "import paddle; print(paddle.is_compiled_with_custom_device(\"iluvatar_gpu\"))"`
113107
if [ "$if_corex" = "True" ]; then
114108
DEVICE_TYPE="iluvatar-gpu"
115-
cp -r ./${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
116109
cp -r ./${OPS_TMP_DIR}/${WHEEL_NAME}/* ../fastdeploy/model_executor/ops/iluvatar
117-
echo -e "BASE and Iluvatar ops have been copy to fastdeploy"
110+
echo -e "Iluvatar ops have been copy to fastdeploy"
118111
return
119112
fi
120113

@@ -127,19 +120,15 @@ function copy_ops(){
127120
fi
128121

129122
DEVICE_TYPE="cpu"
130-
cp -r ./${OPS_TMP_DIR_BASE}/${WHEEL_BASE_NAME}/* ../fastdeploy/model_executor/ops/base
131123
cd ../../../../
132124
cp -r ${OPS_TMP_DIR}/${WHEEL_CPU_NAME}/* ../fastdeploy/model_executor/ops/cpu
133-
echo -e "BASE and CPU ops have been copy to fastdeploy"
125+
echo -e "CPU ops have been copy to fastdeploy"
134126
return
135127
}
136128

137129
function build_and_install_ops() {
138130
cd $OPS_SRC_DIR
139131
export no_proxy=bcebos.com,paddlepaddle.org.cn,${no_proxy}
140-
echo -e "${BLUE}[build]${NONE} build and install fastdeploy_base_ops..."
141-
${python} setup_ops_base.py install --install-lib ${OPS_TMP_DIR_BASE}
142-
find ${OPS_TMP_DIR_BASE} -type f -name "*.o" -exec rm -f {} \;
143132
echo -e "${BLUE}[build]${NONE} build and install fastdeploy_ops..."
144133
TMP_DIR_REAL_PATH=`readlink -f ${OPS_TMP_DIR}`
145134
is_xpu=`$python -c "import paddle; print(paddle.is_compiled_with_xpu())"`
@@ -213,7 +202,6 @@ function cleanup() {
213202
fi
214203

215204
rm -rf $OPS_SRC_DIR/$BUILD_DIR $OPS_SRC_DIR/$EGG_DIR
216-
rm -rf $OPS_SRC_DIR/$OPS_TMP_DIR_BASE
217205
rm -rf $OPS_SRC_DIR/$OPS_TMP_DIR
218206
}
219207

custom_ops/gpu_ops/cpp_extensions.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,12 @@ std::vector<paddle::Tensor> TopKRenorm(const paddle::Tensor &probs,
785785

786786
std::vector<paddle::Tensor> MinPSamplingFromProbs(const paddle::Tensor &probs,
787787
const paddle::Tensor &min_p);
788+
789+
void SaveOutMmsgStatic(const paddle::Tensor& x,
790+
const paddle::Tensor& not_need_stop,
791+
int64_t rank_id,
792+
bool save_each_rank);
793+
788794
PYBIND11_MODULE(fastdeploy_ops, m) {
789795

790796
m.def("get_expert_token_num", &GetExpertTokenNum, py::arg("topk_ids"),
@@ -1143,4 +1149,6 @@ PYBIND11_MODULE(fastdeploy_ops, m) {
11431149
m.def("top_k_renorm_probs", &TopKRenorm, "top_k_renorm_probs function");
11441150

11451151
m.def("min_p_sampling", &MinPSamplingFromProbs, "min_p_sampling function");
1152+
1153+
m.def("save_output", &SaveOutMmsgStatic, "save_output function");
11461154
}

custom_ops/gpu_ops/get_output_ep.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ void GetOutputEp(const paddle::Tensor& x,
109109
return;
110110
}
111111

112-
void GetOutputStatic(const paddle::Tensor& x, int64_t rank_id, bool wait_flag) {
112+
void GetOutputEPStatic(const paddle::Tensor& x, int64_t rank_id, bool wait_flag) {
113113
GetOutputEp(x, rank_id, wait_flag, 1);
114114
}
115115

116-
void GetOutputDynamic(const paddle::Tensor& x,
116+
void GetOutputEPDynamic(const paddle::Tensor& x,
117117
int64_t rank_id,
118118
bool wait_flag,
119119
int msg_queue_id) {
@@ -125,11 +125,11 @@ PD_BUILD_STATIC_OP(get_output_ep)
125125
.Attrs({"rank_id: int64_t", "wait_flag: bool"})
126126
.Outputs({"x_out"})
127127
.SetInplaceMap({{"x", "x_out"}})
128-
.SetKernelFn(PD_KERNEL(GetOutputStatic));
128+
.SetKernelFn(PD_KERNEL(GetOutputEPStatic));
129129

130130
PD_BUILD_STATIC_OP(get_output_ep_dynamic)
131131
.Inputs({"x"})
132132
.Attrs({"rank_id: int64_t", "wait_flag: bool", "msg_queue_id: int"})
133133
.Outputs({"x_out"})
134134
.SetInplaceMap({{"x", "x_out"}})
135-
.SetKernelFn(PD_KERNEL(GetOutputDynamic));
135+
.SetKernelFn(PD_KERNEL(GetOutputEPDynamic));

custom_ops/setup_ops.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ def find_end_files(directory, end_str):
199199
if not os.listdir(json_dir):
200200
raise ValueError("Git clone nlohmann_json failed!")
201201
sources = [
202+
"gpu_ops/save_with_output_msg.cc",
203+
"gpu_ops/get_output.cc",
204+
"gpu_ops/get_output_msg_with_topk.cc",
205+
"gpu_ops/save_output_msg_with_topk.cc",
206+
"gpu_ops/transfer_output.cc",
202207
"gpu_ops/set_value_by_flags.cu",
203208
"gpu_ops/token_penalty_multi_scores.cu",
204209
"gpu_ops/stop_generation.cu",
@@ -250,6 +255,11 @@ def find_end_files(directory, end_str):
250255
)
251256
elif paddle.is_compiled_with_cuda():
252257
sources = [
258+
"gpu_ops/save_with_output_msg.cc",
259+
"gpu_ops/get_output.cc",
260+
"gpu_ops/get_output_msg_with_topk.cc",
261+
"gpu_ops/save_output_msg_with_topk.cc",
262+
"gpu_ops/transfer_output.cc",
253263
"gpu_ops/set_mask_value.cu",
254264
"gpu_ops/set_value_by_flags.cu",
255265
"gpu_ops/ngram_mask.cu",
@@ -532,6 +542,11 @@ def find_end_files(directory, end_str):
532542
]
533543
},
534544
sources=[
545+
"gpu_ops/save_with_output_msg.cc",
546+
"gpu_ops/get_output.cc",
547+
"gpu_ops/get_output_msg_with_topk.cc",
548+
"gpu_ops/save_output_msg_with_topk.cc",
549+
"gpu_ops/transfer_output.cc",
535550
"gpu_ops/get_padding_offset.cu",
536551
"gpu_ops/set_value_by_flags.cu",
537552
"gpu_ops/rebuild_padding.cu",
@@ -587,6 +602,12 @@ def find_end_files(directory, end_str):
587602
name="fastdeploy_cpu_ops",
588603
ext_modules=CppExtension(
589604
sources=[
605+
"gpu_ops/save_with_output_msg.cc",
606+
"gpu_ops/get_output.cc",
607+
"gpu_ops/get_output_msg_with_topk.cc",
608+
"gpu_ops/save_output_msg_with_topk.cc",
609+
"gpu_ops/transfer_output.cc",
610+
"cpu_ops/rebuild_padding.cc",
590611
"cpu_ops/simd_sort.cc",
591612
"cpu_ops/set_value_by_flags.cc",
592613
"cpu_ops/token_penalty_multi_scores.cc",

custom_ops/setup_ops_base.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

fastdeploy/model_executor/ops/gpu/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
PACKAGE = "fastdeploy.model_executor.ops.gpu"
2121

22-
import_custom_ops(PACKAGE, "..base.fastdeploy_base_ops", globals())
2322
import_custom_ops(PACKAGE, ".fastdeploy_ops", globals())
2423

2524

fastdeploy/model_executor/ops/iluvatar/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
PACKAGE = "fastdeploy.model_executor.ops.iluvatar"
1919

20-
import_custom_ops(PACKAGE, "..base.fastdeploy_base_ops", globals())
2120
import_custom_ops(PACKAGE, ".fastdeploy_ops", globals())
2221

2322
from .moe_ops import iluvatar_moe_expert_ffn as moe_expert_ffn # noqa: F401

0 commit comments

Comments
 (0)