From 8b30782c4f0cee21ab36bdb6fa701a2fd6004d57 Mon Sep 17 00:00:00 2001 From: diann <55k@outlook.com> Date: Wed, 9 Jul 2025 15:50:35 +0800 Subject: [PATCH 1/6] docker: add cann build pipline --- .devops/cann.Dockerfile | 137 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .devops/cann.Dockerfile diff --git a/.devops/cann.Dockerfile b/.devops/cann.Dockerfile new file mode 100644 index 0000000000000..bfd320854506e --- /dev/null +++ b/.devops/cann.Dockerfile @@ -0,0 +1,137 @@ +# ============================================================================== +# ARGUMENTS +# ============================================================================== + +# 定义CANN基础镜像,方便后续统一更新版本 +ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.1.rc1-910b-openeuler22.03-py3.10 + + +# ============================================================================== +# BUILD STAGE +# 编译所有二进制文件和库 +# ============================================================================== +FROM ${CANN_BASE_IMAGE} AS build + +# 定义昇腾芯片型号,用于编译。默认为 Ascend910B3 +ARG ASCEND_SOC_TYPE=Ascend910B3 + +# -- 安装构建依赖 -- +RUN yum install -y gcc g++ cmake make git libcurl-devel python3 python3-pip && \ + yum clean all && \ + rm -rf /var/cache/yum + +# -- 设置工作目录 -- +WORKDIR /app + +# -- 拷贝项目文件 -- +COPY . . + +# -- 设置CANN环境变量 (编译时需要) -- +# 相比于 `source`,使用 ENV 可以让环境变量在整个镜像层中持久生效 +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH +# ... 您可以根据需要添加原始文件中其他的环境变量 ... +# 为了简洁,这里只列出核心变量,您可以将原始的ENV列表粘贴于此 + +# -- 编译 llama.cpp -- +# 使用传入的 ASCEND_SOC_TYPE 参数,并增加通用编译选项 +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \ + && \ + cmake -B build \ + -DGGML_CANN=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSOC_TYPE=${ASCEND_SOC_TYPE} \ + . && \ + cmake --build build --config Release -j$(nproc) + +# -- 整理编译产物,方便后续阶段拷贝 -- +# 创建一个lib目录存放所有.so文件 +RUN mkdir -p /app/lib && \ + find build -name "*.so" -exec cp {} /app/lib \; + +# 创建一个full目录存放所有可执行文件和Python脚本 +RUN mkdir -p /app/full && \ + cp build/bin/* /app/full/ && \ + cp *.py /app/full/ && \ + cp -r gguf-py /app/full/ && \ + cp -r requirements /app/full/ && \ + cp requirements.txt /app/full/ + # 如果您有 tools.sh 脚本,也请确保它在此处被拷贝 + # cp .devops/tools.sh /app/full/tools.sh + + +# ============================================================================== +# BASE STAGE +# 创建一个包含CANN运行时和通用库的最小基础镜像 +# ============================================================================== +FROM ${CANN_BASE_IMAGE} AS base + +# -- 安装运行时依赖 -- +RUN yum install -y libgomp curl && \ + yum clean all && \ + rm -rf /var/cache/yum + +# -- 设置CANN环境变量 (运行时需要) -- +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=/app:${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +# ... 您可以根据需要添加原始文件中其他的环境变量 ... + +WORKDIR /app + +# 从build阶段拷贝编译好的.so文件 +COPY --from=build /app/lib/ /app + + +# ============================================================================== +# FINAL STAGES (TARGETS) +# ============================================================================== + +### Target: full +# 包含所有工具、Python绑定和依赖的完整镜像 +# ============================================================================== +FROM base AS full + +COPY --from=build /app/full /app + +# 安装Python依赖 +RUN yum install -y git python3 python3-pip && \ + pip3 install --no-cache-dir --upgrade pip setuptools wheel && \ + pip3 install --no-cache-dir -r requirements.txt && \ + yum clean all && \ + rm -rf /var/cache/yum + +# 您需要提供一个 tools.sh 脚本作为入口点 +ENTRYPOINT ["/app/tools.sh"] +# 如果没有 tools.sh,可以设置默认启动 server +# ENTRYPOINT ["/app/llama-server"] + + +### Target: light +# 仅包含 llama-cli 的轻量级镜像 +# ============================================================================== +FROM base AS light + +COPY --from=build /app/full/llama-cli /app + + +ENTRYPOINT [ "/app/llama-cli" ] + + +### Target: server +# 仅包含 llama-server 的专用服务器镜像 +# ============================================================================== +FROM base AS server + +ENV LLAMA_ARG_HOST=0.0.0.0 + +COPY --from=build /app/full/llama-server /app + + +HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ] + +ENTRYPOINT [ "/app/llama-server" ] \ No newline at end of file From 24ff4839d58841d25fe1021bc2011850cd655bdc Mon Sep 17 00:00:00 2001 From: diann <55k@outlook.com> Date: Wed, 9 Jul 2025 15:55:28 +0800 Subject: [PATCH 2/6] docker: add cann build pipline --- .devops/cann.Dockerfile | 63 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/.devops/cann.Dockerfile b/.devops/cann.Dockerfile index bfd320854506e..e6afe4ccbb49e 100644 --- a/.devops/cann.Dockerfile +++ b/.devops/cann.Dockerfile @@ -2,42 +2,41 @@ # ARGUMENTS # ============================================================================== -# 定义CANN基础镜像,方便后续统一更新版本 +# Define the CANN base image for easier version updates later ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.1.rc1-910b-openeuler22.03-py3.10 - # ============================================================================== # BUILD STAGE -# 编译所有二进制文件和库 +# Compile all binary files and libraries # ============================================================================== FROM ${CANN_BASE_IMAGE} AS build -# 定义昇腾芯片型号,用于编译。默认为 Ascend910B3 +# Define the Ascend chip model for compilation. Default is Ascend910B3 ARG ASCEND_SOC_TYPE=Ascend910B3 -# -- 安装构建依赖 -- +# -- Install build dependencies -- RUN yum install -y gcc g++ cmake make git libcurl-devel python3 python3-pip && \ yum clean all && \ rm -rf /var/cache/yum -# -- 设置工作目录 -- +# -- Set the working directory -- WORKDIR /app -# -- 拷贝项目文件 -- +# -- Copy project files -- COPY . . -# -- 设置CANN环境变量 (编译时需要) -- -# 相比于 `source`,使用 ENV 可以让环境变量在整个镜像层中持久生效 +# -- Set CANN environment variables (required for compilation) -- +# Using ENV instead of `source` allows environment variables to persist across the entire image layer ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH -# ... 您可以根据需要添加原始文件中其他的环境变量 ... -# 为了简洁,这里只列出核心变量,您可以将原始的ENV列表粘贴于此 +# ... You can add other environment variables from the original file as needed ... +# For brevity, only core variables are listed here. You can paste the original ENV list here. -# -- 编译 llama.cpp -- -# 使用传入的 ASCEND_SOC_TYPE 参数,并增加通用编译选项 +# -- Build llama.cpp -- +# Use the passed ASCEND_SOC_TYPE argument and add general build options RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \ && \ cmake -B build \ @@ -47,83 +46,78 @@ RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \ . && \ cmake --build build --config Release -j$(nproc) -# -- 整理编译产物,方便后续阶段拷贝 -- -# 创建一个lib目录存放所有.so文件 +# -- Organize build artifacts for copying in later stages -- +# Create a lib directory to store all .so files RUN mkdir -p /app/lib && \ find build -name "*.so" -exec cp {} /app/lib \; -# 创建一个full目录存放所有可执行文件和Python脚本 +# Create a full directory to store all executables and Python scripts RUN mkdir -p /app/full && \ cp build/bin/* /app/full/ && \ cp *.py /app/full/ && \ cp -r gguf-py /app/full/ && \ cp -r requirements /app/full/ && \ cp requirements.txt /app/full/ - # 如果您有 tools.sh 脚本,也请确保它在此处被拷贝 + # If you have a tools.sh script, make sure it is copied here # cp .devops/tools.sh /app/full/tools.sh - # ============================================================================== # BASE STAGE -# 创建一个包含CANN运行时和通用库的最小基础镜像 +# Create a minimal base image with CANN runtime and common libraries # ============================================================================== FROM ${CANN_BASE_IMAGE} AS base -# -- 安装运行时依赖 -- +# -- Install runtime dependencies -- RUN yum install -y libgomp curl && \ yum clean all && \ rm -rf /var/cache/yum -# -- 设置CANN环境变量 (运行时需要) -- +# -- Set CANN environment variables (required for runtime) -- ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest ENV LD_LIBRARY_PATH=/app:${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp -# ... 您可以根据需要添加原始文件中其他的环境变量 ... +# ... You can add other environment variables from the original file as needed ... WORKDIR /app -# 从build阶段拷贝编译好的.so文件 +# Copy compiled .so files from the build stage COPY --from=build /app/lib/ /app - # ============================================================================== # FINAL STAGES (TARGETS) # ============================================================================== ### Target: full -# 包含所有工具、Python绑定和依赖的完整镜像 +# Complete image with all tools, Python bindings, and dependencies # ============================================================================== FROM base AS full COPY --from=build /app/full /app -# 安装Python依赖 +# Install Python dependencies RUN yum install -y git python3 python3-pip && \ pip3 install --no-cache-dir --upgrade pip setuptools wheel && \ pip3 install --no-cache-dir -r requirements.txt && \ yum clean all && \ rm -rf /var/cache/yum -# 您需要提供一个 tools.sh 脚本作为入口点 +# You need to provide a tools.sh script as the entrypoint ENTRYPOINT ["/app/tools.sh"] -# 如果没有 tools.sh,可以设置默认启动 server +# If there is no tools.sh, you can set the default to start the server # ENTRYPOINT ["/app/llama-server"] - ### Target: light -# 仅包含 llama-cli 的轻量级镜像 +# Lightweight image containing only llama-cli # ============================================================================== FROM base AS light COPY --from=build /app/full/llama-cli /app - ENTRYPOINT [ "/app/llama-cli" ] - ### Target: server -# 仅包含 llama-server 的专用服务器镜像 +# Dedicated server image containing only llama-server # ============================================================================== FROM base AS server @@ -131,7 +125,6 @@ ENV LLAMA_ARG_HOST=0.0.0.0 COPY --from=build /app/full/llama-server /app - HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ] -ENTRYPOINT [ "/app/llama-server" ] \ No newline at end of file +ENTRYPOINT [ "/app/llama-server" ] From 1b752dad387fbc4c4edb88d70b4ba77537c07098 Mon Sep 17 00:00:00 2001 From: diann <55k@outlook.com> Date: Thu, 10 Jul 2025 15:34:12 +0800 Subject: [PATCH 3/6] docker: fix cann devops --- .devops/cann.Dockerfile | 260 ++++++++++++++++++++-------------------- 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/.devops/cann.Dockerfile b/.devops/cann.Dockerfile index e6afe4ccbb49e..1cd7c70005893 100644 --- a/.devops/cann.Dockerfile +++ b/.devops/cann.Dockerfile @@ -1,130 +1,130 @@ -# ============================================================================== -# ARGUMENTS -# ============================================================================== - -# Define the CANN base image for easier version updates later -ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.1.rc1-910b-openeuler22.03-py3.10 - -# ============================================================================== -# BUILD STAGE -# Compile all binary files and libraries -# ============================================================================== -FROM ${CANN_BASE_IMAGE} AS build - -# Define the Ascend chip model for compilation. Default is Ascend910B3 -ARG ASCEND_SOC_TYPE=Ascend910B3 - -# -- Install build dependencies -- -RUN yum install -y gcc g++ cmake make git libcurl-devel python3 python3-pip && \ - yum clean all && \ - rm -rf /var/cache/yum - -# -- Set the working directory -- -WORKDIR /app - -# -- Copy project files -- -COPY . . - -# -- Set CANN environment variables (required for compilation) -- -# Using ENV instead of `source` allows environment variables to persist across the entire image layer -ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest -ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} -ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} -ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp -ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH -# ... You can add other environment variables from the original file as needed ... -# For brevity, only core variables are listed here. You can paste the original ENV list here. - -# -- Build llama.cpp -- -# Use the passed ASCEND_SOC_TYPE argument and add general build options -RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \ - && \ - cmake -B build \ - -DGGML_CANN=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DSOC_TYPE=${ASCEND_SOC_TYPE} \ - . && \ - cmake --build build --config Release -j$(nproc) - -# -- Organize build artifacts for copying in later stages -- -# Create a lib directory to store all .so files -RUN mkdir -p /app/lib && \ - find build -name "*.so" -exec cp {} /app/lib \; - -# Create a full directory to store all executables and Python scripts -RUN mkdir -p /app/full && \ - cp build/bin/* /app/full/ && \ - cp *.py /app/full/ && \ - cp -r gguf-py /app/full/ && \ - cp -r requirements /app/full/ && \ - cp requirements.txt /app/full/ - # If you have a tools.sh script, make sure it is copied here - # cp .devops/tools.sh /app/full/tools.sh - -# ============================================================================== -# BASE STAGE -# Create a minimal base image with CANN runtime and common libraries -# ============================================================================== -FROM ${CANN_BASE_IMAGE} AS base - -# -- Install runtime dependencies -- -RUN yum install -y libgomp curl && \ - yum clean all && \ - rm -rf /var/cache/yum - -# -- Set CANN environment variables (required for runtime) -- -ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest -ENV LD_LIBRARY_PATH=/app:${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} -ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} -ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp -# ... You can add other environment variables from the original file as needed ... - -WORKDIR /app - -# Copy compiled .so files from the build stage -COPY --from=build /app/lib/ /app - -# ============================================================================== -# FINAL STAGES (TARGETS) -# ============================================================================== - -### Target: full -# Complete image with all tools, Python bindings, and dependencies -# ============================================================================== -FROM base AS full - -COPY --from=build /app/full /app - -# Install Python dependencies -RUN yum install -y git python3 python3-pip && \ - pip3 install --no-cache-dir --upgrade pip setuptools wheel && \ - pip3 install --no-cache-dir -r requirements.txt && \ - yum clean all && \ - rm -rf /var/cache/yum - -# You need to provide a tools.sh script as the entrypoint -ENTRYPOINT ["/app/tools.sh"] -# If there is no tools.sh, you can set the default to start the server -# ENTRYPOINT ["/app/llama-server"] - -### Target: light -# Lightweight image containing only llama-cli -# ============================================================================== -FROM base AS light - -COPY --from=build /app/full/llama-cli /app - -ENTRYPOINT [ "/app/llama-cli" ] - -### Target: server -# Dedicated server image containing only llama-server -# ============================================================================== -FROM base AS server - -ENV LLAMA_ARG_HOST=0.0.0.0 - -COPY --from=build /app/full/llama-server /app - -HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ] - -ENTRYPOINT [ "/app/llama-server" ] +# ============================================================================== +# ARGUMENTS +# ============================================================================== + +# Define the CANN base image for easier version updates later +ARG CANN_BASE_IMAGE=quay.io/ascend/cann:8.1.rc1-910b-openeuler22.03-py3.10 + +# ============================================================================== +# BUILD STAGE +# Compile all binary files and libraries +# ============================================================================== +FROM ${CANN_BASE_IMAGE} AS build + +# Define the Ascend chip model for compilation. Default is Ascend910B3 +ARG ASCEND_SOC_TYPE=Ascend910B3 + +# -- Install build dependencies -- +RUN yum install -y gcc g++ cmake make git libcurl-devel python3 python3-pip && \ + yum clean all && \ + rm -rf /var/cache/yum + +# -- Set the working directory -- +WORKDIR /app + +# -- Copy project files -- +COPY . . + +# -- Set CANN environment variables (required for compilation) -- +# Using ENV instead of `source` allows environment variables to persist across the entire image layer +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/runtime/lib64/stub:$LD_LIBRARY_PATH +# ... You can add other environment variables from the original file as needed ... +# For brevity, only core variables are listed here. You can paste the original ENV list here. + +# -- Build llama.cpp -- +# Use the passed ASCEND_SOC_TYPE argument and add general build options +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh --force \ + && \ + cmake -B build \ + -DGGML_CANN=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSOC_TYPE=${ASCEND_SOC_TYPE} \ + . && \ + cmake --build build --config Release -j$(nproc) + +# -- Organize build artifacts for copying in later stages -- +# Create a lib directory to store all .so files +RUN mkdir -p /app/lib && \ + find build -name "*.so" -exec cp {} /app/lib \; + +# Create a full directory to store all executables and Python scripts +RUN mkdir -p /app/full && \ + cp build/bin/* /app/full/ && \ + cp *.py /app/full/ && \ + cp -r gguf-py /app/full/ && \ + cp -r requirements /app/full/ && \ + cp requirements.txt /app/full/ + # If you have a tools.sh script, make sure it is copied here + # cp .devops/tools.sh /app/full/tools.sh + +# ============================================================================== +# BASE STAGE +# Create a minimal base image with CANN runtime and common libraries +# ============================================================================== +FROM ${CANN_BASE_IMAGE} AS base + +# -- Install runtime dependencies -- +RUN yum install -y libgomp curl && \ + yum clean all && \ + rm -rf /var/cache/yum + +# -- Set CANN environment variables (required for runtime) -- +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=/app:${ASCEND_TOOLKIT_HOME}/lib64:${LD_LIBRARY_PATH} +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${PATH} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +# ... You can add other environment variables from the original file as needed ... + +WORKDIR /app + +# Copy compiled .so files from the build stage +COPY --from=build /app/lib/ /app + +# ============================================================================== +# FINAL STAGES (TARGETS) +# ============================================================================== + +### Target: full +# Complete image with all tools, Python bindings, and dependencies +# ============================================================================== +FROM base AS full + +COPY --from=build /app/full /app + +# Install Python dependencies +RUN yum install -y git python3 python3-pip && \ + pip3 install --no-cache-dir --upgrade pip setuptools wheel && \ + pip3 install --no-cache-dir -r requirements.txt && \ + yum clean all && \ + rm -rf /var/cache/yum + +# You need to provide a tools.sh script as the entrypoint +ENTRYPOINT ["/app/tools.sh"] +# If there is no tools.sh, you can set the default to start the server +# ENTRYPOINT ["/app/llama-server"] + +### Target: light +# Lightweight image containing only llama-cli +# ============================================================================== +FROM base AS light + +COPY --from=build /app/full/llama-cli /app + +ENTRYPOINT [ "/app/llama-cli" ] + +### Target: server +# Dedicated server image containing only llama-server +# ============================================================================== +FROM base AS server + +ENV LLAMA_ARG_HOST=0.0.0.0 + +COPY --from=build /app/full/llama-server /app + +HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ] + +ENTRYPOINT [ "/app/llama-server" ] From 06cad0bcc269744ce9b3404fe068e6f9f6cdd8ff Mon Sep 17 00:00:00 2001 From: diann <55k@outlook.com> Date: Tue, 15 Jul 2025 15:37:52 +0800 Subject: [PATCH 4/6] cann : fix multi card hccl --- .devops/cann.Dockerfile | 2 +- ggml/src/ggml-cann/ggml-cann.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.devops/cann.Dockerfile b/.devops/cann.Dockerfile index 1cd7c70005893..02f3e03b5e2ea 100644 --- a/.devops/cann.Dockerfile +++ b/.devops/cann.Dockerfile @@ -125,6 +125,6 @@ ENV LLAMA_ARG_HOST=0.0.0.0 COPY --from=build /app/full/llama-server /app -HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ] +HEALTHCHECK --interval=5m CMD [ "curl", "-f", "http://localhost:8080/health" ] ENTRYPOINT [ "/app/llama-server" ] diff --git a/ggml/src/ggml-cann/ggml-cann.cpp b/ggml/src/ggml-cann/ggml-cann.cpp index eae575cc040cd..05fe7239bdd7e 100755 --- a/ggml/src/ggml-cann/ggml-cann.cpp +++ b/ggml/src/ggml-cann/ggml-cann.cpp @@ -1911,6 +1911,9 @@ static bool ggml_backend_cann_cpy_tensor_async( (ggml_backend_cann_context*)backend_dst->context; size_t copy_size = ggml_nbytes(dst); + if (copy_size==0){ + return true; + } if (backend_src != backend_dst) { ggml_backend_cann_buffer_context* buf_ctx_src = (ggml_backend_cann_buffer_context*)buf_src->context; From 48384b686e15670395363ab799ff1e0ee91ea394 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 17 Jul 2025 08:09:35 +0300 Subject: [PATCH 5/6] Update ggml/src/ggml-cann/ggml-cann.cpp Co-authored-by: Xuan-Son Nguyen --- ggml/src/ggml-cann/ggml-cann.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-cann/ggml-cann.cpp b/ggml/src/ggml-cann/ggml-cann.cpp index 05fe7239bdd7e..cd50efa70ead0 100755 --- a/ggml/src/ggml-cann/ggml-cann.cpp +++ b/ggml/src/ggml-cann/ggml-cann.cpp @@ -1911,7 +1911,7 @@ static bool ggml_backend_cann_cpy_tensor_async( (ggml_backend_cann_context*)backend_dst->context; size_t copy_size = ggml_nbytes(dst); - if (copy_size==0){ + if (copy_size == 0) { return true; } if (backend_src != backend_dst) { From 2c60d3865d4b40161476fb1a922e9a681b8a0e15 Mon Sep 17 00:00:00 2001 From: diannao <55k@outlook.com> Date: Thu, 31 Jul 2025 11:27:23 +0800 Subject: [PATCH 6/6] Update ggml-cann.cpp --- ggml/src/ggml-cann/ggml-cann.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-cann/ggml-cann.cpp b/ggml/src/ggml-cann/ggml-cann.cpp index cd50efa70ead0..bede4165b61dc 100755 --- a/ggml/src/ggml-cann/ggml-cann.cpp +++ b/ggml/src/ggml-cann/ggml-cann.cpp @@ -1912,7 +1912,7 @@ static bool ggml_backend_cann_cpy_tensor_async( size_t copy_size = ggml_nbytes(dst); if (copy_size == 0) { - return true; + return true; } if (backend_src != backend_dst) { ggml_backend_cann_buffer_context* buf_ctx_src =