Merged
[feat]: Add HIXL Engine Python binding and whl packaging #658
LuoYangyangAdd on Jun 22
[feat]: Add HIXL Engine Python binding and whl packaging #658
Merged
LuoYangyangAdd on Jun 22
Total: 20 files changed+1575-8
@@ -19,6 +19,7 @@ hixl:
19 - src/python/llm_wrapper/llm_datadist_v2_wrapper.cc19 - src/python/llm_wrapper/llm_datadist_v2_wrapper.cc
20 - src/python/metadef_wrapper/metadef_wrapper.cc20 - src/python/metadef_wrapper/metadef_wrapper.cc
21 - src/llm_datadist/llm_error_codes.cc21 - src/llm_datadist/llm_error_codes.cc
22+ - src/python/hixl_py/hixl_py.cc
22 llt:23 llt:
23 ut_check: true24 ut_check: true
24 st_check: false25 st_check: false
@@ -24,6 +24,7 @@
24| ├── switch_role_sample.py24| ├── switch_role_sample.py
25| ├── transfer_cache_async_sample.py25| ├── transfer_cache_async_sample.py
26| ├── hixl_transfer_backend_sample.py26| ├── hixl_transfer_backend_sample.py
27+| ├── hixl_d2rd_multiproc_sample.py
27```28```
28 29 
29## 环境准备30## 环境准备
@@ -24,6 +24,7 @@ Function: Implements KV Cache management functionality in disaggregated deployme
24| ├── switch_role_sample.py24| ├── switch_role_sample.py
25| ├── transfer_cache_async_sample.py25| ├── transfer_cache_async_sample.py
26| ├── hixl_transfer_backend_sample.py26| ├── hixl_transfer_backend_sample.py
27+| ├── hixl_d2rd_multiproc_sample.py
27```28```
28 29 
29## Environment Setup30## Environment Setup
@@ -0,0 +1,338 @@
1+#!/usr/bin/env python3
2+# -*- coding: utf-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+ 
13+import argparse
14+import logging
15+import socket
16+import struct
17+import sys
18+import time
19+ 
20+import torch
21+import hixl
22+ 
23+logging.basicConfig(
24+ format="%(asctime)s [%(levelname)s] %(message)s", level=logging.INFO
25+)
26+ 
27+BUF_SIZE = 8 * 1024 * 1024
28+BLOCK_SIZE = 16 * 1024
29+BLOCK_COUNT = BUF_SIZE // BLOCK_SIZE
30+DEFAULT_DEVICE_CLIENT = 0
31+DEFAULT_DEVICE_SERVER = 2
32+DEFAULT_CLIENT_ENGINE = "127.0.0.1:16000"
33+DEFAULT_SERVER_ENGINE = "127.0.0.1:16001"
34+CONNECT_TIMEOUT_MS = 5000
35+TRANSFER_TIMEOUT_MS = 30000
36+SOCKET_PORT_OFFSET = 1000
37+SOCKET_BACKLOG = 1
38+SOCKET_RETRY_COUNT = 10
39+SOCKET_RETRY_INTERVAL_S = 0.5
40+SOCKET_RETRY_TIMEOUT_S = 2.0
41+FILL_VALUE = 0xAA
42+DISCONNECT_WAIT_TIMEOUT_S = 5.0
43+ 
44+ 
45+def parse_engine_addr(engine_addr: str) -> tuple[str, int]:
46+ if engine_addr.startswith("["):
47+ bracket_end = engine_addr.find("]")
48+ if (
49+ bracket_end < 0
50+ or bracket_end + 1 >= len(engine_addr)
51+ or engine_addr[bracket_end + 1] != ":"
52+ ):
53+ raise ValueError(
54+ f"Invalid IPv6 engine address format: {engine_addr}, expected [host]:port"
55+ )
56+ host = engine_addr[1:bracket_end]
57+ port = int(engine_addr[bracket_end + 2 :])
58+ else:
59+ pos = engine_addr.rfind(":")
60+ if pos < 0:
61+ raise ValueError(
62+ f"Invalid engine address format: {engine_addr}, expected host:port"
63+ )
64+ host = engine_addr[:pos]
65+ port = int(engine_addr[pos + 1 :])
66+ return host, port
67+ 
68+ 
69+def build_default_options() -> dict:
70+ options = {
71+ hixl.OPTION_AUTO_CONNECT: "1",
72+ }
73+ return options
74+ 
75+ 
76+def setup_listen_socket(port: int) -> socket.socket:
77+ srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
78+ try:
79+ srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
80+ srv.bind(("0.0.0.0", port))
81+ srv.listen(SOCKET_BACKLOG)
82+ except Exception:
83+ srv.close()
84+ raise
85+ return srv
86+ 
87+ 
88+def _wait_client_disconnect(conn) -> None:
89+ conn.settimeout(DISCONNECT_WAIT_TIMEOUT_S)
90+ try:
91+ while True:
92+ chunk = conn.recv(64)
93+ if not chunk:
94+ break
95+ except socket.timeout:
96+ logging.warning(
97+ "Server timed out waiting for client disconnect after %ss, "
98+ "proceeding anyway (client may have crashed)",
99+ DISCONNECT_WAIT_TIMEOUT_S,
100+ )
101+ finally:
102+ conn.settimeout(None)
103+ logging.info("Server done")
104+ 
105+ 
106+def server_send_addr(listen_port: int, dev_addr: int, timeout_s: float = 120.0):
107+ srv = setup_listen_socket(listen_port)
108+ srv.settimeout(timeout_s)
109+ logging.info(f"Server listening on port {listen_port}, waiting for client...")
110+ try:
111+ conn, _ = srv.accept()
112+ except socket.timeout as e:
113+ srv.close()
114+ raise RuntimeError(
115+ f"Server timed out waiting for client after {timeout_s}s"
116+ ) from e
117+ try:
118+ conn.settimeout(timeout_s)
119+ data = struct.pack("!Q", dev_addr)
120+ conn.sendall(data)
121+ logging.info(f"Server sent buffer addr 0x{dev_addr:X} to client")
122+ _wait_client_disconnect(conn)
123+ finally:
124+ conn.close()
125+ srv.close()
126+ 
127+ 
128+def _recv_exact(sock, size: int) -> bytes:
129+ data = b""
130+ while len(data) < size:
131+ chunk = sock.recv(size - len(data))
132+ if not chunk:
133+ raise ConnectionError("Server closed connection before sending address")
134+ data += chunk
135+ return data
136+ 
137+ 
138+def client_get_remote_addr(remote_engine: str):
139+ ip, port = parse_engine_addr(remote_engine)
140+ port += SOCKET_PORT_OFFSET
141+ sock = None
142+ for attempt in range(1, SOCKET_RETRY_COUNT + 1):
143+ try:
144+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
145+ sock.settimeout(SOCKET_RETRY_TIMEOUT_S)
146+ sock.connect((ip, port))
147+ data = _recv_exact(sock, 8)
148+ remote_addr = struct.unpack("!Q", data)[0]
149+ logging.info(f"Client received remote addr 0x{remote_addr:X}")
150+ return remote_addr, sock
151+ except OSError:
152+ if sock:
153+ sock.close()
154+ sock = None
155+ logging.info(f"Connect retry {attempt}/{SOCKET_RETRY_COUNT}...")
156+ time.sleep(SOCKET_RETRY_INTERVAL_S)
157+ raise RuntimeError(
158+ f"Failed to connect to server at {ip}:{port} after {SOCKET_RETRY_COUNT} retries"
159+ )
160+ 
161+ 
162+def run_server(args):
163+ torch.npu.set_device(args.device)
164+ 
165+ options = build_default_options()
166+ engine = hixl.Hixl()
167+ handle = None
168+ 
169+ try:
170+ ret = engine.initialize(args.local_engine, options)
171+ if ret != hixl.SUCCESS:
172+ raise RuntimeError(f"Server Initialize failed, ret={ret}")
173+ logging.info("Server engine initialized")
174+ 
175+ buf_tensor = torch.full(
176+ (BUF_SIZE,), FILL_VALUE, dtype=torch.uint8, device="npu"
177+ )
178+ dev_addr = int(buf_tensor.data_ptr())
179+ logging.info(f"Server NPU buffer at 0x{dev_addr:X}, size={BUF_SIZE}")
180+ 
181+ mem_desc = hixl.MemDesc(dev_addr, BUF_SIZE)
182+ ret, handle = engine.register_mem(mem_desc, hixl.MemType.MEM_DEVICE)
183+ if ret != hixl.SUCCESS:
184+ raise RuntimeError(f"Server RegisterMem failed, ret={ret}")
185+ logging.info(f"Server RegisterMem success, handle=0x{handle:X}")
186+ 
187+ listen_port = parse_engine_addr(args.local_engine)[1] + SOCKET_PORT_OFFSET
188+ server_send_addr(listen_port, dev_addr)
189+ 
190+ finally:
191+ if handle is not None:
192+ ret = engine.deregister_mem(handle)
193+ if ret != hixl.SUCCESS:
194+ logging.warning(f"Server DeregisterMem ret={ret}")
195+ engine.finalize()
196+ logging.info("Server finalize done")
197+ 
198+ 
199+def _build_transfer_op_descs(dev_addr: int, remote_addr: int):
200+ op_descs = []
201+ for i in range(BLOCK_COUNT):
202+ local_offset = i * BLOCK_SIZE
203+ remote_offset = i * BLOCK_SIZE
204+ op_descs.append(
205+ hixl.TransferOpDesc(
206+ local_addr=dev_addr + local_offset,
207+ remote_addr=remote_addr + remote_offset,
208+ len=BLOCK_SIZE,
209+ )
210+ )
211+ return op_descs
212+ 
213+ 
214+def _verify_transferred_data(buf_tensor) -> None:
215+ host_data = buf_tensor.cpu().numpy()
216+ expected = bytearray([FILL_VALUE]) * BUF_SIZE
217+ if host_data.tobytes() != expected:
218+ mismatch_count = sum(1 for a, b in zip(host_data.tobytes(), expected) if a != b)
219+ raise RuntimeError(f"Verify FAILED: {mismatch_count} bytes mismatch")
220+ logging.info("Client Verify success — all bytes match 0xAA")
221+ 
222+ 
223+def _cleanup_client(engine, handle, sock, connected, remote_engine: str) -> None:
224+ if connected:
225+ ret = engine.disconnect(remote_engine, timeout_in_millis=CONNECT_TIMEOUT_MS)
226+ if ret != hixl.SUCCESS:
227+ logging.warning(f"Client Disconnect ret={ret}")
228+ else:
229+ logging.info("Client Disconnect success")
230+ if sock is not None:
231+ try:
232+ sock.close()
233+ except OSError as e:
234+ logging.warning(f"Client socket close failed: {e}")
235+ if handle is not None:
236+ ret = engine.deregister_mem(handle)
237+ if ret != hixl.SUCCESS:
238+ logging.warning(f"Client DeregisterMem ret={ret}")
239+ engine.finalize()
240+ logging.info("Client finalize done")
241+ 
242+ 
243+def run_client(args):
244+ torch.npu.set_device(args.device)
245+ 
246+ options = build_default_options()
247+ engine = hixl.Hixl()
248+ handle = None
249+ sock = None
250+ connected = False
251+ 
252+ try:
253+ ret = engine.initialize(args.local_engine, options)
254+ if ret != hixl.SUCCESS:
255+ raise RuntimeError(f"Client Initialize failed, ret={ret}")
256+ logging.info("Client engine initialized")
257+ 
258+ buf_tensor = torch.zeros(BUF_SIZE, dtype=torch.uint8, device="npu")
259+ dev_addr = int(buf_tensor.data_ptr())
260+ logging.info(f"Client NPU buffer at 0x{dev_addr:X}, size={BUF_SIZE}")
261+ 
262+ mem_desc = hixl.MemDesc(dev_addr, BUF_SIZE)
263+ ret, handle = engine.register_mem(mem_desc, hixl.MemType.MEM_DEVICE)
264+ if ret != hixl.SUCCESS:
265+ raise RuntimeError(f"Client RegisterMem failed, ret={ret}")
266+ logging.info(f"Client RegisterMem success, handle=0x{handle:X}")
267+ 
268+ remote_addr, sock = client_get_remote_addr(args.remote_engine)
269+ 
270+ ret = engine.connect(args.remote_engine, timeout_in_millis=CONNECT_TIMEOUT_MS)
271+ if ret != hixl.SUCCESS:
272+ raise RuntimeError(f"Client Connect failed, ret={ret}")
273+ connected = True
274+ logging.info("Client Connect success")
275+ 
276+ op_descs = _build_transfer_op_descs(dev_addr, remote_addr)
277+ 
278+ ret = engine.transfer_sync(
279+ args.remote_engine,
280+ hixl.TransferOp.READ,
281+ op_descs,
282+ timeout_in_millis=TRANSFER_TIMEOUT_MS,
283+ )
284+ if ret != hixl.SUCCESS:
285+ raise RuntimeError(f"Client TransferSync READ failed, ret={ret}")
286+ logging.info("Client TransferSync READ completed")
287+ 
288+ _verify_transferred_data(buf_tensor)
289+ 
290+ finally:
291+ _cleanup_client(engine, handle, sock, connected, args.remote_engine)
292+ 
293+ 
294+def parse_args():
295+ parser = argparse.ArgumentParser(description="HIXL D2RD multi-process sample")
296+ parser.add_argument("--role", required=True, choices=["client", "server"])
297+ parser.add_argument("--device", type=int, default=None)
298+ parser.add_argument("--local-engine", type=str, default=None)
299+ parser.add_argument("--remote-engine", type=str, default=None)
300+ args = parser.parse_args()
301+ 
302+ is_client = args.role == "client"
303+ if args.device is None:
304+ args.device = DEFAULT_DEVICE_CLIENT if is_client else DEFAULT_DEVICE_SERVER
305+ if args.local_engine is None:
306+ args.local_engine = (
307+ DEFAULT_CLIENT_ENGINE if is_client else DEFAULT_SERVER_ENGINE
308+ )
309+ if args.remote_engine is None:
310+ args.remote_engine = (
311+ DEFAULT_SERVER_ENGINE if is_client else DEFAULT_CLIENT_ENGINE
312+ )
313+ 
314+ if is_client:
315+ parse_engine_addr(args.remote_engine)
316+ else:
317+ parse_engine_addr(args.local_engine)
318+ 
319+ logging.info(f"role={args.role}, device={args.device}")
320+ logging.info(f" local={args.local_engine}, remote={args.remote_engine}")
321+ return args
322+ 
323+ 
324+def main():
325+ try:
326+ args = parse_args()
327+ except ValueError as e:
328+ logging.error(str(e))
329+ sys.exit(1)
330+ if args.role == "server":
331+ run_server(args)
332+ else:
333+ run_client(args)
334+ logging.info("Sample finished successfully")
335+ 
336+ 
337+if __name__ == "__main__":
338+ main()
@@ -15,6 +15,7 @@ unset PYTHONPATH
15export PIP_BREAK_SYSTEM_PACKAGES=115export PIP_BREAK_SYSTEM_PACKAGES=1
16 16 
17WHL_LLM_DATADIST="${sourcedir}/hixl/lib/llm_datadist-0.0.1-py3-none-any.whl"17WHL_LLM_DATADIST="${sourcedir}/hixl/lib/llm_datadist-0.0.1-py3-none-any.whl"
18+PYTHON_HIXL_SO="${sourcedir}/hixl/lib/hixl.so"
18 19 
19run_pip() { python3 -m pip "$@" || pip3 "$@"; }20run_pip() { python3 -m pip "$@" || pip3 "$@"; }
20 21 
@@ -48,12 +49,30 @@ set_file_chmod() {
48 49 
49[ -f "${WHL_LLM_DATADIST}" ] && echo "[hixl] installing ${WHL_LLM_DATADIST}" && run_pip install --disable-pip-version-check --upgrade --no-deps --force-reinstall -t "${WHL_INSTALL_DIR_PATH}" "${WHL_LLM_DATADIST}" || true50[ -f "${WHL_LLM_DATADIST}" ] && echo "[hixl] installing ${WHL_LLM_DATADIST}" && run_pip install --disable-pip-version-check --upgrade --no-deps --force-reinstall -t "${WHL_INSTALL_DIR_PATH}" "${WHL_LLM_DATADIST}" || true
50 51 
52+if [ -f "${PYTHON_HIXL_SO}" ]; then
53+ mkdir -p "${WHL_INSTALL_DIR_PATH}"
54+ echo "[hixl] installing ${PYTHON_HIXL_SO}"
55+ cp -f "${PYTHON_HIXL_SO}" "${WHL_INSTALL_DIR_PATH}/"
56+ if [ $? -ne 0 ]; then
57+ echo "[hixl][ERROR] copy hixl.so to ${WHL_INSTALL_DIR_PATH}/ failed"
58+ exit 1
59+ fi
60+ mkdir -p "${WHL_INSTALL_DIR_PATH}/hixl"
lining23666

创建的目录和文件,都需要做权限控制

likedislike
61+ ln -sf ../hixl.so "${WHL_INSTALL_DIR_PATH}/hixl/hixl.so"
62+ if [ $? -ne 0 ]; then
63+ echo "[hixl][ERROR] create softlink hixl.so under ${WHL_INSTALL_DIR_PATH}/hixl/ failed"
64+ exit 1
65+ fi
66+fi
67+ 
51if [ -d "${WHL_INSTALL_DIR_PATH}" ]; then68if [ -d "${WHL_INSTALL_DIR_PATH}" ]; then
52 chmod_recur "${sourcedir}/python" 750 dir69 chmod_recur "${sourcedir}/python" 750 dir
53 chmod_recur "${WHL_INSTALL_DIR_PATH}/llm_datadist" 550 dir70 chmod_recur "${WHL_INSTALL_DIR_PATH}/llm_datadist" 550 dir
54 chmod_recur "${WHL_INSTALL_DIR_PATH}/llm_datadist" 550 file71 chmod_recur "${WHL_INSTALL_DIR_PATH}/llm_datadist" 550 file
55 chmod_recur "${WHL_INSTALL_DIR_PATH}"/llm_datadist-*.dist-info 550 dir72 chmod_recur "${WHL_INSTALL_DIR_PATH}"/llm_datadist-*.dist-info 550 dir
56 chmod_recur "${WHL_INSTALL_DIR_PATH}"/llm_datadist-*.dist-info 550 file73 chmod_recur "${WHL_INSTALL_DIR_PATH}"/llm_datadist-*.dist-info 550 file
74+ chmod_recur "${WHL_INSTALL_DIR_PATH}/hixl" 550 dir
75+ chmod_recur "${WHL_INSTALL_DIR_PATH}/hixl" 550 file
57 chmod_recur "${WHL_INSTALL_DIR_PATH}/LICENSE" 440 file76 chmod_recur "${WHL_INSTALL_DIR_PATH}/LICENSE" 440 file
58fi77fi
59 78 
@@ -17,6 +17,8 @@ export PIP_BREAK_SYSTEM_PACKAGES=1
17pip3 uninstall -y "llm_datadist" >/dev/null 2>&1 || true17pip3 uninstall -y "llm_datadist" >/dev/null 2>&1 || true
18 18 
19rm -fr "${WHL_INSTALL_DIR_PATH}/llm_datadist" "${WHL_INSTALL_DIR_PATH}/llm_datadist-"*.dist-info 2>/dev/null19rm -fr "${WHL_INSTALL_DIR_PATH}/llm_datadist" "${WHL_INSTALL_DIR_PATH}/llm_datadist-"*.dist-info 2>/dev/null
20+rm -f "${WHL_INSTALL_DIR_PATH}/hixl.so" 2>/dev/null
21+rm -fr "${WHL_INSTALL_DIR_PATH}/hixl" 2>/dev/null
20 22 
21remove_empty_dir() {23remove_empty_dir() {
22 local dir="$1"24 local dir="$1"
@@ -28,4 +30,3 @@ remove_empty_dir() {
28 30 
29remove_empty_dir "${WHL_INSTALL_DIR_PATH}"31remove_empty_dir "${WHL_INSTALL_DIR_PATH}"
30remove_empty_dir "${sourcedir}/python"32remove_empty_dir "${sourcedir}/python"
31- 
@@ -108,6 +108,8 @@ python_dir_chmod_reset "$WHL_SOFTLINK_INSTALL_DIR_PATH"
108 108 
109create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist"109create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist"
110create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist-*.dist-info"110create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "llm_datadist-*.dist-info"
111+create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl.so"
112+create_softlink_if_exists "${WHL_INSTALL_DIR_PATH}" "$WHL_SOFTLINK_INSTALL_DIR_PATH" "hixl"
111 113 
112python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH"114python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH"
113python_dir_chmod_set "$(dirname $WHL_SOFTLINK_INSTALL_DIR_PATH)"115python_dir_chmod_set "$(dirname $WHL_SOFTLINK_INSTALL_DIR_PATH)"
@@ -323,7 +323,8 @@ clear_kernel_cache_dir() {
323}323}
324 324 
325WHL_INSTALL_DIR_PATH="${common_parse_dir}/python/site-packages"325WHL_INSTALL_DIR_PATH="${common_parse_dir}/python/site-packages"
326-PYTHON_HIXL_WHL="${sourcedir}/lib/llm_datadist-0.0.1-py3-none-any.whl"326+PYTHON_LLM_DATADIST_WHL="${sourcedir}/lib/llm_datadist-0.0.1-py3-none-any.whl"
327+PYTHON_HIXL_SO="${sourcedir}/lib/hixl.so"
327 328 
328custom_install() {329custom_install() {
329 if [ ! -d "$common_parse_dir/hixl" ]; then330 if [ ! -d "$common_parse_dir/hixl" ]; then
@@ -338,14 +339,28 @@ custom_install() {
338 fi339 fi
339 340 
340 if [ "$hetero_arch" != "y" ]; then341 if [ "$hetero_arch" != "y" ]; then
341- log "INFO" "install hixl extension module begin..."342+ mkdir -p "${WHL_INSTALL_DIR_PATH}"
342- hixl_install_package "${PYTHON_HIXL_WHL}" "${WHL_INSTALL_DIR_PATH}"343+ log "INFO" "install llm_datadist extension module begin..."
343- log "INFO" "the hixl extension module installed successfully!"344+ hixl_install_package "${PYTHON_LLM_DATADIST_WHL}" "${WHL_INSTALL_DIR_PATH}"
345+ log "INFO" "the llm_datadist extension module installed successfully!"
346+ log "INFO" "install hixl begin..."
347+ cp -f "${PYTHON_HIXL_SO}" "${WHL_INSTALL_DIR_PATH}/"
348+ if [ $? -ne 0 ]; then
349+ log "ERROR" "copy hixl.so to ${WHL_INSTALL_DIR_PATH}/ failed"
350+ exit 1
351+ fi
352+ mkdir -p "${WHL_INSTALL_DIR_PATH}/hixl"
353+ ln -sf ../hixl.so "${WHL_INSTALL_DIR_PATH}/hixl/hixl.so"
354+ if [ $? -ne 0 ]; then
355+ log "ERROR" "create softlink hixl.so under ${WHL_INSTALL_DIR_PATH}/hixl/ failed"
356+ exit 1
357+ fi
358+ log "INFO" "the hixl installed successfully!"
344 359 
345 if [ "${pylocal}" = "y" ]; then360 if [ "${pylocal}" = "y" ]; then
346 log "INFO" "please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH}."361 log "INFO" "please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH}."
347 else362 else
348- log "INFO" "The package llm_datadist is already installed in python default path. It is recommended to install it using the '--pylocal' parameter, install the package hixl in the ${WHL_INSTALL_DIR_PATH}."363+ log "INFO" "llm_datadist is installed in python default path. hixl.so is installed in ${WHL_INSTALL_DIR_PATH}, please make sure PYTHONPATH include ${WHL_INSTALL_DIR_PATH} to import hixl. It is recommended to install using the '--pylocal' parameter for a unified install location."
349 fi364 fi
350 365 
351 if [ "x$stage" = "xinstall" ]; then366 if [ "x$stage" = "xinstall" ]; then
@@ -93,6 +93,8 @@ python_dir_chmod_set "$WHL_SOFTLINK_INSTALL_DIR_PATH"
93 93 
94remove_softlink "llm_datadist"94remove_softlink "llm_datadist"
95remove_softlink "llm_datadist-*.dist-info"95remove_softlink "llm_datadist-*.dist-info"
96+remove_softlink "hixl.so"
97+remove_softlink "hixl"
96 98 
97remove_empty_dir "$WHL_SOFTLINK_INSTALL_DIR_PATH"99remove_empty_dir "$WHL_SOFTLINK_INSTALL_DIR_PATH"
98remove_empty_dir "$install_path/$latest_dir/python"100remove_empty_dir "$install_path/$latest_dir/python"
@@ -221,6 +221,10 @@ custom_uninstall() {
221 log "INFO" "uninstall hixl tool begin..."221 log "INFO" "uninstall hixl tool begin..."
222 whl_uninstall_package "${HIXL_NAME}" "${WHL_INSTALL_DIR_PATH}"222 whl_uninstall_package "${HIXL_NAME}" "${WHL_INSTALL_DIR_PATH}"
223 log "INFO" "hixl tool uninstalled successfully!"223 log "INFO" "hixl tool uninstalled successfully!"
224+ 
225+ rm -f "${WHL_INSTALL_DIR_PATH}/hixl.so" 2> /dev/null
226+ rm -rf "${WHL_INSTALL_DIR_PATH}/hixl" 2> /dev/null
227+ log "INFO" "hixl module uninstalled successfully!"
224 fi228 fi
225 229 
226 remove_empty_dir "${common_parse_dir}/hixl/python"230 remove_empty_dir "${common_parse_dir}/hixl/python"
@@ -10,4 +10,5 @@
10 10 
11add_subdirectory(llm_datadist)11add_subdirectory(llm_datadist)
12add_subdirectory(llm_wrapper)12add_subdirectory(llm_wrapper)
13-add_subdirectory(metadef_wrapper)13+add_subdirectory(metadef_wrapper)
14+add_subdirectory(hixl_py)
@@ -0,0 +1,55 @@
1+# ----------------------------------------------------------------------------
2+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------
10+ 
11+if (NOT ENABLE_TEST)
12+ set(CMAKE_SKIP_RPATH TRUE)
13+ add_library(hixl MODULE
14+ hixl_py.cc)
15+ 
16+ target_include_directories(hixl PRIVATE
17+ ${HI_PYTHON_INC}
18+ ${pybind11_INCLUDE_DIR}
19+ ${HIXL_CODE_DIR}/include
20+ ${HIXL_CODE_DIR}/src/hixl
21+ )
22+ 
23+ target_link_libraries(hixl PRIVATE
24+ $<BUILD_INTERFACE:intf_pub>
25+ $<BUILD_INTERFACE:hccl_headers>
26+ $<BUILD_INTERFACE:slog_headers>
27+ $<BUILD_INTERFACE:metadef_headers>
28+ $<BUILD_INTERFACE:msprof_headers>
29+ alog
30+ cann_hixl
31+ )
32+ 
33+ set_target_properties(hixl PROPERTIES
34+ PREFIX ""
35+ SUFFIX ".so"
36+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
37+ )
38+ 
39+ target_compile_definitions(hixl PRIVATE
40+ PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF
41+ )
42+ 
43+ target_compile_options(hixl PRIVATE
44+ -Xlinker -export-dynamic
45+ )
46+ 
47+ target_link_options(hixl PRIVATE
48+ -s
49+ )
50+ 
51+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hixl.so
52+ DESTINATION ${INSTALL_LIBRARY_DIR}
53+ COMPONENT hixl
54+ )
55+endif ()
@@ -0,0 +1,361 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "hixl_py.h"
12+ 
13+#include "Python.h"
14+ 
15+#include "pybind11/pybind11.h"
16+#include "pybind11/stl.h"
17+ 
18+#include "hixl/hixl_types.h"
19+#include "common/hixl_checker.h"
20+ 
21+#undef PYBIND11_CHECK_PYTHON_VERSION
22+#define PYBIND11_CHECK_PYTHON_VERSION
23+ 
24+namespace hixl_py {
25+namespace py = pybind11;
26+ 
27+HixlPy::HixlPy() : hixl_engine_(nullptr), initialized_(false) {}
28+ 
29+HixlPy::~HixlPy() {
30+ if (initialized_ && hixl_engine_ != nullptr) {
lining23666

这里是不是需要释放GIL,python的Finalize方法都是调用了py::call_guardpy::gil_scoped_release()

likedislike
31+ py::gil_scoped_release release;
32+ hixl_engine_->Finalize();
33+ hixl_engine_.reset();
34+ initialized_ = false;
35+ }
36+}
37+ 
38+hixl::Status HixlPy::Initialize(const std::string &local_engine, const std::map<std::string, std::string> &options) {
39+ std::lock_guard<std::mutex> lock(mutex_);
40+ if (initialized_) {
41+ HIXL_LOGI("Initialize: already initialized, ignoring repeated call");
42+ return hixl::SUCCESS;
43+ }
44+ auto instance = std::make_unique<hixl::Hixl>();
45+ hixl::AscendString ascend_local_engine(local_engine.c_str());
46+ std::map<hixl::AscendString, hixl::AscendString> ascend_options;
47+ for (const auto &opt : options) {
48+ (void)ascend_options.emplace(opt.first.c_str(), opt.second.c_str());
49+ }
50+ hixl::Status ret = instance->Initialize(ascend_local_engine, ascend_options);
51+ if (ret != hixl::SUCCESS) {
52+ HIXL_LOGE(ret, "Initialize: failed for engine '%s'", local_engine.c_str());
53+ return ret;
54+ }
55+ hixl_engine_ = std::move(instance);
56+ initialized_ = true;
57+ return hixl::SUCCESS;
58+}
59+ 
60+void HixlPy::Finalize() {
61+ std::lock_guard<std::mutex> lock(mutex_);
62+ if (!initialized_ || hixl_engine_ == nullptr) {
63+ return;
64+ }
65+ hixl_engine_->Finalize();
66+ hixl_engine_.reset();
67+ initialized_ = false;
68+}
69+ 
70+std::pair<hixl::Status, uintptr_t> HixlPy::RegisterMem(const hixl::MemDesc &mem_desc, hixl::MemType mem_type) {
71+ hixl::MemHandle handle = nullptr;
72+ std::lock_guard<std::mutex> lock(mutex_);
73+ if (!initialized_ || hixl_engine_ == nullptr) {
74+ return {hixl::FAILED, reinterpret_cast<uintptr_t>(handle)};
75+ }
76+ hixl::Status ret = hixl_engine_->RegisterMem(mem_desc, mem_type, handle);
77+ return {ret, reinterpret_cast<uintptr_t>(handle)};
78+}
79+ 
80+hixl::Status HixlPy::DeregisterMem(uintptr_t mem_handle) {
81+ std::lock_guard<std::mutex> lock(mutex_);
82+ if (!initialized_ || hixl_engine_ == nullptr) {
83+ return hixl::FAILED;
84+ }
85+ hixl::MemHandle handle = reinterpret_cast<hixl::MemHandle>(mem_handle);
86+ return hixl_engine_->DeregisterMem(handle);
87+}
88+ 
89+hixl::Status HixlPy::Connect(const std::string &remote_engine, int32_t timeout_ms) {
90+ std::lock_guard<std::mutex> lock(mutex_);
91+ if (!initialized_ || hixl_engine_ == nullptr) {
92+ return hixl::FAILED;
93+ }
94+ hixl::AscendString ascend_remote(remote_engine.c_str());
95+ return hixl_engine_->Connect(ascend_remote, timeout_ms);
96+}
97+ 
98+hixl::Status HixlPy::Disconnect(const std::string &remote_engine, int32_t timeout_ms) {
99+ std::lock_guard<std::mutex> lock(mutex_);
100+ if (!initialized_ || hixl_engine_ == nullptr) {
101+ return hixl::FAILED;
102+ }
103+ hixl::AscendString ascend_remote(remote_engine.c_str());
104+ return hixl_engine_->Disconnect(ascend_remote, timeout_ms);
105+}
106+ 
107+hixl::Status HixlPy::ConnectAsync(const std::string &remote_engine, int32_t timeout_ms) {
108+ std::lock_guard<std::mutex> lock(mutex_);
109+ if (!initialized_ || hixl_engine_ == nullptr) {
110+ return hixl::FAILED;
111+ }
112+ hixl::AscendString ascend_remote(remote_engine.c_str());
113+ return hixl_engine_->ConnectAsync(ascend_remote, timeout_ms);
114+}
115+ 
116+hixl::Status HixlPy::DisconnectAsync(const std::string &remote_engine, int32_t timeout_ms) {
117+ std::lock_guard<std::mutex> lock(mutex_);
118+ if (!initialized_ || hixl_engine_ == nullptr) {
119+ return hixl::FAILED;
120+ }
121+ hixl::AscendString ascend_remote(remote_engine.c_str());
122+ return hixl_engine_->DisconnectAsync(ascend_remote, timeout_ms);
123+}
124+ 
125+std::pair<hixl::Status, hixl::AsyncConnectStatus> HixlPy::GetAsyncConnectStatus(const std::string &remote_engine) {
126+ hixl::AsyncConnectStatus status = hixl::AsyncConnectStatus::NOT_CONNECT;
127+ std::lock_guard<std::mutex> lock(mutex_);
128+ if (!initialized_ || hixl_engine_ == nullptr) {
129+ return {hixl::FAILED, status};
130+ }
131+ hixl::AscendString ascend_remote(remote_engine.c_str());
132+ hixl::Status ret = hixl_engine_->GetAsyncConnectStatus(ascend_remote, status);
133+ return {ret, status};
134+}
135+ 
136+std::pair<hixl::Status, std::map<std::string, hixl::AsyncConnectStatus>> HixlPy::GetAllAsyncConnectStatus() {
137+ std::map<hixl::AscendString, hixl::AsyncConnectStatus> statuses;
138+ std::lock_guard<std::mutex> lock(mutex_);
139+ if (!initialized_ || hixl_engine_ == nullptr) {
140+ return {hixl::FAILED, {}};
141+ }
142+ hixl::Status ret = hixl_engine_->GetAsyncConnectStatus(statuses);
143+ std::map<std::string, hixl::AsyncConnectStatus> result;
144+ for (const auto &s : statuses) {
145+ (void)result.emplace(std::string(s.first.GetString()), s.second);
146+ }
147+ return {ret, result};
148+}
149+ 
150+hixl::Status HixlPy::TransferSync(const std::string &remote_engine, hixl::TransferOp operation,
151+ const std::vector<hixl::TransferOpDesc> &op_descs, int32_t timeout_ms) {
152+ std::lock_guard<std::mutex> lock(mutex_);
153+ if (!initialized_ || hixl_engine_ == nullptr) {
154+ return hixl::FAILED;
155+ }
156+ hixl::AscendString ascend_remote(remote_engine.c_str());
157+ return hixl_engine_->TransferSync(ascend_remote, operation, op_descs, timeout_ms);
158+}
159+ 
160+std::pair<hixl::Status, uintptr_t> HixlPy::TransferAsync(const std::string &remote_engine, hixl::TransferOp operation,
161+ const std::vector<hixl::TransferOpDesc> &op_descs,
162+ hixl::TransferArgs args) {
163+ hixl::TransferReq req = nullptr;
164+ std::lock_guard<std::mutex> lock(mutex_);
165+ if (!initialized_ || hixl_engine_ == nullptr) {
166+ return {hixl::FAILED, reinterpret_cast<uintptr_t>(req)};
167+ }
168+ hixl::AscendString ascend_remote(remote_engine.c_str());
169+ hixl::Status ret = hixl_engine_->TransferAsync(ascend_remote, operation, op_descs, args, req);
170+ return {ret, reinterpret_cast<uintptr_t>(req)};
171+}
172+ 
173+std::pair<hixl::Status, hixl::TransferStatus> HixlPy::GetTransferStatus(uintptr_t req_id) {
174+ hixl::TransferStatus status = hixl::TransferStatus::FAILED;
175+ std::lock_guard<std::mutex> lock(mutex_);
176+ if (!initialized_ || hixl_engine_ == nullptr) {
177+ return {hixl::FAILED, status};
178+ }
179+ hixl::TransferReq req = reinterpret_cast<hixl::TransferReq>(req_id);
180+ hixl::Status ret = hixl_engine_->GetTransferStatus(req, status);
181+ return {ret, status};
182+}
183+ 
184+std::pair<hixl::Status, std::vector<hixl::TransferResult>> HixlPy::GetAllTransferStatus(
185+ hixl::GetTransferStatusArgs args) {
186+ std::vector<hixl::TransferResult> results;
187+ std::lock_guard<std::mutex> lock(mutex_);
188+ if (!initialized_ || hixl_engine_ == nullptr) {
189+ return {hixl::FAILED, {}};
190+ }
191+ hixl::Status ret = hixl_engine_->GetTransferStatus(args, results);
192+ return {ret, results};
193+}
194+ 
195+hixl::Status HixlPy::SendNotify(const std::string &remote_engine, const hixl::NotifyDesc &notify, int32_t timeout_ms) {
196+ std::lock_guard<std::mutex> lock(mutex_);
197+ if (!initialized_ || hixl_engine_ == nullptr) {
198+ return hixl::FAILED;
199+ }
200+ hixl::AscendString ascend_remote(remote_engine.c_str());
201+ return hixl_engine_->SendNotify(ascend_remote, notify, timeout_ms);
202+}
203+ 
204+std::pair<hixl::Status, std::vector<hixl::NotifyDesc>> HixlPy::GetNotifies() {
205+ std::vector<hixl::NotifyDesc> notifies;
206+ std::lock_guard<std::mutex> lock(mutex_);
207+ if (!initialized_ || hixl_engine_ == nullptr) {
208+ return {hixl::FAILED, {}};
209+ }
210+ hixl::Status ret = hixl_engine_->GetNotifies(notifies);
211+ return {ret, notifies};
212+}
213+ 
214+std::pair<hixl::Status, int32_t> HixlPy::GetCapability(hixl::FeatureType feature_type) {
215+ int32_t value = hixl::FEATURE_NOT_SUPPORTED;
216+ hixl::Status ret = hixl::Hixl::GetCapability(feature_type, value);
217+ return {ret, value};
218+}
219+ 
220+static void RegisterConstants(py::module_ &m) {
221+ m.attr("SUCCESS") = py::int_(hixl::SUCCESS);
222+ m.attr("PARAM_INVALID") = py::int_(hixl::PARAM_INVALID);
223+ m.attr("TIMEOUT") = py::int_(hixl::TIMEOUT);
224+ m.attr("NOT_CONNECTED") = py::int_(hixl::NOT_CONNECTED);
225+ m.attr("ALREADY_CONNECTED") = py::int_(hixl::ALREADY_CONNECTED);
226+ m.attr("NOTIFY_FAILED") = py::int_(hixl::NOTIFY_FAILED);
227+ m.attr("UNSUPPORTED") = py::int_(hixl::UNSUPPORTED);
228+ m.attr("FAILED") = py::int_(hixl::FAILED);
229+ m.attr("RESOURCE_EXHAUSTED") = py::int_(hixl::RESOURCE_EXHAUSTED);
230+ 
231+ m.attr("OPTION_ENABLE_USE_FABRIC_MEM") = py::str(hixl::OPTION_ENABLE_USE_FABRIC_MEM);
232+ m.attr("OPTION_RDMA_TRAFFIC_CLASS") = py::str(hixl::OPTION_RDMA_TRAFFIC_CLASS);
233+ m.attr("OPTION_RDMA_SERVICE_LEVEL") = py::str(hixl::OPTION_RDMA_SERVICE_LEVEL);
234+ m.attr("OPTION_BUFFER_POOL") = py::str(hixl::OPTION_BUFFER_POOL);
235+ m.attr("OPTION_GLOBAL_RESOURCE_CONFIG") = py::str(hixl::OPTION_GLOBAL_RESOURCE_CONFIG);
236+ m.attr("OPTION_AUTO_CONNECT") = py::str(hixl::OPTION_AUTO_CONNECT);
237+ m.attr("OPTION_LOCAL_COMM_RES") = py::str(hixl::OPTION_LOCAL_COMM_RES);
238+ 
239+ m.attr("FEATURE_SUPPORTED") = py::int_(hixl::FEATURE_SUPPORTED);
240+ m.attr("FEATURE_NOT_SUPPORTED") = py::int_(hixl::FEATURE_NOT_SUPPORTED);
241+}
242+ 
243+static void RegisterEnums(py::module_ &m) {
244+ py::enum_<hixl::MemType>(m, "MemType")
245+ .value("MEM_DEVICE", hixl::MEM_DEVICE)
246+ .value("MEM_HOST", hixl::MEM_HOST)
247+ .export_values();
248+ 
249+ py::enum_<hixl::TransferOp>(m, "TransferOp").value("READ", hixl::READ).value("WRITE", hixl::WRITE).export_values();
250+ 
251+ py::enum_<hixl::TransferStatus>(m, "TransferStatus")
252+ .value("WAITING", hixl::TransferStatus::WAITING)
253+ .value("COMPLETED", hixl::TransferStatus::COMPLETED)
254+ .value("TIMEOUT", hixl::TransferStatus::TIMEOUT)
255+ .value("FAILED", hixl::TransferStatus::FAILED);
256+ 
257+ py::enum_<hixl::AsyncConnectStatus>(m, "AsyncConnectStatus")
258+ .value("NOT_CONNECT", hixl::AsyncConnectStatus::NOT_CONNECT)
259+ .value("CONNECT_PENDING", hixl::AsyncConnectStatus::CONNECT_PENDING)
260+ .value("CONNECTING", hixl::AsyncConnectStatus::CONNECTING)
261+ .value("CONNECTED", hixl::AsyncConnectStatus::CONNECTED)
262+ .value("CONNECT_FAILED", hixl::AsyncConnectStatus::CONNECT_FAILED)
263+ .value("DISCONNECT_PENDING", hixl::AsyncConnectStatus::DISCONNECT_PENDING)
264+ .value("DISCONNECTING", hixl::AsyncConnectStatus::DISCONNECTING)
265+ .export_values();
266+ 
267+ py::enum_<hixl::FeatureType>(m, "FeatureType")
268+ .value("AUTO_CONNECT", hixl::AUTO_CONNECT)
269+ .value("CLIENT_SERVER_COMM", hixl::CLIENT_SERVER_COMM)
270+ .export_values();
271+}
272+ 
273+static void RegisterDataClasses(py::module_ &m) {
274+ py::class_<hixl::MemDesc>(m, "MemDesc")
275+ .def(py::init<uintptr_t, size_t>(), py::arg("addr"), py::arg("len"))
276+ .def_readwrite("addr", &hixl::MemDesc::addr)
277+ .def_readwrite("len", &hixl::MemDesc::len);
278+ 
279+ py::class_<hixl::TransferOpDesc>(m, "TransferOpDesc")
280+ .def(py::init<uintptr_t, uintptr_t, size_t>(), py::arg("local_addr"), py::arg("remote_addr"), py::arg("len"))
281+ .def_readwrite("local_addr", &hixl::TransferOpDesc::local_addr)
282+ .def_readwrite("remote_addr", &hixl::TransferOpDesc::remote_addr)
283+ .def_readwrite("len", &hixl::TransferOpDesc::len);
284+ 
285+ py::class_<hixl::TransferArgs>(m, "TransferArgs")
286+ .def(py::init<>())
287+ .def_property(
288+ "user_data", [](const hixl::TransferArgs &a) { return reinterpret_cast<uintptr_t>(a.user_data); },
289+ [](hixl::TransferArgs &a, uintptr_t v) { a.user_data = reinterpret_cast<const void *>(v); });
290+ 
291+ py::class_<hixl::GetTransferStatusArgs>(m, "GetTransferStatusArgs")
292+ .def(py::init<uint32_t, bool>(), py::arg("max_query_count") = UINT32_MAX, py::arg("skip_waiting") = false)
293+ .def_readwrite("max_query_count", &hixl::GetTransferStatusArgs::max_query_count)
294+ .def_readwrite("skip_waiting", &hixl::GetTransferStatusArgs::skip_waiting);
295+ 
296+ py::class_<hixl::TransferResult>(m, "TransferResult")
297+ .def(py::init<>())
298+ .def_property(
299+ "req", [](const hixl::TransferResult &r) { return reinterpret_cast<uintptr_t>(r.req); },
300+ [](hixl::TransferResult &r, uintptr_t v) { r.req = reinterpret_cast<hixl::TransferReq>(v); })
301+ .def_property(
302+ "user_data", [](const hixl::TransferResult &r) { return reinterpret_cast<uintptr_t>(r.user_data); },
303+ [](hixl::TransferResult &r, uintptr_t v) { r.user_data = reinterpret_cast<const void *>(v); })
304+ .def_readonly("status", &hixl::TransferResult::status);
305+ 
306+ py::class_<hixl::NotifyDesc>(m, "NotifyDesc")
307+ .def(py::init([](const std::string &name, const std::string &msg) {
308+ hixl::NotifyDesc n;
309+ n.name = hixl::AscendString(name.c_str());
310+ n.notify_msg = hixl::AscendString(msg.c_str());
311+ return n;
312+ }),
313+ py::arg("name"), py::arg("notify_msg"))
314+ .def_property(
315+ "name", [](const hixl::NotifyDesc &n) { return std::string(n.name.GetString()); },
316+ [](hixl::NotifyDesc &n, const std::string &s) { n.name = hixl::AscendString(s.c_str()); })
317+ .def_property(
318+ "notify_msg", [](const hixl::NotifyDesc &n) { return std::string(n.notify_msg.GetString()); },
319+ [](hixl::NotifyDesc &n, const std::string &s) { n.notify_msg = hixl::AscendString(s.c_str()); });
320+}
321+ 
322+static void RegisterHixlEngine(py::module_ &m) {
323+ py::class_<HixlPy>(m, "Hixl")
324+ .def(py::init<>())
325+ .def("initialize", &HixlPy::Initialize, py::arg("local_engine"),
326+ py::arg("options") = std::map<std::string, std::string>{}, py::call_guard<py::gil_scoped_release>())
327+ .def("finalize", &HixlPy::Finalize, py::call_guard<py::gil_scoped_release>())
328+ .def("register_mem", &HixlPy::RegisterMem, py::call_guard<py::gil_scoped_release>())
329+ .def("deregister_mem", &HixlPy::DeregisterMem, py::call_guard<py::gil_scoped_release>())
330+ .def("connect", &HixlPy::Connect, py::arg("remote_engine"), py::arg("timeout_in_millis") = 1000,
331+ py::call_guard<py::gil_scoped_release>())
332+ .def("disconnect", &HixlPy::Disconnect, py::arg("remote_engine"), py::arg("timeout_in_millis") = 1000,
333+ py::call_guard<py::gil_scoped_release>())
334+ .def("connect_async", &HixlPy::ConnectAsync, py::arg("remote_engine"), py::arg("timeout_in_millis") = 1000,
335+ py::call_guard<py::gil_scoped_release>())
336+ .def("disconnect_async", &HixlPy::DisconnectAsync, py::arg("remote_engine"), py::arg("timeout_in_millis") = 1000,
337+ py::call_guard<py::gil_scoped_release>())
338+ .def("get_async_connect_status", &HixlPy::GetAsyncConnectStatus, py::call_guard<py::gil_scoped_release>())
339+ .def("get_all_async_connect_status", &HixlPy::GetAllAsyncConnectStatus, py::call_guard<py::gil_scoped_release>())
340+ .def("transfer_sync", &HixlPy::TransferSync, py::arg("remote_engine"), py::arg("op"), py::arg("op_descs"),
341+ py::arg("timeout_in_millis") = 1000, py::call_guard<py::gil_scoped_release>())
342+ .def("transfer_async", &HixlPy::TransferAsync, py::arg("remote_engine"), py::arg("op"), py::arg("op_descs"),
343+ py::arg("args") = hixl::TransferArgs{}, py::call_guard<py::gil_scoped_release>())
344+ .def("get_transfer_status", &HixlPy::GetTransferStatus, py::call_guard<py::gil_scoped_release>())
345+ .def("get_all_transfer_status", &HixlPy::GetAllTransferStatus, py::arg("args") = hixl::GetTransferStatusArgs{},
346+ py::call_guard<py::gil_scoped_release>())
347+ .def("send_notify", &HixlPy::SendNotify, py::arg("remote_engine"), py::arg("notify"),
348+ py::arg("timeout_in_millis") = 1000, py::call_guard<py::gil_scoped_release>())
349+ .def("get_notifies", &HixlPy::GetNotifies, py::call_guard<py::gil_scoped_release>());
350+ 
351+ m.def("get_capability", &HixlPy::GetCapability, py::call_guard<py::gil_scoped_release>());
352+}
353+ 
354+PYBIND11_MODULE(hixl, m) {
355+ RegisterConstants(m);
356+ RegisterEnums(m);
357+ RegisterDataClasses(m);
358+ RegisterHixlEngine(m);
359+}
360+ 
361+} // namespace hixl_py
@@ -0,0 +1,58 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#ifndef CANN_HIXL_PYTHON_HIXL_PY_HIXL_PY_H_
12+#define CANN_HIXL_PYTHON_HIXL_PY_HIXL_PY_H_
13+ 
14+#include <cstdint>
15+#include <memory>
16+#include <mutex>
17+#include <utility>
18+#include "hixl/hixl.h"
19+#include "hixl/hixl_types.h"
20+ 
21+namespace hixl_py {
22+ 
23+class HixlPy {
24+ public:
25+ HixlPy();
26+ ~HixlPy();
27+ 
28+ hixl::Status Initialize(const std::string &local_engine, const std::map<std::string, std::string> &options);
29+ void Finalize();
30+ 
31+ std::pair<hixl::Status, uintptr_t> RegisterMem(const hixl::MemDesc &mem_desc, hixl::MemType mem_type);
32+ hixl::Status DeregisterMem(uintptr_t mem_handle);
33+ hixl::Status Connect(const std::string &remote_engine, int32_t timeout_ms = 1000);
34+ hixl::Status Disconnect(const std::string &remote_engine, int32_t timeout_ms = 1000);
35+ hixl::Status ConnectAsync(const std::string &remote_engine, int32_t timeout_ms = 1000);
36+ hixl::Status DisconnectAsync(const std::string &remote_engine, int32_t timeout_ms = 1000);
37+ std::pair<hixl::Status, hixl::AsyncConnectStatus> GetAsyncConnectStatus(const std::string &remote_engine);
38+ std::pair<hixl::Status, std::map<std::string, hixl::AsyncConnectStatus>> GetAllAsyncConnectStatus();
39+ hixl::Status TransferSync(const std::string &remote_engine, hixl::TransferOp operation,
40+ const std::vector<hixl::TransferOpDesc> &op_descs, int32_t timeout_ms = 1000);
41+ std::pair<hixl::Status, uintptr_t> TransferAsync(const std::string &remote_engine, hixl::TransferOp operation,
42+ const std::vector<hixl::TransferOpDesc> &op_descs,
43+ hixl::TransferArgs args);
44+ std::pair<hixl::Status, hixl::TransferStatus> GetTransferStatus(uintptr_t req_id);
45+ std::pair<hixl::Status, std::vector<hixl::TransferResult>> GetAllTransferStatus(hixl::GetTransferStatusArgs args);
46+ hixl::Status SendNotify(const std::string &remote_engine, const hixl::NotifyDesc &notify, int32_t timeout_ms = 1000);
47+ std::pair<hixl::Status, std::vector<hixl::NotifyDesc>> GetNotifies();
48+ static std::pair<hixl::Status, int32_t> GetCapability(hixl::FeatureType feature_type);
49+ 
50+ private:
51+ std::unique_ptr<hixl::Hixl> hixl_engine_;
52+ std::mutex mutex_;
53+ bool initialized_ = false;
54+};
55+ 
56+} // namespace hixl_py
57+ 
58+#endif // CANN_HIXL_PYTHON_HIXL_PY_HIXL_PY_H_
@@ -15,6 +15,7 @@ add_subdirectory(depends/mmpa)
15add_subdirectory(depends/hccl)15add_subdirectory(depends/hccl)
16add_subdirectory(depends/error_manager)16add_subdirectory(depends/error_manager)
17add_subdirectory(depends/llm_datadist)17add_subdirectory(depends/llm_datadist)
18+add_subdirectory(depends/hixl)
18add_subdirectory(depends/python)19add_subdirectory(depends/python)
19add_subdirectory(depends/ascendcl)20add_subdirectory(depends/ascendcl)
20add_subdirectory(depends/runtime)21add_subdirectory(depends/runtime)
@@ -0,0 +1,99 @@
1+# ----------------------------------------------------------------------------
2+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------
10+ 
11+file(GLOB ADXL_SRC_LIST
12+ "${HIXL_CODE_DIR}/src/llm_datadist/api/adxl_engine_impl.cc"
13+ "${HIXL_CODE_DIR}/src/llm_datadist/comm_statistic_manager.cc"
14+ "${HIXL_CODE_DIR}/src/llm_datadist/llm_datadist_timer.cc"
15+ "${HIXL_CODE_DIR}/src/llm_datadist/adxl/*.cc"
16+ "${HIXL_CODE_DIR}/src/llm_datadist/common/*.cc"
17+ "${HIXL_CODE_DIR}/src/llm_datadist/adapter_hccl/*.cc"
18+ "${HIXL_CODE_DIR}/src/llm_datadist/comm_adapter/*.cc"
19+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/*.cc"
20+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/allocator/*.cc"
21+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/config/*.cc"
22+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/span/*.cc"
23+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/type/*.cc"
24+ "${HIXL_CODE_DIR}/src/llm_datadist/memory/util/*.cc"
25+)
26+ 
27+file(GLOB HIXL_SRC_LIST
28+ "${HIXL_CODE_DIR}/src/hixl/common/*.cc"
29+ "${HIXL_CODE_DIR}/src/hixl/fabric_mem/*.cc"
30+ "${HIXL_CODE_DIR}/src/hixl/engine/*.cc"
31+ "${HIXL_CODE_DIR}/src/hixl/engine/endpoint_generator/*.cc"
32+ "${HIXL_CODE_DIR}/src/hixl/cs/*.cc"
33+ "${HIXL_CODE_DIR}/src/hixl/profiling/*.cc"
34+ "${HIXL_CODE_DIR}/src/hixl/proxy/*.cc"
35+)
36+ 
37+set(HIXL_STUB_SRC_FILES
38+ "${HIXL_CODE_DIR}/tests/depends/llm_datadist/src/mmpa_stub.cc"
39+ "${HIXL_CODE_DIR}/tests/depends/llm_datadist/src/hccl_stub.cc"
40+ "${HIXL_CODE_DIR}/tests/depends/llm_datadist/src/ascend_string_stub.cc"
41+)
42+ 
43+add_library(cann_hixl_base SHARED
44+ ${HIXL_SRC_LIST}
45+ ${ADXL_SRC_LIST}
46+ ${HIXL_STUB_SRC_FILES}
47+)
48+ 
49+target_include_directories(cann_hixl_base PRIVATE
50+ ${HIXL_CODE_DIR}/include
51+ ${HIXL_CODE_DIR}/src/hixl
52+ ${HIXL_CODE_DIR}/src/hixl/common
53+ ${HIXL_CODE_DIR}/src/hixl/proxy
54+ ${HIXL_CODE_DIR}/src/llm_datadist
55+ ${HIXL_CODE_DIR}/tests
56+ ${HIXL_CODE_DIR}/tests/depends/llm_datadist/src
57+ ${HIXL_CODE_DIR}/tests/depends/ascendcl/src
58+ ${HIXL_CODE_DIR}/tests/depends/hccl/src
59+ ${HIXL_CODE_DIR}/tests/depends/slog/src
60+)
61+ 
62+target_link_libraries(cann_hixl_base PRIVATE
63+ $<BUILD_INTERFACE:intf_pub>
64+ $<BUILD_INTERFACE:hccl_headers>
65+ $<BUILD_INTERFACE:slog_headers>
66+ $<BUILD_INTERFACE:acl_rt_headers>
67+ $<BUILD_INTERFACE:runtime_headers>
68+ $<BUILD_INTERFACE:msprof_headers>
69+ $<BUILD_INTERFACE:metadef_headers>
70+ $<BUILD_INTERFACE:error_manager_headers>
71+ PUBLIC c_sec
72+ slog_stub
73+ sys_api_wrap
74+ msprof_stub
75+ ascendcl_stub
76+ runtime_stub
77+ hccl_stub
78+ dcmi_stub
79+ drvdsmi_host_stub
80+ error_manager_stub
81+ json
82+ -ldl
83+ -Wl,--no-as-needed
84+ hccl_stub
85+ -Wl,--as-needed
86+ ${DT_COMMON_LINK_OPTION}
87+)
88+ 
89+set_target_properties(cann_hixl_base PROPERTIES
90+ LINK_FLAGS "-Wl,--wrap=dlopen -Wl,--wrap=dlsym -Wl,--wrap=dlclose -Wl,--wrap=dlerror -Wl,--wrap=access -Wl,--wrap=realpath"
91+)
92+ 
93+target_compile_definitions(cann_hixl_base PRIVATE
94+ HCCN_TEST_CONF_PATH="${HIXL_CODE_DIR}/tests/depends/llm_datadist/src/hccn_test.conf"
95+)
96+ 
97+target_compile_options(cann_hixl_base PRIVATE
98+ ${DT_COMMON_COMPILE_OPTION}
99+)
@@ -37,6 +37,10 @@ HcclResult HcclRemapRegistedMemory(HcclComm *comm, CommMem *memInfoArray, uint64
37}37}
38 38 
39HcclResult HcclRegisterGlobalMem(CommMem *mem, void **memHandle) {39HcclResult HcclRegisterGlobalMem(CommMem *mem, void **memHandle) {
40+ static int64_t mock_handle = 1;
41+ if (memHandle != nullptr) {
42+ *memHandle = reinterpret_cast<void *>(&mock_handle);
43+ }
40 return HcclResult::HCCL_SUCCESS;44 return HcclResult::HCCL_SUCCESS;
41}45}
42 46 
@@ -76,3 +76,43 @@ target_compile_options(metadef_wrapper_stub PRIVATE
76 ${DT_COMMON_COMPILE_OPTION}76 ${DT_COMMON_COMPILE_OPTION}
77 -Xlinker -export-dynamic77 -Xlinker -export-dynamic
78)78)
79+ 
80+set(HIXL_PY_SRC_FILES
81+ "${HIXL_CODE_DIR}/src/python/hixl_py/hixl_py.cc")
82+ 
83+add_library(hixl_py_stub MODULE
84+ ${HIXL_PY_SRC_FILES}
85+)
86+ 
87+target_include_directories(hixl_py_stub PRIVATE
88+ ${HI_PYTHON_INC}
89+ ${pybind11_INCLUDE_DIR}
90+ ${HIXL_CODE_DIR}/include
91+ ${HIXL_CODE_DIR}/src/hixl
92+)
93+ 
94+target_link_libraries(hixl_py_stub PRIVATE
95+ intf_pub
96+ hccl_headers
97+ metadef_headers
98+ cann_hixl_base
99+ error_manager_stub
100+ -Wl,-as-needed
101+ ${DT_COMMON_LINK_OPTION}
102+)
103+ 
104+set_target_properties(hixl_py_stub
105+ PROPERTIES
106+ PREFIX ""
107+)
108+ 
109+set_target_properties(hixl_py_stub PROPERTIES OUTPUT_NAME "hixl")
110+ 
111+target_compile_definitions(hixl_py_stub PRIVATE
112+ PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF
113+)
114+ 
115+target_compile_options(hixl_py_stub PRIVATE
116+ ${DT_COMMON_COMPILE_OPTION}
117+ -Xlinker -export-dynamic
118+)
@@ -0,0 +1,558 @@
1+#!/usr/bin/env python3
2+# -*- coding: utf-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+ 
13+import ctypes
14+import logging
15+import unittest
16+ 
17+import hixl
18+ 
19+logging.basicConfig(format="%(asctime)s %(message)s", level=logging.INFO)
20+ 
21+ 
22+_DEFAULT_OPTIONS = {
23+ hixl.OPTION_AUTO_CONNECT: "1",
24+}
25+ 
26+ 
27+def _alloc_cpu_mem(size):
28+ buf = ctypes.create_string_buffer(size)
29+ addr = ctypes.addressof(buf)
30+ return hixl.MemDesc(addr, size), buf
31+ 
32+ 
33+def _alloc_npu_mem(size):
34+ buf = ctypes.create_string_buffer(size)
35+ addr = ctypes.addressof(buf)
36+ return hixl.MemDesc(addr, size), buf
37+ 
38+ 
39+def _create_engine():
40+ engine = hixl.Hixl()
41+ ret = engine.initialize("127.0.0.1:0", _DEFAULT_OPTIONS)
42+ assert ret == hixl.SUCCESS, f"initialize failed: {ret}"
43+ return engine
44+ 
45+ 
46+class HixlModuleImportTest(unittest.TestCase):
47+ def test_status_constants(self):
48+ self.assertEqual(hixl.SUCCESS, 0)
49+ self.assertEqual(hixl.FAILED, 503900)
50+ self.assertEqual(hixl.PARAM_INVALID, 103900)
51+ self.assertEqual(hixl.TIMEOUT, 103901)
52+ self.assertEqual(hixl.NOT_CONNECTED, 103902)
53+ self.assertEqual(hixl.ALREADY_CONNECTED, 103903)
54+ self.assertEqual(hixl.NOTIFY_FAILED, 103904)
55+ self.assertEqual(hixl.UNSUPPORTED, 103905)
56+ self.assertEqual(hixl.RESOURCE_EXHAUSTED, 203900)
57+ 
58+ def test_enum_constants(self):
59+ self.assertEqual(int(hixl.MemType.MEM_DEVICE), 0)
60+ self.assertEqual(int(hixl.MemType.MEM_HOST), 1)
61+ self.assertEqual(int(hixl.TransferOp.READ), 0)
62+ self.assertEqual(int(hixl.TransferOp.WRITE), 1)
63+ self.assertEqual(int(hixl.FeatureType.AUTO_CONNECT), 0)
64+ self.assertEqual(int(hixl.FeatureType.CLIENT_SERVER_COMM), 1)
65+ self.assertEqual(hixl.MEM_DEVICE, 0)
66+ self.assertEqual(hixl.MEM_HOST, 1)
67+ 
68+ self.assertEqual(hixl.READ, 0)
69+ self.assertEqual(hixl.WRITE, 1)
70+ 
71+ self.assertEqual(hixl.AUTO_CONNECT, 0)
72+ self.assertEqual(hixl.CLIENT_SERVER_COMM, 1)
73+ 
74+ def test_transfer_status_enum(self):
75+ self.assertEqual(int(hixl.TransferStatus.WAITING), 0)
76+ self.assertEqual(int(hixl.TransferStatus.COMPLETED), 1)
77+ self.assertEqual(int(hixl.TransferStatus.TIMEOUT), 2)
78+ self.assertEqual(int(hixl.TransferStatus.FAILED), 3)
79+ 
80+ def test_async_connect_status_enum(self):
81+ self.assertEqual(int(hixl.AsyncConnectStatus.NOT_CONNECT), 0)
82+ self.assertEqual(int(hixl.AsyncConnectStatus.CONNECT_PENDING), 1)
83+ self.assertEqual(int(hixl.AsyncConnectStatus.CONNECTING), 2)
84+ self.assertEqual(int(hixl.AsyncConnectStatus.CONNECTED), 3)
85+ self.assertEqual(int(hixl.AsyncConnectStatus.CONNECT_FAILED), 4)
86+ self.assertEqual(int(hixl.AsyncConnectStatus.DISCONNECT_PENDING), 5)
87+ self.assertEqual(int(hixl.AsyncConnectStatus.DISCONNECTING), 6)
88+ 
89+ def test_feature_support_constants(self):
90+ self.assertEqual(hixl.FEATURE_SUPPORTED, 1)
91+ self.assertEqual(hixl.FEATURE_NOT_SUPPORTED, 0)
92+ 
93+ def test_option_constants(self):
94+ self.assertIsInstance(hixl.OPTION_ENABLE_USE_FABRIC_MEM, str)
95+ self.assertIsInstance(hixl.OPTION_RDMA_TRAFFIC_CLASS, str)
96+ self.assertIsInstance(hixl.OPTION_RDMA_SERVICE_LEVEL, str)
97+ self.assertIsInstance(hixl.OPTION_BUFFER_POOL, str)
98+ self.assertIsInstance(hixl.OPTION_GLOBAL_RESOURCE_CONFIG, str)
99+ self.assertIsInstance(hixl.OPTION_AUTO_CONNECT, str)
100+ self.assertIsInstance(hixl.OPTION_LOCAL_COMM_RES, str)
@@ -458,9 +458,12 @@ run() {
458 unset LD_PRELOAD458 unset LD_PRELOAD
459 cp ${BUILD_PATH}/tests/depends/python/llm_datadist_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/459 cp ${BUILD_PATH}/tests/depends/python/llm_datadist_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/
460 cp ${BUILD_PATH}/tests/depends/python/metadef_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/460 cp ${BUILD_PATH}/tests/depends/python/metadef_wrapper.so ${BASEPATH}/src/python/llm_datadist/llm_datadist/
461+ cp ${BUILD_PATH}/tests/depends/python/hixl.so ${BASEPATH}/src/python/hixl_py/
461 cp -r ${BASEPATH}/tests/python ./462 cp -r ${BASEPATH}/tests/python ./
462 PYTHON_ORIGINAL_PATH=$PYTHONPATH463 PYTHON_ORIGINAL_PATH=$PYTHONPATH
463- export PYTHONPATH=${BASEPATH}/src/python/llm_datadist/464+ export PYTHONPATH=${BASEPATH}/src/python/llm_datadist/:${BASEPATH}/src/python/hixl_py/
465+ LD_LIBRARY_PATH_ORIGINAL=$LD_LIBRARY_PATH
466+ export LD_LIBRARY_PATH=${BUILD_PATH}/tests/depends/hixl/:${BUILD_PATH}/tests/depends/llm_datadist/:${BUILD_PATH}/tests/depends/slog/:${BUILD_PATH}/tests/depends/mmpa/:${BUILD_PATH}/tests/depends/hccl/:${BUILD_PATH}/tests/depends/ascendcl/:${BUILD_PATH}/tests/depends/runtime/:${BUILD_PATH}/tests/depends/msprof/:${BUILD_PATH}/tests/depends/dcmi/:${BUILD_PATH}/tests/depends/dsmi/:${BUILD_PATH}/tests/depends/error_manager/
464 467 
465 echo "----------st start----------"468 echo "----------st start----------"
466 if [[ "X$ENABLE_ASAN" = "XON" ]]; then469 if [[ "X$ENABLE_ASAN" = "XON" ]]; then
@@ -472,14 +475,17 @@ run() {
472 if [[ "$?" -ne 0 ]]; then475 if [[ "$?" -ne 0 ]]; then
473 echo "!!! PY TEST FAILED, PLEASE CHECK YOUR CHANGES !!!"476 echo "!!! PY TEST FAILED, PLEASE CHECK YOUR CHANGES !!!"
474 rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so477 rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so
478+ rm -f ${BASEPATH}/src/python/hixl_py/*.so
475 exit 1;479 exit 1;
476 fi480 fi
477 rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so481 rm -f ${BASEPATH}/src/python/llm_datadist/llm_datadist/*.so
482+ rm -f ${BASEPATH}/src/python/hixl_py/*.so
478 483 
479 if [[ "X$ENABLE_ASAN" = "XON" ]]; then484 if [[ "X$ENABLE_ASAN" = "XON" ]]; then
480 unset LD_PRELOAD485 unset LD_PRELOAD
481 fi486 fi
482 export PYTHONPATH=${PYTHON_ORIGINAL_PATH}487 export PYTHONPATH=${PYTHON_ORIGINAL_PATH}
488+ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH_ORIGINAL}
483 fi489 fi
484 490 
485 if [[ "X$ENABLE_GCOV" = "XON" ]]; then491 if [[ "X$ENABLE_GCOV" = "XON" ]]; then