diff --git a/.ci/inferencer_test.py b/.ci/inferencer_test.py index a789f95..ec71d4d 100644 --- a/.ci/inferencer_test.py +++ b/.ci/inferencer_test.py @@ -16,27 +16,12 @@ from importlib import resources import asyncio import os +import pandas as pd +import numpy as np current_file_path = os.path.abspath(__file__) code_dir = os.path.dirname(os.path.dirname(current_file_path)) -alice_serving_config_file_path = os.path.join( - code_dir, - "secretflow_serving/tools/inferencer/example/alice/serving.config", -) -alice_inference_config_file_path = os.path.join( - code_dir, - "secretflow_serving/tools/inferencer/example/alice/inference.config", -) -bob_serving_config_file_path = os.path.join( - code_dir, - "secretflow_serving/tools/inferencer/example/bob/serving.config", -) -bob_inference_config_file_path = os.path.join( - code_dir, - "secretflow_serving/tools/inferencer/example/bob/inference.config", -) - async def run_process(command): process = await asyncio.create_subprocess_exec( @@ -53,19 +38,21 @@ async def run_process(command): ) -async def main(): +async def run_inferencer_example(exmaple_dir: str, result_path: str, target_path: str): + print(f"====begin example: {exmaple_dir}=====") + with resources.path( 'secretflow_serving.tools.inferencer', 'inferencer' ) as tool_path: alice_command = [ str(tool_path), - f'--serving_config_file={alice_serving_config_file_path}', - f'--inference_config_file={alice_inference_config_file_path}', + f'--serving_config_file={exmaple_dir}/alice/serving.config', + f'--inference_config_file={exmaple_dir}/alice/inference.config', ] bob_command = [ str(tool_path), - f'--serving_config_file={bob_serving_config_file_path}', - f'--inference_config_file={bob_inference_config_file_path}', + f'--serving_config_file={exmaple_dir}/bob/serving.config', + f'--inference_config_file={exmaple_dir}/bob/inference.config', ] commands = [alice_command, bob_command] @@ -73,6 +60,33 @@ async def main(): await asyncio.gather(*tasks) + result_df = pd.read_csv(result_path) + target_df = pd.read_csv(target_path) + + score_col = result_df['score'] + pred_col = target_df['pred'] + + assert len(score_col) == len(pred_col) + + are_close = np.isclose(score_col, pred_col, atol=0.0001) + + for i, match in enumerate(are_close): + assert match, f"row {i} mismatch: {score_col[i]} != {pred_col[i]}" + if __name__ == '__main__': - asyncio.run(main()) + asyncio.run( + run_inferencer_example( + "secretflow_serving/tools/inferencer/example/normal", + "tmp/alice/score.csv", + ".ci/test_data/bin_onehot_glm/predict.csv", + ) + ) + + asyncio.run( + run_inferencer_example( + "secretflow_serving/tools/inferencer/example/one_party_no_feature", + "tmp/bob/score.csv", + ".ci/test_data/bin_onehot_glm_alice_no_feature/predict.csv", + ) + ) diff --git a/.circleci/continue-config.yml b/.circleci/continue-config.yml index 973187e..12b6dee 100644 --- a/.circleci/continue-config.yml +++ b/.circleci/continue-config.yml @@ -50,6 +50,8 @@ commands: - run: name: "build" command: | + export BAZEL_MAX_JOBS=16 + sh ./build_wheel_entrypoint.sh bazel build <> -c opt --jobs 16 - run: diff --git a/.circleci/release-config.yml b/.circleci/release-config.yml index b8a1695..6d8dfb5 100644 --- a/.circleci/release-config.yml +++ b/.circleci/release-config.yml @@ -55,6 +55,7 @@ commands: conda create -n build python=<< parameters.python_ver >> -y conda activate build + export BAZEL_MAX_JOBS=16 sh ./build_wheel_entrypoint.sh python3 -m pip install twine ls python_lib/dist/*.whl diff --git a/bazel/ipp.BUILD b/bazel/ipp.BUILD new file mode 100644 index 0000000..9cb1fe8 --- /dev/null +++ b/bazel/ipp.BUILD @@ -0,0 +1,41 @@ +# Copyright 2024 Ant Group Co., Ltd. +# +# 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. + +load("@yacl//bazel:yacl.bzl", "yacl_cmake_external") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "all_srcs", + srcs = glob(["**"]), +) + +yacl_cmake_external( + name = "ipp", + cache_entries = { + "ARCH": "intel64", + "OPENSSL_INCLUDE_DIR": "$EXT_BUILD_DEPS/openssl/include", + "OPENSSL_LIBRARIES": "$EXT_BUILD_DEPS/openssl/lib", + "OPENSSL_ROOT_DIR": "$EXT_BUILD_DEPS/openssl", + "CMAKE_BUILD_TYPE": "Release", + }, + lib_source = ":all_srcs", + out_static_libs = [ + "intel64/libippcp.a", + "intel64/libcrypto_mb.a", + ], + deps = [ + "@com_github_openssl_openssl//:openssl", + ], +) diff --git a/bazel/patches/ippcp.patch b/bazel/patches/ippcp.patch new file mode 100644 index 0000000..af63505 --- /dev/null +++ b/bazel/patches/ippcp.patch @@ -0,0 +1,172 @@ +diff --git a/sources/cmake/linux/GNU8.2.0.cmake b/sources/cmake/linux/GNU8.2.0.cmake +index 24d7e0f..15dd433 100644 +--- a/sources/cmake/linux/GNU8.2.0.cmake ++++ b/sources/cmake/linux/GNU8.2.0.cmake +@@ -32,7 +32,7 @@ set(LINK_FLAG_DYNAMIC_LINUX "${LINK_FLAG_SECURITY} -nostdlib") + # Dynamically link lib c (libdl is for old apps) + set(LINK_FLAG_DYNAMIC_LINUX "${LINK_FLAG_DYNAMIC_LINUX} -Wl,-call_shared,-lc") + # Create a shared library +-set(LINK_FLAG_DYNAMIC_LINUX "-Wl,-shared") ++set(LINK_FLAG_DYNAMIC_LINUX "-Wl,-shared,-fuse-ld=bfd") + if(${ARCH} MATCHES "ia32") + # Tells the compiler to generate code for a specific architecture (32) + set(LINK_FLAG_DYNAMIC_LINUX "${LINK_FLAG_DYNAMIC_LINUX} -m32") +@@ -74,7 +74,7 @@ if ((${ARCH} MATCHES "ia32") OR (NOT NONPIC_LIB)) + endif() + + # Security flag that adds compile-time and run-time checks +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2") ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") + + if(NOT NONPIC_LIB) + # Position Independent Execution (PIE) +@@ -95,6 +95,8 @@ if(${ARCH} MATCHES "ia32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + endif(${ARCH} MATCHES "ia32") + ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wno-strict-aliasing -Wno-parentheses -Wno-array-parameter") ++ + # Optimization level = 3, no-debug definition (turns off asserts), warnings=errors + set (CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG -Werror") + +diff --git a/sources/cmake/macosx/AppleClang11.0.0.cmake b/sources/cmake/macosx/AppleClang11.0.0.cmake +index 5b92877..ccb963e 100644 +--- a/sources/cmake/macosx/AppleClang11.0.0.cmake ++++ b/sources/cmake/macosx/AppleClang11.0.0.cmake +@@ -20,12 +20,6 @@ + + # Security Linker flags + set(LINK_FLAG_SECURITY "") +-# Disallows undefined symbols in object files. Undefined symbols in shared libraries are still allowed +-set(LINK_FLAG_SECURITY "${LINK_FLAG_SECURITY} -Wl,-z,defs") +-# Stack execution protection +-set(LINK_FLAG_SECURITY "${LINK_FLAG_SECURITY} -Wl,-z,noexecstack") +-# Data relocation and protection (RELRO) +-set(LINK_FLAG_SECURITY "${LINK_FLAG_SECURITY} -Wl,-z,relro -Wl,-z,now") + # Prevents the compiler from using standard libraries and startup files when linking. + set(LINK_FLAG_DYNAMIC_MACOSX "${LINK_FLAG_SECURITY} -nostdlib") + # Dynamically link lib c (libdl is for old apps) +@@ -79,7 +73,7 @@ if ((${ARCH} MATCHES "ia32") OR (NOT NONPIC_LIB)) + endif() + + # Security flag that adds compile-time and run-time checks +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2") ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") + + if(NOT NONPIC_LIB) + # Position Independent Execution (PIE) +@@ -98,6 +92,8 @@ if(${ARCH} MATCHES "ia32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + endif(${ARCH} MATCHES "ia32") + ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unknown-pragmas -Wno-missing-braces -Wno-unused-command-line-argument -Wno-unused-but-set-variable -Wno-unknown-warning-option") ++ + # Optimization level = 3, no-debug definition (turns off asserts), warnings=errors + set (CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG -Werror") + +@@ -115,3 +111,5 @@ set(l9_opt "${l9_opt} -march=haswell -mavx2 -maes -mpclmul -msha -mrdrnd -mrdsee + set(n0_opt "${n0_opt} -march=knl -mavx2 -maes -mavx512f -mavx512cd -mavx512pf -mavx512er -mpclmul -msha -mrdrnd -mrdseed") + set(k0_opt "${k0_opt} -march=skylake-avx512") + set(k0_opt "${k0_opt} -maes -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mpclmul -msha -mrdrnd -mrdseed -madx -mgfni -mvaes -mvpclmulqdq -mavx512vbmi -mavx512vbmi2") ++set(k1_opt "${k1_opt} -march=skylake-avx512") ++set(k1_opt "${k1_opt} -maes -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mpclmul -msha -mrdrnd -mrdseed -madx -mgfni -mvaes -mvpclmulqdq -mavx512vbmi -mavx512vbmi2") +diff --git a/sources/cmake/macosx/common.cmake b/sources/cmake/macosx/common.cmake +index 85ec3ad..67bb9f9 100644 +--- a/sources/cmake/macosx/common.cmake ++++ b/sources/cmake/macosx/common.cmake +@@ -18,7 +18,7 @@ + # Intel® Integrated Performance Primitives Cryptography (Intel® IPP Cryptography) + # + +-set(OS_DEFAULT_COMPILER Intel19.0.0) ++set(OS_DEFAULT_COMPILER AppleClang11.0.0) + + set(LIBRARY_DEFINES "${LIBRARY_DEFINES} -DIPP_PIC -DOSXEM64T -DLINUX32E -D_ARCH_EM64T") + #set(LIBRARY_DEFINES "${LIBRARY_DEFINES} -DBN_OPENSSL_DISABLE") +\ No newline at end of file +diff --git a/sources/ippcp/crypto_mb/src/cmake/linux/GNU.cmake b/sources/ippcp/crypto_mb/src/cmake/linux/GNU.cmake +index a2abeeb..67aca8b 100644 +--- a/sources/ippcp/crypto_mb/src/cmake/linux/GNU.cmake ++++ b/sources/ippcp/crypto_mb/src/cmake/linux/GNU.cmake +@@ -31,7 +31,7 @@ set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -Wformat -Wformat-security + if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + if(NOT DEFINED NO_FORTIFY_SOURCE) + # Security flag that adds compile-time and run-time checks. +- set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -D_FORTIFY_SOURCE=2") ++ set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") + endif() + endif() + +@@ -51,7 +51,7 @@ set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -Werror") + # Linker flags + + # Create shared library +-set(LINK_FLAGS_DYNAMIC " -Wl,-shared") ++set(LINK_FLAGS_DYNAMIC " -Wl,-shared,-fuse-ld=bfd") + # Add export files + set(LINK_FLAGS_DYNAMIC "${LINK_FLAGS_DYNAMIC} ${CRYPTO_MB_SOURCES_DIR}/cmake/dll_export/crypto_mb.linux.lib-export") + +@@ -69,6 +69,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + + # Suppress warnings from casts from a pointer to an integer type of a different size + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pointer-to-int-cast") ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wno-strict-aliasing -Wno-parentheses") + + # Optimization level = 3, no-debug definition (turns off asserts) + set(CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG") +diff --git a/sources/ippcp/crypto_mb/src/cmake/macosx/AppleClang.cmake b/sources/ippcp/crypto_mb/src/cmake/macosx/AppleClang.cmake +index ea1641d..f98fc2d 100644 +--- a/sources/ippcp/crypto_mb/src/cmake/macosx/AppleClang.cmake ++++ b/sources/ippcp/crypto_mb/src/cmake/macosx/AppleClang.cmake +@@ -17,10 +17,6 @@ + # Security Linker flags + + set(LINK_FLAG_SECURITY "") +-# Data relocation and protection (RELRO) +-set(LINK_FLAG_SECURITY "${LINK_FLAG_SECURITY} -Wl,-z,relro -Wl,-z,now") +-# Stack execution protection +-set(LINK_FLAG_SECURITY "${LINK_FLAG_SECURITY} -Wl,-z,noexecstack") + + # Security Compiler flags + +@@ -30,7 +26,7 @@ set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -Wformat -Wformat-security + + if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + # Security flag that adds compile-time and run-time checks. +- set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -D_FORTIFY_SOURCE=2") ++ set(CMAKE_C_FLAGS_SECURITY "${CMAKE_C_FLAGS_SECURITY} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") + endif() + + # Stack-based Buffer Overrun Detection +@@ -65,6 +61,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + # Suppress warnings from casts from a pointer to an integer type of a different size + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pointer-to-int-cast") + ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unknown-pragmas -Wno-missing-braces -Wno-unknown-warning-option") ++ + # Optimization level = 3, no-debug definition (turns off asserts) + set(CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + +diff --git a/sources/cmake/linux/Clang9.0.0.cmake b/sources/cmake/linux/Clang9.0.0.cmake +index 0015431..f93411c 100644 +--- a/sources/cmake/linux/Clang9.0.0.cmake ++++ b/sources/cmake/linux/Clang9.0.0.cmake +@@ -79,7 +79,7 @@ endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcf-protection=full") + + # Security flag that adds compile-time and run-time checks +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2") ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + + if(NOT NONPIC_LIB) + # Position Independent Execution (PIE) +@@ -107,7 +107,7 @@ if(SANITIZERS) + endif(SANITIZERS) + + # Optimization level = 3, no-debug definition (turns off asserts), warnings=errors +-set (CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG -Werror") ++set (CMAKE_C_FLAGS_RELEASE " -O3 -DNDEBUG -Werror -Wno-unused-function -Wno-missing-braces -Wno-unused-but-set-variable -Wno-unknown-pragmas") + + # DEBUG flags - optimization level = 0, generation GDB information (-g) + set (CMAKE_C_FLAGS_DEBUG " -O0 -g") diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 11d73b1..b8b5424 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -33,6 +33,8 @@ def sf_serving_deps(): _com_aws_checksums() _com_aws_sdk() + _com_github_intel_ipp() + _heu() _dataproxy() @@ -209,3 +211,19 @@ def _com_github_brpc_brpc(): "https://github.com/apache/brpc/archive/refs/tags/1.9.0.tar.gz", ], ) + +def _com_github_intel_ipp(): + maybe( + http_archive, + name = "com_github_intel_ipp", + sha256 = "d70f42832337775edb022ca8ac1ac418f272e791ec147778ef7942aede414cdc", + strip_prefix = "cryptography-primitives-ippcp_2021.8", + build_file = "@sf_serving//bazel:ipp.BUILD", + patch_args = ["-p1"], + patches = [ + "@sf_serving//bazel:patches/ippcp.patch", + ], + urls = [ + "https://github.com/intel/ipp-crypto/archive/refs/tags/ippcp_2021.8.tar.gz", + ], + ) diff --git a/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/deployment.po b/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/deployment.po index 80409a8..682c06e 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/deployment.po +++ b/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/deployment.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: SecretFlow-Serving \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-01 16:51+0800\n" +"POT-Creation-Date: 2024-10-14 11:33+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -64,8 +64,8 @@ msgid "" "via `HTTPS`. Please check :ref:`mTLS Configuration ` for " "details." msgstr "" -"本示例的SecretFlow-Serving 通过 `HTTP` 协议提供服务。然而对于生产环境,建议使用 `mTLS` 加固各个通信链路,并通过 `HTTPS` 访问服务。请查看 " -":ref:`mTLS 配置 ` 获取详细信息。" +"本示例的SecretFlow-Serving 通过 `HTTP` 协议提供服务。然而对于生产环境,建议使用 `mTLS` 加固各个通信链路,并通过" +" `HTTPS` 访问服务。请查看 :ref:`mTLS 配置 ` 获取详细信息。" #: ../../source/topics/deployment/deployment.rst:18 msgid "" @@ -75,7 +75,9 @@ msgid "" "Communication Configuration `, and :ref:`SPI Communication" " Configuration `." msgstr "" -"SecretFlow-Serving 支持不同的通信链路配置不同的 `mTLS` 配置,可查看 :ref:`服务端配置 `、:ref:`集群通信配置 `、:ref:`SPI配置 ` 获取详细信息" +"SecretFlow-Serving 支持不同的通信链路配置不同的 `mTLS` 配置,可查看 :ref:`服务端配置 " +"`、:ref:`集群通信配置 `、:ref:`SPI配置 `" +" 获取详细信息" #: ../../source/topics/deployment/deployment.rst:21 msgid "Step 1: Deploy SecretFlow-Serving" @@ -275,25 +277,35 @@ msgstr "" msgid "``trace_config_file`` line is optional." msgstr "``trace_config_file`` 这一行是可选的。" -#: ../../source/topics/deployment/deployment.rst:188 +#: ../../source/topics/deployment/deployment.rst:185 +msgid "" +"You can also use mirrors at Alibaba Cloud: ``secretflow-registry.cn-" +"hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-" +"registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]``" +msgstr "" +"你也可以使用阿里云上的镜像:``secretflow-registry.cn-" +"hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-" +"registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]``" + +#: ../../source/topics/deployment/deployment.rst:189 msgid "Step 2: Start Serving Service" msgstr "步骤 2:启动 Serving 服务" -#: ../../source/topics/deployment/deployment.rst:190 +#: ../../source/topics/deployment/deployment.rst:191 msgid "" "The file your workspace should be as follows, ``trace.config`` is " "optional:" msgstr "您工作区的文件应如下所示,``trace.config`` 是可选的:" -#: ../../source/topics/deployment/deployment.rst:200 +#: ../../source/topics/deployment/deployment.rst:201 msgid "Then you can start serving service by running docker compose up." msgstr "然后您可以运行 docker compose up 来启动 serving 服务" -#: ../../source/topics/deployment/deployment.rst:207 +#: ../../source/topics/deployment/deployment.rst:208 msgid "You can use docker logs to check whether serving works well" msgstr "您可以使用 docker logs 检查 serving 是否正常工作" -#: ../../source/topics/deployment/deployment.rst:213 +#: ../../source/topics/deployment/deployment.rst:214 msgid "" "Now, ``Alice`` serving is listening on ``9010``, you can confirm if the " "service is ready by accessing the ``/health`` endpoint." @@ -301,17 +313,17 @@ msgstr "" "现在 ``Alice`` 的 serving 服务监听了 ``9010`` 端口,您可以通过访问 ``/health`` " "接口来检测服务是否已经准备完成。" -#: ../../source/topics/deployment/deployment.rst:219 +#: ../../source/topics/deployment/deployment.rst:220 msgid "" "When the endpoint returns a status code of ``200``, it means that the " "service is ready." msgstr "若接口返回状态码 ``200`` 则标志服务已经准备完成。" -#: ../../source/topics/deployment/deployment.rst:222 +#: ../../source/topics/deployment/deployment.rst:223 msgid "Step 3: Predict Test" msgstr "步骤 3:预测测试" -#: ../../source/topics/deployment/deployment.rst:224 +#: ../../source/topics/deployment/deployment.rst:225 msgid "" "Based on the capabilities of `Brpc " "`_, serving supports accessing " @@ -321,7 +333,7 @@ msgstr "" "得益于 `Brpc `_ 的能力,serving " "能够支持通过多种协议进行访问。这里我们通过发送一个 HTTP 的预测请求来测试服务。" -#: ../../source/topics/deployment/deployment.rst:226 +#: ../../source/topics/deployment/deployment.rst:227 msgid "" "You can read :ref:`SecretFlow-Serving API ` for more " "information about serving APIs." diff --git a/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/serving_on_kuscia.po b/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/serving_on_kuscia.po index 32e2e07..3caf020 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/serving_on_kuscia.po +++ b/docs/locales/zh_CN/LC_MESSAGES/topics/deployment/serving_on_kuscia.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: SecretFlow-Serving \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-20 11:45+0800\n" +"POT-Creation-Date: 2024-10-14 11:33+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -48,7 +48,17 @@ msgstr "" "Hans/reference/concepts/appimage_cn#id2>`_ 。SecretFlow-Serving 的 " "`AppImage` 如下所示:" -#: ../../source/topics/deployment/serving_on_kuscia.rst:85 +#: ../../source/topics/deployment/serving_on_kuscia.rst:87 +msgid "" +"You can also use mirrors at Alibaba Cloud: ``secretflow-registry.cn-" +"hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-" +"registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]``" +msgstr "" +"你也可以使用阿里云上的镜像:``secretflow-registry.cn-" +"hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-" +"registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]``" + +#: ../../source/topics/deployment/serving_on_kuscia.rst:89 msgid "" "The explanation of the common fields can be found `here " "`_ 。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:87 +#: ../../source/topics/deployment/serving_on_kuscia.rst:91 msgid "Other field explanations are as follows:" msgstr "其他字段说明如下:" -#: ../../source/topics/deployment/serving_on_kuscia.rst:99 +#: ../../source/topics/deployment/serving_on_kuscia.rst:93 msgid "**configTemplates**:" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:96 +#: ../../source/topics/deployment/serving_on_kuscia.rst:94 msgid "**serving-config.conf**:" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:91 +#: ../../source/topics/deployment/serving_on_kuscia.rst:95 msgid "" "**serving_id**: Service ID identifier, corresponding to the configuration" " :ref:`ServingConfig.id `. The current content is a " @@ -82,7 +92,7 @@ msgstr "" "`_ 中的内容替换。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:92 +#: ../../source/topics/deployment/serving_on_kuscia.rst:96 msgid "" "**input_config**: SecretFlow-Serving startup configuration, details can " "be seen in the description below. The current content is a placeholder " @@ -95,7 +105,7 @@ msgstr "" "`_ 中的内容替换。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:93 +#: ../../source/topics/deployment/serving_on_kuscia.rst:97 msgid "" "**cluster_def**: See `AppImage explanation " "`_。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:94 +#: ../../source/topics/deployment/serving_on_kuscia.rst:98 msgid "" "**allocated_ports**: See `AppImage explanation " "`_。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:95 +#: ../../source/topics/deployment/serving_on_kuscia.rst:99 msgid "" "**oss_meta**: OSS/S3 model source configuration, only effective when " "using OSS/S3 as the model data source. The actual content is in the form " @@ -133,7 +143,7 @@ msgstr "" "\\\"bucket\\\":\\\"test_bucket\\\"}``,其具体定义可见 :ref:`这里 ` " "该配置为可选配置,若需要使用可通过`Kuscia 配置管理系统`进行配置。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:96 +#: ../../source/topics/deployment/serving_on_kuscia.rst:100 msgid "" "**spi_tls_config**: The TLS configuration used by SPI. The actual content" " is in the form of a string-formatted JSON configuration, for example: " @@ -146,7 +156,7 @@ msgstr "" "**spi_tls_config**:SPI链路使用的TLS配置。其真实内容为字符串格式化的Json配置,例如:``{\\\"certificate_path\\\":\\\"abc\\\",\"\\\"private_key_path\\\":\\\"def\\\",\\\"ca_file_path\\\":\\\"gkh\\\"}``,具体定义可见" " :ref:`这里 ` 。该配置为可选配置,若需要使用可通过`Kuscia 配置管理系统`进行配置。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:97 +#: ../../source/topics/deployment/serving_on_kuscia.rst:101 msgid "" "**http_source_meta**: HTTP model source configuration, only effective " "when using HTTP as the model data source. The actual content is in the " @@ -157,14 +167,13 @@ msgid "" "optional configuration and can be set up through the ``Kuscia " "configuration management`` system if needed." msgstr "" -"**http_source_meta**:HTTP 数据源" -"配置,只当使用HTTP服务作为模型数据源时生效。其真实内容为字符串格式化的Json配置,例如:" -"``{\\\"connectTimeoutMs\\\":60000,\\\"timeoutMs\\\":120000,\\\"tlsConfig\\\":{\\\"certificatePath\\\":\\\"abc\\\"," -" \\\"privateKeyPath\\\":\\\"def\\\",\\\"caFilePath\\\":\\\"gkh\\\"}}``" -",其具体定义可见 :ref:`这里 ` " -"该配置为可选配置,若需要使用可通过`Kuscia 配置管理系统`进行配置。" +"**http_source_meta**:HTTP " +"数据源配置,只当使用HTTP服务作为模型数据源时生效。其真实内容为字符串格式化的Json配置,例如:``{\\\"connectTimeoutMs\\\":60000,\\\"timeoutMs\\\":120000,\\\"tlsConfig\\\":{\\\"certificatePath\\\":\\\"abc\\\"," +" " +"\\\"privateKeyPath\\\":\\\"def\\\",\\\"caFilePath\\\":\\\"gkh\\\"}}``,其具体定义可见" +" :ref:`这里 ` 该配置为可选配置,若需要使用可通过`Kuscia 配置管理系统`进行配置。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:98 +#: ../../source/topics/deployment/serving_on_kuscia.rst:102 msgid "" "**logging-config.conf**: SecretFlow-Serving Log Configuration. The actual" " content is in the form of a string-formatted JSON configuration, for " @@ -178,7 +187,7 @@ msgstr "" "config.conf**:日志配置。其真实内容为字符串格式化的Json配置,例如:``{\\\"systemLogPath\\\":\\\"/tmp/alice/serving.log\\\",\\\"logLevel\\\":\\\"INFO_LOG_LEVEL\\\",\\\"maxLogFileSize\\\":4194304,\\\"maxLogFileCount\\\":10}``,具体定义可见" " :ref:`这里 ` 。该配置为可选配置,若需要使用可通过`Kuscia 配置管理系统`进行配置。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:99 +#: ../../source/topics/deployment/serving_on_kuscia.rst:103 msgid "" "**trace-config.conf**: SecretFlow-Serving Trace Configuration. The actual" " content is in the form of a string-formatted JSON configuration, for " @@ -196,21 +205,21 @@ msgstr "" msgid "**ports**:" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:102 +#: ../../source/topics/deployment/serving_on_kuscia.rst:106 msgid "**service**: The :ref:`ServerConfig.service_port `" msgstr "**service**: 即 :ref:`ServerConfig.service_port `" -#: ../../source/topics/deployment/serving_on_kuscia.rst:103 +#: ../../source/topics/deployment/serving_on_kuscia.rst:107 msgid "" "**communication**: The :ref:`ServerConfig.communication_port " "`" msgstr "**communication**:即 :ref:`ServerConfig.communication_port `" -#: ../../source/topics/deployment/serving_on_kuscia.rst:104 +#: ../../source/topics/deployment/serving_on_kuscia.rst:108 msgid "**internal**: The :ref:`ServerConfig.metrics_exposer_port `" msgstr "**internal**:即 :ref:`ServerConfig.metrics_exposer_port `" -#: ../../source/topics/deployment/serving_on_kuscia.rst:105 +#: ../../source/topics/deployment/serving_on_kuscia.rst:109 msgid "" "**brpc-builtin**: The :ref:`ServerConfig.brpc_builtin_service_port " "`" @@ -218,15 +227,15 @@ msgstr "" "**brpc-builtin**:即 :ref:`ServerConfig.brpc_builtin_service_port " "`" -#: ../../source/topics/deployment/serving_on_kuscia.rst:108 +#: ../../source/topics/deployment/serving_on_kuscia.rst:112 msgid "Configuration description" msgstr "配置说明" -#: ../../source/topics/deployment/serving_on_kuscia.rst:111 +#: ../../source/topics/deployment/serving_on_kuscia.rst:115 msgid "serving_input_config" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:113 +#: ../../source/topics/deployment/serving_on_kuscia.rst:117 msgid "" "The launch and management of SecretFlow-Serving can be performed using " "the `Kuscia Serving API " @@ -240,164 +249,164 @@ msgstr "" "Hans/reference/apis/serving_cn#serving>`_ 进行,这里我们将对 " "``/api/v1/serving/create`` 请求中的 ``serving_input_config`` 字段内容进行说明。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:168 +#: ../../source/topics/deployment/serving_on_kuscia.rst:172 msgid "**Field description**:" msgstr "**字段说明**:" -#: ../../source/topics/deployment/serving_on_kuscia.rst:171 +#: ../../source/topics/deployment/serving_on_kuscia.rst:175 msgid "Name" msgstr "名称" -#: ../../source/topics/deployment/serving_on_kuscia.rst:171 +#: ../../source/topics/deployment/serving_on_kuscia.rst:175 msgid "Type" msgstr "类型" -#: ../../source/topics/deployment/serving_on_kuscia.rst:171 +#: ../../source/topics/deployment/serving_on_kuscia.rst:175 msgid "Description" msgstr "描述" -#: ../../source/topics/deployment/serving_on_kuscia.rst:171 +#: ../../source/topics/deployment/serving_on_kuscia.rst:175 msgid "Required" msgstr "必选" -#: ../../source/topics/deployment/serving_on_kuscia.rst:173 +#: ../../source/topics/deployment/serving_on_kuscia.rst:177 msgid "partyConfigs" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:173 +#: ../../source/topics/deployment/serving_on_kuscia.rst:177 msgid "map" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:173 +#: ../../source/topics/deployment/serving_on_kuscia.rst:177 msgid "" "Dictionary of startup parameters for each participant. Key: Participant " "Unique ID; Value: PartyConfig (Json Object)." msgstr "各参与方启动参数字典。Key: 参与方id; Value: PartyConfig(Json Object)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:173 -#: ../../source/topics/deployment/serving_on_kuscia.rst:175 +#: ../../source/topics/deployment/serving_on_kuscia.rst:177 #: ../../source/topics/deployment/serving_on_kuscia.rst:179 -#: ../../source/topics/deployment/serving_on_kuscia.rst:181 #: ../../source/topics/deployment/serving_on_kuscia.rst:183 #: ../../source/topics/deployment/serving_on_kuscia.rst:185 -#: ../../source/topics/deployment/serving_on_kuscia.rst:190 -#: ../../source/topics/deployment/serving_on_kuscia.rst:198 -#: ../../source/topics/deployment/serving_on_kuscia.rst:206 -#: ../../source/topics/deployment/serving_on_kuscia.rst:216 -#: ../../source/topics/deployment/serving_on_kuscia.rst:218 +#: ../../source/topics/deployment/serving_on_kuscia.rst:187 +#: ../../source/topics/deployment/serving_on_kuscia.rst:189 +#: ../../source/topics/deployment/serving_on_kuscia.rst:194 +#: ../../source/topics/deployment/serving_on_kuscia.rst:202 +#: ../../source/topics/deployment/serving_on_kuscia.rst:210 #: ../../source/topics/deployment/serving_on_kuscia.rst:220 #: ../../source/topics/deployment/serving_on_kuscia.rst:222 +#: ../../source/topics/deployment/serving_on_kuscia.rst:224 +#: ../../source/topics/deployment/serving_on_kuscia.rst:226 msgid "Yes" msgstr "是" -#: ../../source/topics/deployment/serving_on_kuscia.rst:175 +#: ../../source/topics/deployment/serving_on_kuscia.rst:179 msgid "PartyConfig.serverConfig" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:175 -#: ../../source/topics/deployment/serving_on_kuscia.rst:181 -#: ../../source/topics/deployment/serving_on_kuscia.rst:183 +#: ../../source/topics/deployment/serving_on_kuscia.rst:179 #: ../../source/topics/deployment/serving_on_kuscia.rst:185 #: ../../source/topics/deployment/serving_on_kuscia.rst:187 #: ../../source/topics/deployment/serving_on_kuscia.rst:189 -#: ../../source/topics/deployment/serving_on_kuscia.rst:196 -#: ../../source/topics/deployment/serving_on_kuscia.rst:202 +#: ../../source/topics/deployment/serving_on_kuscia.rst:191 +#: ../../source/topics/deployment/serving_on_kuscia.rst:193 +#: ../../source/topics/deployment/serving_on_kuscia.rst:200 #: ../../source/topics/deployment/serving_on_kuscia.rst:206 -#: ../../source/topics/deployment/serving_on_kuscia.rst:222 +#: ../../source/topics/deployment/serving_on_kuscia.rst:210 +#: ../../source/topics/deployment/serving_on_kuscia.rst:226 msgid "str" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:175 +#: ../../source/topics/deployment/serving_on_kuscia.rst:179 msgid ":ref:`ServerConfig `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:177 +#: ../../source/topics/deployment/serving_on_kuscia.rst:181 msgid "PartyConfig.serverConfig.featureMapping" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:177 +#: ../../source/topics/deployment/serving_on_kuscia.rst:181 msgid "map" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:177 +#: ../../source/topics/deployment/serving_on_kuscia.rst:181 msgid "" "Feature name mapping rules. Key: source or predefined feature name; " "Value: model feature name" msgstr "特征名称映射规则。Key: 数据源或请求定义中的特征名称;Value: 模型中使用的特征名称。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:177 -#: ../../source/topics/deployment/serving_on_kuscia.rst:187 -#: ../../source/topics/deployment/serving_on_kuscia.rst:196 -#: ../../source/topics/deployment/serving_on_kuscia.rst:202 -#: ../../source/topics/deployment/serving_on_kuscia.rst:208 -#: ../../source/topics/deployment/serving_on_kuscia.rst:210 +#: ../../source/topics/deployment/serving_on_kuscia.rst:181 +#: ../../source/topics/deployment/serving_on_kuscia.rst:191 +#: ../../source/topics/deployment/serving_on_kuscia.rst:200 +#: ../../source/topics/deployment/serving_on_kuscia.rst:206 #: ../../source/topics/deployment/serving_on_kuscia.rst:212 -#: ../../source/topics/deployment/serving_on_kuscia.rst:224 -#: ../../source/topics/deployment/serving_on_kuscia.rst:226 +#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:216 +#: ../../source/topics/deployment/serving_on_kuscia.rst:228 +#: ../../source/topics/deployment/serving_on_kuscia.rst:230 msgid "No" msgstr "否" -#: ../../source/topics/deployment/serving_on_kuscia.rst:179 +#: ../../source/topics/deployment/serving_on_kuscia.rst:183 msgid "PartyConfig.modelConfig" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:179 -#: ../../source/topics/deployment/serving_on_kuscia.rst:194 +#: ../../source/topics/deployment/serving_on_kuscia.rst:183 #: ../../source/topics/deployment/serving_on_kuscia.rst:198 -#: ../../source/topics/deployment/serving_on_kuscia.rst:200 +#: ../../source/topics/deployment/serving_on_kuscia.rst:202 #: ../../source/topics/deployment/serving_on_kuscia.rst:204 -#: ../../source/topics/deployment/serving_on_kuscia.rst:214 -#: ../../source/topics/deployment/serving_on_kuscia.rst:216 +#: ../../source/topics/deployment/serving_on_kuscia.rst:208 #: ../../source/topics/deployment/serving_on_kuscia.rst:218 #: ../../source/topics/deployment/serving_on_kuscia.rst:220 +#: ../../source/topics/deployment/serving_on_kuscia.rst:222 +#: ../../source/topics/deployment/serving_on_kuscia.rst:224 msgid "Object" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:179 +#: ../../source/topics/deployment/serving_on_kuscia.rst:183 msgid ":ref:`ModelConfig `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:181 +#: ../../source/topics/deployment/serving_on_kuscia.rst:185 msgid "PartyConfig.modelConfig.modelId" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:181 +#: ../../source/topics/deployment/serving_on_kuscia.rst:185 msgid "Unique id of the model package" msgstr "模型包标识ID" -#: ../../source/topics/deployment/serving_on_kuscia.rst:183 +#: ../../source/topics/deployment/serving_on_kuscia.rst:187 msgid "PartyConfig.modelConfig.basePath" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:183 +#: ../../source/topics/deployment/serving_on_kuscia.rst:187 msgid "The local path used to cache and load model package" msgstr "本地缓存路径,用于缓存模型包数据" -#: ../../source/topics/deployment/serving_on_kuscia.rst:185 +#: ../../source/topics/deployment/serving_on_kuscia.rst:189 msgid "PartyConfig.modelConfig.sourcePath" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:185 +#: ../../source/topics/deployment/serving_on_kuscia.rst:189 msgid "" "The path to the model package in the data source, where the content " "format may vary depending on the ``sourceType``." msgstr "模型包路径,其具体内容格式取决于参数 ``sourceType``" -#: ../../source/topics/deployment/serving_on_kuscia.rst:187 +#: ../../source/topics/deployment/serving_on_kuscia.rst:191 msgid "PartyConfig.modelConfig.sourceSha256" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:187 +#: ../../source/topics/deployment/serving_on_kuscia.rst:191 msgid "" "The expected SHA256 hash of the model package. When provided, the fetched" " model package will be verified against it." msgstr "期望的模型包SHA256哈希值。提供时,会被用于校验获取的模型包是否匹配。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:189 +#: ../../source/topics/deployment/serving_on_kuscia.rst:193 msgid "PartyConfig.modelConfig.sourceType" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:189 +#: ../../source/topics/deployment/serving_on_kuscia.rst:193 msgid "" "Model data source type, options include: ``ST_FILE``: In this case, the " "``sourcePath`` should be a file path accessible to Serving. ``ST_DP``: In" @@ -412,158 +421,158 @@ msgstr "" "``dpSourceMeta``。 ``ST_OSS``: 此时 ``sourcePath`` 应为 Bucket 下的文件路径。 " "``ST_HTTP``: 此时 ``sourcePath`` 应为模型包的下载链接。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:194 +#: ../../source/topics/deployment/serving_on_kuscia.rst:198 msgid "PartyConfig.modelConfig.dpSourceMeta" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:194 +#: ../../source/topics/deployment/serving_on_kuscia.rst:198 msgid ":ref:`DPSourceMeta `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:194 +#: ../../source/topics/deployment/serving_on_kuscia.rst:198 msgid "" "No(If ``sourceType`` is ``DT_DP``, ``dpSourceMeta`` needs to be " "configured)" msgstr "否(只当 ``sourceType`` 为 ``DT_DP`` 时, ``dpSourceMeta`` 需要被配置)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:196 +#: ../../source/topics/deployment/serving_on_kuscia.rst:200 msgid "PartyConfig.modelConfig.dpSourceMeta.dmHost" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:196 +#: ../../source/topics/deployment/serving_on_kuscia.rst:200 msgid "The address of DataMesh in Kuscia. Default: datamesh:8071" msgstr "Kusica DataMesh地址, 默认值: datamesh:8071" -#: ../../source/topics/deployment/serving_on_kuscia.rst:198 +#: ../../source/topics/deployment/serving_on_kuscia.rst:202 msgid "PartyConfig.featureSourceConfig" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:198 +#: ../../source/topics/deployment/serving_on_kuscia.rst:202 msgid ":ref:`FeatureSourceConfig `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:200 +#: ../../source/topics/deployment/serving_on_kuscia.rst:204 msgid "PartyConfig.featureSourceConfig.mockOpts" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:200 +#: ../../source/topics/deployment/serving_on_kuscia.rst:204 msgid ":ref:`MockOptions `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:200 #: ../../source/topics/deployment/serving_on_kuscia.rst:204 -#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:208 +#: ../../source/topics/deployment/serving_on_kuscia.rst:218 msgid "" "No(One of ``csvOpts``, ``mockOpts``, or ``httpOpts`` needs to be " "configured)" msgstr "否(``csvOpts``, ``mockOpts`` 或者 ``httpOpts`` 中的之一需要被配置)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:202 +#: ../../source/topics/deployment/serving_on_kuscia.rst:206 msgid "PartyConfig.featureSourceConfig.mockOpts.type" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:202 +#: ../../source/topics/deployment/serving_on_kuscia.rst:206 msgid "" "The method for generating mock feature values, options: \"MDT_RANDOM\" " "for random values, and \"MDT_FIXED\" for fixed values. Default: " "\"MDT_FIXED\"." msgstr "mock特征数据生成方法类型,可选:\"MDT_RANDOM\"用于生成随机值;\"MDT_FIXED\"返回固定值。默认设置为:\"MDT_FIXED\"。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:204 +#: ../../source/topics/deployment/serving_on_kuscia.rst:208 msgid "PartyConfig.featureSourceConfig.httpOpts" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:204 +#: ../../source/topics/deployment/serving_on_kuscia.rst:208 msgid ":ref:`HttpOptions `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:206 +#: ../../source/topics/deployment/serving_on_kuscia.rst:210 msgid "PartyConfig.featureSourceConfig.httpOpts.endpoint" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:206 +#: ../../source/topics/deployment/serving_on_kuscia.rst:210 msgid "Feature service address" msgstr "特征服务地址" -#: ../../source/topics/deployment/serving_on_kuscia.rst:208 +#: ../../source/topics/deployment/serving_on_kuscia.rst:212 msgid "PartyConfig.featureSourceConfig.httpOpts.enableLb" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:208 +#: ../../source/topics/deployment/serving_on_kuscia.rst:212 msgid "bool" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:208 +#: ../../source/topics/deployment/serving_on_kuscia.rst:212 msgid "Whether to enable round robin load balancer, Default: False" msgstr "是否开启轮询负载均衡访问,默认值:False。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:210 +#: ../../source/topics/deployment/serving_on_kuscia.rst:214 msgid "PartyConfig.featureSourceConfig.httpOpts.connectTimeoutMs" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:210 -#: ../../source/topics/deployment/serving_on_kuscia.rst:212 -#: ../../source/topics/deployment/serving_on_kuscia.rst:224 -#: ../../source/topics/deployment/serving_on_kuscia.rst:226 +#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:216 +#: ../../source/topics/deployment/serving_on_kuscia.rst:228 +#: ../../source/topics/deployment/serving_on_kuscia.rst:230 msgid "int32" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:210 -#: ../../source/topics/deployment/serving_on_kuscia.rst:226 +#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:230 msgid "Max duration for a connect. -1 means wait indefinitely. Default: 500 (ms)" msgstr "连接超时时间,-1 即无限时间,默认值:500 (ms)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:212 +#: ../../source/topics/deployment/serving_on_kuscia.rst:216 msgid "PartyConfig.featureSourceConfig.httpOpts.timeoutMs" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:212 +#: ../../source/topics/deployment/serving_on_kuscia.rst:216 msgid "" "Max duration of http request. -1 means wait indefinitely. Default: 1000 " "(ms)" msgstr "请求超时时间,-1 即无限时间,默认值:1000 (ms)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:218 msgid "PartyConfig.featureSourceConfig.csvOpts" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:214 +#: ../../source/topics/deployment/serving_on_kuscia.rst:218 msgid ":ref:`CsvOptions `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:216 +#: ../../source/topics/deployment/serving_on_kuscia.rst:220 msgid "PartyConfig.featureSourceConfig.csvOpts.filePath" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:216 +#: ../../source/topics/deployment/serving_on_kuscia.rst:220 msgid "" "Input file path, specifies where to load data. Note that this will load " "all of the data into memory at once" msgstr "文件路径,注意:整个文件会被全部加载到内存中,不建议生产系统使用。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:218 +#: ../../source/topics/deployment/serving_on_kuscia.rst:222 msgid "PartyConfig.featureSourceConfig.csvOpts.idName" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:218 +#: ../../source/topics/deployment/serving_on_kuscia.rst:222 msgid "" "Id column name, associated with ``FeatureParam::query_datas``. " "``query_datas`` is a subset of id column" msgstr "ID列名称,系统此时认为预测请求中 ``FeatureParam::query_datas`` 的内容为ID数据,将以此进行数据查询。" -#: ../../source/topics/deployment/serving_on_kuscia.rst:220 +#: ../../source/topics/deployment/serving_on_kuscia.rst:224 msgid "PartyConfig.channelDesc" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:220 +#: ../../source/topics/deployment/serving_on_kuscia.rst:224 msgid ":ref:`ChannelDesc `" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:222 +#: ../../source/topics/deployment/serving_on_kuscia.rst:226 msgid "PartyConfig.channelDesc.protocol" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:222 +#: ../../source/topics/deployment/serving_on_kuscia.rst:226 msgid "" "Communication protocol, for optional value, see `here " "`_" @@ -571,14 +580,14 @@ msgstr "" "通信协议,可选值可以参考 `这里 " "`_" -#: ../../source/topics/deployment/serving_on_kuscia.rst:224 +#: ../../source/topics/deployment/serving_on_kuscia.rst:228 msgid "PartyConfig.channelDesc.rpcTimeoutMs" msgstr "" -#: ../../source/topics/deployment/serving_on_kuscia.rst:224 +#: ../../source/topics/deployment/serving_on_kuscia.rst:228 msgid "Max duration of RPC. -1 means wait indefinitely. Default: 2000 (ms)" msgstr "RPC超时时间, -1 即无穷时间。默认值:2000(ms)" -#: ../../source/topics/deployment/serving_on_kuscia.rst:226 +#: ../../source/topics/deployment/serving_on_kuscia.rst:230 msgid "PartyConfig.channelDesc.connectTimeoutMs" msgstr "" diff --git a/docs/source/imgs/sgb_calc.jpg b/docs/source/imgs/sgb_calc.jpg new file mode 100644 index 0000000..a98b81c Binary files /dev/null and b/docs/source/imgs/sgb_calc.jpg differ diff --git a/docs/source/imgs/sgb_calc.png b/docs/source/imgs/sgb_calc.png deleted file mode 100644 index 3403939..0000000 Binary files a/docs/source/imgs/sgb_calc.png and /dev/null differ diff --git a/docs/source/topics/algorithm/intro.rst b/docs/source/topics/algorithm/intro.rst index f9a3157..bfb1e8c 100644 --- a/docs/source/topics/algorithm/intro.rst +++ b/docs/source/topics/algorithm/intro.rst @@ -74,5 +74,5 @@ The TREE_MERGE operator is executed on the party with the weight of the leaf nod Each tree corresponds to a TREE_SELECT operator and a TREE_MERGE operator. The aggregation of multiple trees is completed by TREE_ENSEMBLE_PREDICT, and like the linear model, the results can also be calculated by sigmoid. The calculation method of sigmoid here is consistent with the approximation method used during training. The result of TREE_ENSEMBLE_PREDICT is the prediction result. -.. image:: /imgs/sgb_calc.png +.. image:: /imgs/sgb_calc.jpg :alt: Vertical Tree Model Calculation diff --git a/docs/source/topics/deployment/deployment.rst b/docs/source/topics/deployment/deployment.rst index a43707e..5c42854 100644 --- a/docs/source/topics/deployment/deployment.rst +++ b/docs/source/topics/deployment/deployment.rst @@ -182,6 +182,7 @@ Create a file called ``docker-compose.yaml`` in your workspace and paste the fol * ``__ALICE_PORT__`` is the published port on the host machine which is used for SecretFlow-Serving service to listen on, you need to replace it with an accessible port number. In this case, we have designated it as ``9010`` for ``Alice``, ``9011`` for ``Bob``. * ``trace_config_file`` line is optional. + * You can also use mirrors at Alibaba Cloud: ``secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]`` Step 2: Start Serving Service diff --git a/docs/source/topics/deployment/serving_on_kuscia.rst b/docs/source/topics/deployment/serving_on_kuscia.rst index 5bf9511..5336059 100644 --- a/docs/source/topics/deployment/serving_on_kuscia.rst +++ b/docs/source/topics/deployment/serving_on_kuscia.rst @@ -82,6 +82,10 @@ To deploy SecretFlow-Serving in Kusica, you first need to register the template name: secretflow/serving-anolis8 tag: latest +.. note:: + + You can also use mirrors at Alibaba Cloud: ``secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:latestsecretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/serving-anolis8:[tag]`` + The explanation of the common fields can be found `here `_. Other field explanations are as follows: diff --git a/secretflow_serving/feature_adapter/streaming_adapter.cc b/secretflow_serving/feature_adapter/streaming_adapter.cc index 9612011..7272de6 100644 --- a/secretflow_serving/feature_adapter/streaming_adapter.cc +++ b/secretflow_serving/feature_adapter/streaming_adapter.cc @@ -30,15 +30,6 @@ namespace { const char* kUnSetMagicToken = "__UNSET_MAGIC_TOKEN__"; -void CheckIdsEqual(const FeatureAdapter::Request& request, - const std::shared_ptr& id_array) { - SERVING_ENFORCE_EQ(id_array->length(), request.fs_param->query_datas_size(), - "id_array length mismatch with query_datas_size."); - auto str_array = std::static_pointer_cast(id_array); - for (int i = 0; i < request.fs_param->query_datas_size(); ++i) { - SERVING_ENFORCE_EQ(request.fs_param->query_datas(i), str_array->Value(i)); - } -} } // namespace StreamingAdapter::StreamingAdapter( @@ -46,6 +37,7 @@ StreamingAdapter::StreamingAdapter( const std::string& party_id, const std::shared_ptr& feature_schema) : FeatureAdapter(spec, service_id, party_id, feature_schema), + cur_offset_(0), last_context_token_(kUnSetMagicToken) { SERVING_ENFORCE( FLAGS_inferencer_mode, errors::ErrorCode::LOGIC_ERROR, @@ -84,8 +76,6 @@ void StreamingAdapter::OnFetchFeature(const Request& request, // The retry request attempts to retrieve previously read data, possibly // due to an exception in some other logic. response->features = last_batch_; - CheckIdsEqual(request, response->features->GetColumnByName( - spec_.streaming_opts().id_name())); return; } // cleanup cache @@ -143,8 +133,6 @@ void StreamingAdapter::OnFetchFeature(const Request& request, } else { response->features = std::move(batches[0]); } - CheckIdsEqual(request, response->features->GetColumnByName( - spec_.streaming_opts().id_name())); // cache current result. last_batch_ = response->features; last_context_token_ = request.fs_param->query_context(); diff --git a/secretflow_serving/feature_adapter/streaming_adapter_test.cc b/secretflow_serving/feature_adapter/streaming_adapter_test.cc index b7627f1..8799792 100644 --- a/secretflow_serving/feature_adapter/streaming_adapter_test.cc +++ b/secretflow_serving/feature_adapter/streaming_adapter_test.cc @@ -156,17 +156,6 @@ id,x1,x2,x3,x4 MakeRecordBatch(model_schema_with_id, 1, {x1, x2, x3, x4}); CheckRecordBatchEqual(expect_features, response.features); } - - // exception request - fs_params.clear_query_datas(); - fs_params.add_query_datas("0"); - fs_params.set_query_context("test_contex_1"); - ASSERT_THROW(adapter->FetchFeature(request, &response), Exception); - - fs_params.clear_query_datas(); - fs_params.add_query_datas("3"); - fs_params.set_query_context("test_contex_2"); - ASSERT_THROW(adapter->FetchFeature(request, &response), Exception); } struct StreamingModeParam { @@ -205,14 +194,12 @@ TEST_P(StreamingAdapterStreamingModeTest, Works) { auto req_reader = csv::BuildStreamingReader( tmpfile.fname(), {{"id", arrow::utf8()}}, req_reader_opts); std::shared_ptr batch; - size_t idx = 0; while (true) { - ++idx; SERVING_CHECK_ARROW_STATUS(req_reader->ReadNext(&batch)); if (batch == nullptr) { break; } - std::cout << "req batch length: " << batch->num_rows() << std::endl; + std::cout << "req batch length: " << batch->num_rows() << '\n'; auto id_array = std::static_pointer_cast(batch->column(0)); diff --git a/secretflow_serving/framework/model_info_processor.cc b/secretflow_serving/framework/model_info_processor.cc index 85b5270..cfab830 100644 --- a/secretflow_serving/framework/model_info_processor.cc +++ b/secretflow_serving/framework/model_info_processor.cc @@ -17,6 +17,7 @@ #include #include +#include "fmt/ranges.h" #include "spdlog/spdlog.h" #include "secretflow_serving/core/exception.h" diff --git a/secretflow_serving/ops/graph.cc b/secretflow_serving/ops/graph.cc index 202c74e..24ae4bd 100644 --- a/secretflow_serving/ops/graph.cc +++ b/secretflow_serving/ops/graph.cc @@ -18,6 +18,7 @@ #include #include "fmt/format.h" +#include "fmt/ranges.h" #include "secretflow_serving/ops/op_kernel_factory.h" diff --git a/secretflow_serving/server/main.cc b/secretflow_serving/server/main.cc index a9f0dec..5c6f66d 100644 --- a/secretflow_serving/server/main.cc +++ b/secretflow_serving/server/main.cc @@ -14,6 +14,7 @@ #include "absl/debugging/failure_signal_handler.h" #include "absl/debugging/symbolize.h" +#include "fmt/ranges.h" #include "gflags/gflags.h" #include "secretflow_serving/core/exception.h" diff --git a/secretflow_serving/server/prediction_core.cc b/secretflow_serving/server/prediction_core.cc index e757179..0a8403c 100644 --- a/secretflow_serving/server/prediction_core.cc +++ b/secretflow_serving/server/prediction_core.cc @@ -14,6 +14,7 @@ #include "secretflow_serving/server/prediction_core.h" +#include "fmt/ranges.h" #include "spdlog/spdlog.h" #include "secretflow_serving/util/utils.h" diff --git a/secretflow_serving/source/http_source.cc b/secretflow_serving/source/http_source.cc index 55762e1..7e9b54e 100644 --- a/secretflow_serving/source/http_source.cc +++ b/secretflow_serving/source/http_source.cc @@ -18,6 +18,7 @@ #include "brpc/controller.h" #include "brpc/uri.h" +#include "fmt/ranges.h" #include "spdlog/spdlog.h" #include "yacl/utils/elapsed_timer.h" diff --git a/secretflow_serving/tools/inferencer/README.md b/secretflow_serving/tools/inferencer/README.md index 24010e1..aef881c 100644 --- a/secretflow_serving/tools/inferencer/README.md +++ b/secretflow_serving/tools/inferencer/README.md @@ -5,13 +5,13 @@ ### Alice ```bash -bazel-bin/secretflow_serving/tools/inferencer/inferencer --serving_config_file=secretflow_serving/tools/inferencer/example/alice/serving.config --inference_config_file=secretflow_serving/tools/inferencer/example/alice/inference.config +bazel-bin/secretflow_serving/tools/inferencer/inferencer --serving_config_file=secretflow_serving/tools/inferencer/example/normal/alice/serving.config --inference_config_file=secretflow_serving/tools/inferencer/example/normal/alice/inference.config ``` ### Bob ```bash -bazel-bin/secretflow_serving/tools/inferencer/inferencer --serving_config_file=secretflow_serving/tools/inferencer/example/bob/serving.config --inference_config_file=secretflow_serving/tools/inferencer/example/bob/inference.config +bazel-bin/secretflow_serving/tools/inferencer/inferencer --serving_config_file=secretflow_serving/tools/inferencer/example/normal/bob/serving.config --inference_config_file=secretflow_serving/tools/inferencer/example/normal/bob/inference.config ``` ## Python diff --git a/secretflow_serving/tools/inferencer/control_service_impl.cc b/secretflow_serving/tools/inferencer/control_service_impl.cc index bb27a12..ac0bdcc 100644 --- a/secretflow_serving/tools/inferencer/control_service_impl.cc +++ b/secretflow_serving/tools/inferencer/control_service_impl.cc @@ -24,7 +24,7 @@ namespace secretflow::serving::tools { InferenceControlServiceImpl::InferenceControlServiceImpl( - const std::string& requester_id, int32_t row_num) + const std::string& requester_id, int64_t row_num) : requester_id_(requester_id), row_num_(row_num) {} void InferenceControlServiceImpl::ReadyToServe() { diff --git a/secretflow_serving/tools/inferencer/control_service_impl.h b/secretflow_serving/tools/inferencer/control_service_impl.h index 50322c6..223c6f0 100644 --- a/secretflow_serving/tools/inferencer/control_service_impl.h +++ b/secretflow_serving/tools/inferencer/control_service_impl.h @@ -23,7 +23,7 @@ namespace secretflow::serving::tools { // 预测 - 服务入口 class InferenceControlServiceImpl : public InferenceControlService { public: - InferenceControlServiceImpl(const std::string& requester_id, int32_t row_num); + InferenceControlServiceImpl(const std::string& requester_id, int64_t row_num); void Push(::google::protobuf::RpcController* controller, const ControlRequest* request, ControlResponse* response, @@ -42,7 +42,7 @@ class InferenceControlServiceImpl : public InferenceControlService { const std::string requester_id_; - const int32_t row_num_; + const int64_t row_num_; bool ready_flag_ = false; diff --git a/secretflow_serving/tools/inferencer/example/bob/inference.config b/secretflow_serving/tools/inferencer/example/bob/inference.config deleted file mode 100644 index 8c26014..0000000 --- a/secretflow_serving/tools/inferencer/example/bob/inference.config +++ /dev/null @@ -1,4 +0,0 @@ -{ - "requester_id": "alice", - "score_col_name": "score" -} diff --git a/secretflow_serving/tools/inferencer/example/alice/inference.config b/secretflow_serving/tools/inferencer/example/normal/alice/inference.config similarity index 100% rename from secretflow_serving/tools/inferencer/example/alice/inference.config rename to secretflow_serving/tools/inferencer/example/normal/alice/inference.config diff --git a/secretflow_serving/tools/inferencer/example/normal/alice/serving.config b/secretflow_serving/tools/inferencer/example/normal/alice/serving.config new file mode 100644 index 0000000..ca1069d --- /dev/null +++ b/secretflow_serving/tools/inferencer/example/normal/alice/serving.config @@ -0,0 +1,43 @@ +{ + "id": "test_service_id", + "serverConf": { + "host": "0.0.0.0", + "communicationPort": "8110", + }, + "modelConf": { + "modelId": "glm-test-1", + "basePath": "./tmp/alice", + "sourcePath": ".ci/test_data/bin_onehot_glm/alice/s_model.tar.gz", + "sourceType": "ST_FILE" + }, + "clusterConf": { + "selfId": "alice", + "parties": [ + { + "id": "alice", + "address": "0.0.0.0:8110" + }, + { + "id": "bob", + "address": "0.0.0.0:8111" + } + ], + "channel_desc": { + "protocol": "http", + "retryPolicyConfig": { + "retryCustom": "true", + "retryAggressive": "true", + "maxRetryCount": "3", + "fixedBackoffConfig": { + "intervalMs": "100" + }, + } + } + }, + "featureSourceConf": { + "streamingOpts": { + "file_path": ".ci/test_data/bin_onehot_glm/alice/alice.csv", + "id_name": "id", + } + } +} diff --git a/secretflow_serving/tools/inferencer/example/normal/bob/inference.config b/secretflow_serving/tools/inferencer/example/normal/bob/inference.config new file mode 100644 index 0000000..7f75166 --- /dev/null +++ b/secretflow_serving/tools/inferencer/example/normal/bob/inference.config @@ -0,0 +1,8 @@ +{ + "requester_id": "alice", + "result_file_path": "./tmp/bob/score.csv", + "score_col_name": "score", + "additional_col_names": [ + "b2" + ], +} diff --git a/secretflow_serving/tools/inferencer/example/normal/bob/serving.config b/secretflow_serving/tools/inferencer/example/normal/bob/serving.config new file mode 100644 index 0000000..2b30ef2 --- /dev/null +++ b/secretflow_serving/tools/inferencer/example/normal/bob/serving.config @@ -0,0 +1,43 @@ +{ + "id": "test_service_id", + "serverConf": { + "host": "0.0.0.0", + "communicationPort": "8111", + }, + "modelConf": { + "modelId": "glm-test-1", + "basePath": "./tmp/bob", + "sourcePath": ".ci/test_data/bin_onehot_glm/bob/s_model.tar.gz", + "sourceType": "ST_FILE" + }, + "clusterConf": { + "selfId": "bob", + "parties": [ + { + "id": "alice", + "address": "0.0.0.0:8110" + }, + { + "id": "bob", + "address": "0.0.0.0:8111" + } + ], + "channel_desc": { + "protocol": "http", + "retryPolicyConfig": { + "retryCustom": "true", + "retryAggressive": "true", + "maxRetryCount": "3", + "fixedBackoffConfig": { + "intervalMs": "100" + }, + } + } + }, + "featureSourceConf": { + "streamingOpts": { + "file_path": ".ci/test_data/bin_onehot_glm/bob/bob.csv", + "id_name": "id", + } + } +} diff --git a/secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/inference.config b/secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/inference.config new file mode 100644 index 0000000..d8e6eb7 --- /dev/null +++ b/secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/inference.config @@ -0,0 +1,8 @@ +{ + "requester_id": "bob", + "result_file_path": "./tmp/alice/score.csv", + "additional_col_names": [ + "y" + ], + "score_col_name": "score" +} diff --git a/secretflow_serving/tools/inferencer/example/alice/serving.config b/secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/serving.config similarity index 85% rename from secretflow_serving/tools/inferencer/example/alice/serving.config rename to secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/serving.config index 6f16208..03d3637 100644 --- a/secretflow_serving/tools/inferencer/example/alice/serving.config +++ b/secretflow_serving/tools/inferencer/example/one_party_no_feature/alice/serving.config @@ -35,9 +35,6 @@ } }, "featureSourceConf": { - "streamingOpts": { - "file_path": ".ci/test_data/bin_onehot_glm_alice_no_feature/alice/alice.csv", - "id_name": "id", - } + "mockOpts": {} } } diff --git a/secretflow_serving/tools/inferencer/example/one_party_no_feature/bob/inference.config b/secretflow_serving/tools/inferencer/example/one_party_no_feature/bob/inference.config new file mode 100644 index 0000000..d6268bf --- /dev/null +++ b/secretflow_serving/tools/inferencer/example/one_party_no_feature/bob/inference.config @@ -0,0 +1,8 @@ +{ + "requester_id": "bob", + "score_col_name": "score", + "result_file_path": "./tmp/bob/score.csv", + "additional_col_names": [ + "b2" + ], +} diff --git a/secretflow_serving/tools/inferencer/example/bob/serving.config b/secretflow_serving/tools/inferencer/example/one_party_no_feature/bob/serving.config similarity index 100% rename from secretflow_serving/tools/inferencer/example/bob/serving.config rename to secretflow_serving/tools/inferencer/example/one_party_no_feature/bob/serving.config diff --git a/secretflow_serving/tools/inferencer/inference_executor.cc b/secretflow_serving/tools/inferencer/inference_executor.cc index 71ff188..279e219 100644 --- a/secretflow_serving/tools/inferencer/inference_executor.cc +++ b/secretflow_serving/tools/inferencer/inference_executor.cc @@ -16,6 +16,7 @@ #include +#include "fmt/ranges.h" #include "spdlog/spdlog.h" #include "secretflow_serving/tools/inferencer/control_service_impl.h" @@ -39,6 +40,8 @@ const size_t kSendRetryIntervalMs = 1000; const size_t kHeartBeatCheckIntervalMs = 3000; const size_t kHeartBeatCheckFailedNum = 10; +const int64_t kRequestBatchNum = 500; + } // namespace namespace { @@ -65,11 +68,15 @@ InferenceExecutor::InferenceExecutor(Options opts) : opts_(std::move(opts)) { // TODO: check config valiable SERVING_ENFORCE(opts_.serving_conf.has_feature_source_conf(), errors::INVALID_ARGUMENT); - SERVING_ENFORCE(opts_.serving_conf.feature_source_conf().has_streaming_opts(), - errors::INVALID_ARGUMENT); - - row_num_ = GetCsvFileRowNum( - opts_.serving_conf.feature_source_conf().streaming_opts().file_path()); + SERVING_ENFORCE( + opts_.serving_conf.feature_source_conf().has_streaming_opts() || + opts_.serving_conf.feature_source_conf().has_mock_opts(), + errors::INVALID_ARGUMENT); + + if (opts_.serving_conf.feature_source_conf().has_streaming_opts()) { + row_num_ = GetCsvFileRowNum( + opts_.serving_conf.feature_source_conf().streaming_opts().file_path()); + } channels_ = BuildChannelsFromConfig(opts_.serving_conf.cluster_conf()); @@ -131,8 +138,9 @@ void InferenceExecutor::OnRun() { } // init other party + int64_t compute_row_num = -1; RetryRunner runner(kSendRetryCount, kSendRetryIntervalMs); - std::vector row_num_list; + std::vector row_num_list; for (const auto& [p, c] : *channels_) { ControlResponse res; SERVING_ENFORCE(runner.Run( @@ -147,23 +155,59 @@ void InferenceExecutor::OnRun() { "send init msg to {} failed.", p); row_num_list.emplace_back(res.init_msg().row_num()); } - SERVING_ENFORCE(std::all_of(row_num_list.begin(), row_num_list.end(), - [this](auto e) { return e == row_num_; }), - errors::UNEXPECTED_ERROR, - "The number of input file lines of different participants " - "does not match. {} vs {}", - row_num_, - fmt::join(row_num_list.begin(), row_num_list.end(), ",")); + if (row_num_ > 0) { + // mock feature source no need check row num (row_num < 0) + compute_row_num = row_num_; + SERVING_ENFORCE( + std::all_of(row_num_list.begin(), row_num_list.end(), + [this](auto e) { return e < 0 || e == row_num_; }), + errors::UNEXPECTED_ERROR, + "The number of input file lines of different participants " + "does not match. {} vs {}", + row_num_, fmt::join(row_num_list.begin(), row_num_list.end(), ",")); + } else { + // do not allow all parties to use mock features + size_t count = 0; + std::for_each(row_num_list.begin(), row_num_list.end(), [&](auto e) { + if (e < 0) { + ++count; + } + if (compute_row_num > 0) { + SERVING_ENFORCE_EQ( + compute_row_num, e, + "The number of input file lines of different participants " + "does not match. {} vs {}", + compute_row_num, + fmt::join(row_num_list.begin(), row_num_list.end(), ",")); + } else { + compute_row_num = e; + } + }); + SERVING_ENFORCE_NE(count, row_num_list.size(), + "all parties use mock features is not allowed."); + } + SERVING_ENFORCE_GT(compute_row_num, 0); // start keepalive keepalive_thread_ = std::thread(&InferenceExecutor::KeepAlive, this); - // build read colums types - std::unordered_map> col_types{ - {opts_.serving_conf.feature_source_conf().streaming_opts().id_name(), - arrow::utf8()}}; - for (const auto& c : opts_.inference_conf.additional_col_names()) { - col_types.emplace(c, arrow::utf8()); + // build csv reader + std::shared_ptr csv_reader; + std::unordered_map> col_types; + if (row_num_ > 0) { + arrow::csv::ReadOptions read_opts = arrow::csv::ReadOptions::Defaults(); + if (opts_.inference_conf.block_size() > 0) { + read_opts.block_size = opts_.inference_conf.block_size(); + } + col_types.emplace( + opts_.serving_conf.feature_source_conf().streaming_opts().id_name(), + arrow::utf8()); + for (const auto& c : opts_.inference_conf.additional_col_names()) { + col_types.emplace(c, arrow::utf8()); + } + csv_reader = csv::BuildStreamingReader( + opts_.serving_conf.feature_source_conf().streaming_opts().file_path(), + col_types, read_opts); } // build output schema @@ -177,16 +221,6 @@ void InferenceExecutor::OnRun() { output_schema = arrow::schema(std::move(fields)); } - // csv reader - arrow::csv::ReadOptions read_opts = arrow::csv::ReadOptions::Defaults(); - if (opts_.inference_conf.block_size() > 0) { - read_opts.block_size = opts_.inference_conf.block_size(); - } - std::shared_ptr csv_reader = - csv::BuildStreamingReader( - opts_.serving_conf.feature_source_conf().streaming_opts().file_path(), - std::move(col_types), read_opts); - // build result writer std::shared_ptr csv_writer = csv::BuildeStreamingWriter(opts_.inference_conf.result_file_path(), @@ -200,32 +234,30 @@ void InferenceExecutor::OnRun() { for (const auto& [p, c] : *channels_) { fs_params->insert({p, {}}); } - int32_t idx = 0; + int64_t idx = 0; std::shared_ptr batch; - while (true) { - ++idx; - SERVING_CHECK_ARROW_STATUS(csv_reader->ReadNext(&batch)); - if (!batch) { - // read finish - break; + while (idx < compute_row_num) { + auto request_num = std::min(compute_row_num - idx, kRequestBatchNum); + if (csv_reader) { + SERVING_CHECK_ARROW_STATUS(csv_reader->ReadNext(&batch)); + if (!batch) { + // read finish + break; + } + SERVING_ENFORCE_GT( + batch->num_rows(), 0, + "may be because `block_size` is configured too small: {}", + opts_.inference_conf.block_size()); + request_num = batch->num_rows(); } - SERVING_ENFORCE_GT( - batch->num_rows(), 0, - "may be because `block_size` is configured too small: {}", - opts_.inference_conf.block_size()); - - auto id_array = std::static_pointer_cast( - batch->GetColumnByName(opts_.serving_conf.feature_source_conf() - .streaming_opts() - .id_name())); + auto request_num_str = std::to_string(request_num); // build fs_params for (auto& [party, param] : *fs_params) { param.clear_query_datas(); param.set_query_context(std::to_string(idx)); - for (int64_t i = 0; i < id_array->length(); ++i) { - auto item = id_array->Value(i); - param.add_query_datas(item.data(), item.length()); + for (int64_t i = 0; i < request_num; ++i) { + param.add_query_datas(request_num_str); } } @@ -243,18 +275,22 @@ void InferenceExecutor::OnRun() { SERVING_CHECK_ARROW_STATUS(builder.Finish(&score_array)); // write result - std::vector> arrays; + std::vector> arrays{std::move(score_array)}; arrays.reserve(output_schema->num_fields()); - for (const auto& f : output_schema->fields()) { - if (f->name() == opts_.inference_conf.score_col_name()) { - arrays.emplace_back(std::move(score_array)); - continue; + if (batch) { + for (const auto& f : output_schema->fields()) { + if (f->name() == opts_.inference_conf.score_col_name()) { + continue; + } + arrays.emplace_back(batch->GetColumnByName(f->name())); } - arrays.emplace_back(batch->GetColumnByName(f->name())); } + auto result_batch = MakeRecordBatch( output_schema, pred_response.results_size(), std::move(arrays)); SERVING_CHECK_ARROW_STATUS(csv_writer->WriteRecordBatch(*result_batch)); + + idx += request_num; } SERVING_CHECK_ARROW_STATUS(csv_writer->Close()); diff --git a/secretflow_serving/tools/inferencer/inference_executor.h b/secretflow_serving/tools/inferencer/inference_executor.h index 5488ba8..0f580f7 100644 --- a/secretflow_serving/tools/inferencer/inference_executor.h +++ b/secretflow_serving/tools/inferencer/inference_executor.h @@ -66,7 +66,7 @@ class InferenceExecutor { std::shared_ptr prediction_core_; - int32_t row_num_; + int64_t row_num_ = -1; std::thread keepalive_thread_; diff --git a/secretflow_serving/util/arrow_helper.cc b/secretflow_serving/util/arrow_helper.cc index ba80aca..da767e2 100644 --- a/secretflow_serving/util/arrow_helper.cc +++ b/secretflow_serving/util/arrow_helper.cc @@ -21,6 +21,7 @@ #include "arrow/compute/api.h" #include "arrow/io/api.h" #include "arrow/ipc/api.h" +#include "fmt/ranges.h" #include "secretflow_serving/core/exception.h" #include "secretflow_serving/util/utils.h" diff --git a/secretflow_serving/util/csv_extractor.cc b/secretflow_serving/util/csv_extractor.cc index b4b499a..806f84f 100644 --- a/secretflow_serving/util/csv_extractor.cc +++ b/secretflow_serving/util/csv_extractor.cc @@ -23,6 +23,7 @@ #include #include "arrow/compute/api.h" +#include "fmt/ranges.h" #include "spdlog/spdlog.h" #include "secretflow_serving/core/exception.h"