用户要求先用 1.0.1 对齐两端再把 nax MPC 跑通。闭环达成:
x86_64 Ray node 73bfdc0a… nax site=b MPC 35
armv7 Ray node 235afb22… nax site=a MPC 35
同一进程既是 Ray driver 又是 MPC 参与方;node_id 由 raylet 握手分配,
两端不同即「真的挂在两个节点上」的证据。35 = (1·4+1)+(2·5+1)+(3·6+1)。
1.0.1 shim(ray/nax_ray_shim_101.cc)与 2.59 的六个接口差异:
CoreWorkerProcess 无独立头、TaskExecutionCallback 只有 8 参数、
GcsClientOptions 位置参数、无 GetNodeToConnectForDriver/GetNextJobID、
无 ray::core 命名空间、GcsNodeInfo 无 node_manager_port。
两个必踩的坑:
- options.num_workers 必须显式设 1(1.0.1 有 RAY_CHECK(>0),默认 0 abort)
- gcs_options 要指向 Redis(6400)而非 gcs_server(6402),指错报
Protocol error got "\x00",看着像协议问题其实是端口给错
同一版本两个架构的 string ABI 不同(关键):
x86_64 _raylet.so 是旧 ABI(0 个 cxx11),armv7 是新 ABI(423 个)。
搞错的表现是运行期 basic_string::_M_create 异常,错误信息不提 ABI。
编译补丁自动打在解出来的头上:client_call.h 的 vector<CompletionQueue> 换 deque
(grpc 1.51 删了移动构造)、影子 arrow/buffer.h、-Dgrpc_impl=grpc。
Python 符号 x86 缺 8 个 / armv7 缺 2 个,shim 零值占位(不执行 Python 代码)。
nax-cli 加可选 feature ray:设 NAX_RAY_RAYLET 即注册 driver,默认构建仍是
纯静态单二进制。rpath 放在 nax-cli 的 build.rs(link-arg-bins),放 nax-ray
里传不到依赖方的 bin。
新增 docs/RAY_CORE_101.md、ray/{nax_ray_shim_101.cc,build101.sh,
build101_armv7.sh,test101.py,test101_arm.c,verify101.sh}、ray/armv7/mpc_ray.sh;
nax-ray 重写为 1.0.1 签名;README 状态表更新。
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
import ctypes, sys
|
|
|
|
|
|
class Cfg(ctypes.Structure):
|
|
_fields_ = [
|
|
("gcs_addr", ctypes.c_char_p),
|
|
("node_ip", ctypes.c_char_p),
|
|
("raylet_socket", ctypes.c_char_p),
|
|
("plasma_socket", ctypes.c_char_p),
|
|
("node_manager_port", ctypes.c_int),
|
|
("job_id_int", ctypes.c_int),
|
|
("language", ctypes.c_int),
|
|
("driver_name", ctypes.c_char_p),
|
|
]
|
|
|
|
|
|
lib = ctypes.CDLL(sys.argv[1] if len(sys.argv) > 1 else "/tmp/libnax_ray.so")
|
|
lib.nax_ray_last_error.restype = ctypes.c_char_p
|
|
|
|
gcs = sys.argv[2] if len(sys.argv) > 2 else "127.0.0.1:6402"
|
|
rsock = sys.argv[3] if len(sys.argv) > 3 else "/tmp/raylet_x.sock"
|
|
psock = sys.argv[4] if len(sys.argv) > 4 else "/tmp/plasma_x.sock"
|
|
port = int(sys.argv[5]) if len(sys.argv) > 5 else 6403
|
|
lang = int(sys.argv[6]) if len(sys.argv) > 6 else 2 # 2 = CPP
|
|
|
|
cfg = Cfg(gcs.encode(), b"127.0.0.1", rsock.encode(), psock.encode(), port, 1, lang, b"nax_driver")
|
|
buf = ctypes.create_string_buffer(16384)
|
|
|
|
print(f"--- init gcs={gcs} raylet={rsock} port={port} lang={lang}")
|
|
rc = lib.nax_ray_init(ctypes.byref(cfg), buf, 16384)
|
|
print("init rc =", rc)
|
|
if rc != 0:
|
|
print("err:", lib.nax_ray_last_error().decode())
|
|
sys.exit(1)
|
|
print(buf.value.decode())
|
|
|
|
import time
|
|
hold = int(sys.argv[7]) if len(sys.argv) > 7 else 0
|
|
rc2 = lib.nax_ray_probe(buf, 16384)
|
|
print("probe rc =", rc2, buf.value.decode() if rc2 == 0 else lib.nax_ray_last_error().decode())
|
|
if hold:
|
|
print(f"holding {hold}s ...", flush=True)
|
|
time.sleep(hold)
|
|
lib.nax_ray_shutdown()
|
|
print("shutdown done")
|