ci / gate (push) Waiting to run
- 项目与文档标题:nax-rs → ssw-mpc(尚数网-多方安全计算),二进制 nax → mpc - 18 个 crate 及目录 nax-* → mpc-*,Rust 引用 nax_* → mpc_* - 环境变量、C 符号、构建/部署脚本:NAX_* → MPC_*、libnax_ray.so → libmpc_ray.so - 保留协议域分隔常量与 refs/nax 参考实现路径,维持 golden 向量与历史数据兼容 - 新增 [profile.dev] incremental=false
229 lines
10 KiB
Markdown
229 lines
10 KiB
Markdown
# Ray 1.0.1 在 armv7 上实测记录
|
||
|
||
**结论先说:Ray 在 armv7 上是能跑的,而且我们跑通了完整节点。**
|
||
之前 `docs/RAY_CORE.md` §5 写的「Zynq 上不通」是错的,已改。
|
||
|
||
## 1. 包从哪来
|
||
|
||
PyPI 上确实没有,但**社区编过**:
|
||
|
||
| 来源 | 版本 | Python | 链接 |
|
||
|---|---|---|---|
|
||
| PidgeyBE | 1.0.1 | cp36 | `github.com/ray-project/ray/files/5703429/ray_armv7l_32bit.zip` |
|
||
| PeterPirog | 1.2.0 | cp38 | `github.com/PeterPirog/Raspberry_armv7_builds/tree/main/ray` |
|
||
|
||
上游 issue:[ray-project/ray#12128](https://github.com/ray-project/ray/issues/12128)。
|
||
1.2.0 之后没人再编,官方 2.0.0.dev 在 armv7 上就失败了。
|
||
|
||
**唯一需要的源码改动是链接参数**(PeterPirog 在讨论区的原话):
|
||
|
||
```
|
||
# python/setup.py,给 bazel build 加一个 linkopt
|
||
["build", "--linkopt=-latomic", "--"] + bazel_targets
|
||
```
|
||
|
||
原因是 32 位 ARM 上 `std::atomic<int64_t>` 会落成 `__atomic_load_8` /
|
||
`__atomic_fetch_add_8`,libgcc 里没有内联版本,必须显式链 `libatomic`。
|
||
**这不是移植工程,是加一个编译/链接宏。**
|
||
|
||
## 2. 实物核对(2026-10-30 实测)
|
||
|
||
`ray-1.0.1-cp36-cp36m-linux_armv7l.whl`:19 MB 压缩、64 MB 解压。
|
||
|
||
| 组件 | 大小 | 架构 |
|
||
|---|---|---|
|
||
| `_raylet.so` | 16.4 MB | ELF32 ARM,flags `0x5000400`(EABI5 + hard-float) |
|
||
| `raylet` | 13.1 MB | 同上 |
|
||
| `gcs_server` | 10.9 MB | 同上 |
|
||
| `libray_redis_module.so` | 3.6 MB | 同上 |
|
||
| `redis-server` | 3.4 MB | 同上 |
|
||
| `plasma_store_server` | 0.8 MB | 同上 |
|
||
|
||
C++ 侧合计约 **44.6 MB**(对照 x86_64 的 2.59:`_raylet.so` 44 MB + raylet 35 MB + gcs 40 MB)。
|
||
|
||
`_raylet.so` 的动态符号:10562 条,其中 `ray::` 命名空间 **2040** 个,且
|
||
`CoreWorkerProcess` 全套导出:
|
||
|
||
```
|
||
T _ZN3ray17CoreWorkerProcess10InitializeERKNS_17CoreWorkerOptionsE@@VERSION_1.0
|
||
T _ZN3ray17CoreWorkerProcess13GetCoreWorkerEv@@VERSION_1.0
|
||
T _ZN3ray17CoreWorkerProcess20RunTaskExecutionLoopEv@@VERSION_1.0
|
||
T _ZN3ray17CoreWorkerProcess8ShutdownEv@@VERSION_1.0
|
||
```
|
||
|
||
符号名里**没有 `B5cxx11`** —— 和 2.59 一样是旧 ABI(`_GLIBCXX_USE_CXX11_ABI=0`)。
|
||
也就是说 `ray/mpc_ray_shim.cc` 那套「绕开 bazel、直接链 `_raylet.so`」的做法
|
||
在 armv7 上同样成立,只是 API 要从 2.59 回退到 1.0.1。
|
||
|
||
## 3. 完整节点跑通
|
||
|
||
环境:x86_64 沙箱 + `qemu-arm-static -L /usr/lib/arm-linux-gnueabihf`
|
||
(qemu **只做用户态指令翻译**,不是模拟编译,跑的是真 ELF32 ARM 二进制)。
|
||
|
||
手工做掉 `ray start --head` 的 bootstrap(因为板上没有 python3.6),
|
||
`ray/armv7/run_node.sh` 完整复现:
|
||
|
||
1. 主 redis `:6390` + 分片 redis `:6391`,都 `--loadmodule libray_redis_module.so`
|
||
2. 播种 5 个键(等同 `services.py::start_redis`):
|
||
`NumRedisShards=1`、`RedirectOutput=0`、`JobCounter=0`、`ray_version`、`RedisShards`
|
||
3. `gcs_server :6392`
|
||
4. `plasma_store_server`(注意容器 `/dev/shm` 只有 64 MB,要 `-d /tmp/plasmadir -m 50M`)
|
||
5. `raylet --node_manager_port=6393`
|
||
|
||
实测输出:
|
||
|
||
```
|
||
Module 'ray' loaded from .../libray_redis_module.so
|
||
GcsServer server started, listening on port 6392
|
||
Gcs server address = 127.0.0.1:6392
|
||
ObjectManager server started, listening on port 34591
|
||
node_manager.cc:178] Initializing NodeManager with ID ebb89cb915e55e838bcadeb10b7bcb16b9cfb643
|
||
NodeManager server started, listening on port 6393
|
||
service_based_accessor.cc:775] Received notification for node id = ebb89cb9…, IsAlive = 1
|
||
raylet 存活 ✅
|
||
```
|
||
|
||
`IsAlive = 1` 是 GCS 收到 raylet 注册后的确认。整条链
|
||
**redis(带 ray 模块)→ gcs_server → plasma → raylet** 在 armv7 上都成立。
|
||
|
||
### 两个不是 32 位问题的坑
|
||
|
||
| 现象 | 真因 | 处理 |
|
||
|---|---|---|
|
||
| `Check failed: No entry found for NumRedisShards` | redis 没被 bootstrap 播种 | 手工写 5 个键 |
|
||
| `System memory request exceeds memory available in /dev/shm` | 容器 `/dev/shm` 只有 64 MB | `-d /tmp/plasmadir -m 50M` |
|
||
| `At least one of Python/Java/CPP worker command should be provided` | raylet 硬性校验 | `--num_initial_workers=0` 时给 `--cpp_worker_command=/bin/true` |
|
||
|
||
## 4. 但这条路对 mpc 的代价(必须说清)
|
||
|
||
能跑 ≠ 该用。三个真实代价:
|
||
|
||
1. **版本断层**。1.0.1 是 2020-12 的代码,GCS 协议和 2.59 不同,**接不进现代 Ray 集群**。
|
||
要么整集群降级到 1.x,要么边缘独立成一个小集群。
|
||
2. **要 python3.6**。wheel 是 cp36,`_raylet.so` 是 CPython 扩展(和 2.59 同样有几百个
|
||
`Py*` 未定义符号)。板上跑得装 python3.6,或者像 `crates/mpc-ray/build.rs` 那样链
|
||
libpython 兜住符号——但 Debian 12 / PetaLinux 都不带 3.6。
|
||
3. **44.6 MB 二进制 + plasma 内存**。ACZ7015 是 1 GB DDR3,放得下;512 MB 的板子就悬。
|
||
|
||
## 5. 三个选项的取舍
|
||
|
||
| 方案 | 工作量 | 能得到 | 风险 |
|
||
|---|---|---|---|
|
||
| **A. 用 1.0.1 armv7 + 移植 shim** | 中(改 ~250 行 shim 到 1.0 API,交叉编译 shim) | 边缘板上真的跑 Ray,能加入 1.x 集群 | 2020 年代码;要 python3.6 |
|
||
| **B. 自己编 2.59 armv7** | 大(bazel crosstool + 38 依赖全过一遍 + 未知 32 位问题) | 与现代 Ray 协议一致 | 未知量大,可能卡死在某个依赖 |
|
||
| **C. 保持 mpc-orch** | 零(已完成,661 行) | 放置 + 成员,任意架构 | 没有 Ray 生态 |
|
||
|
||
**当前选择:C 作为默认,A 作为「确实需要 Ray 生态」时的备选。**
|
||
B 不建议——为一个我们只用「放置」的能力去背 38 个依赖的 32 位交叉编译。
|
||
|
||
## 6. 跨版本兼容性实测:1.0.1 ⟷ 2.59 双向都不通
|
||
|
||
结论:**不兼容,且不是「协商失败」,是传输层就不是一个协议。**
|
||
|
||
### 1.0.1 节点想加入 2.59 集群
|
||
|
||
```
|
||
$ redis-cli -h 169.254.68.6 -p 6379 ping
|
||
Error: Protocol error, got "\x00" as reply type byte
|
||
|
||
$ # 1.0.1 armv7 raylet --redis_address=<2.59 head> --redis_port=6379
|
||
F redis_client.cc:114] Check failed: _s.ok()
|
||
Bad status: RedisError: Protocol error, got "\x00" as reply type byte
|
||
```
|
||
|
||
原因:Ray 2.0 把 Redis 从 GCS 后端彻底移除,head 的 6379 从 RESP 换成了 gRPC(HTTP/2)。
|
||
1.0.1 的 raylet 一上来就发 RESP 的 `PING`,收到的第一个字节是 HTTP/2 的 `\x00`。
|
||
|
||
### 2.59 节点想加入 1.0.1 集群
|
||
|
||
```
|
||
$ ray start --address=127.0.0.1:6402 # 1.0.1 的 gcs_server
|
||
RuntimeError: Failed to connect to GCS. Last connection error:
|
||
ray.exceptions.RpcError: RPC error:
|
||
```
|
||
|
||
gRPC 这一层通了,但 GCS 的 service/protobuf 定义在 1.x → 2.x 之间已经改过,
|
||
握手拿不到可用的服务。
|
||
|
||
### 所以
|
||
|
||
跨版本混部**没有中间路线**。要么整集群 2.x(那么 armv7 节点进不来,
|
||
因为 2.59 没有 armv7 构建),要么整集群 1.0.1(那么 armv7 节点能进来,
|
||
但要接受 2020 年的代码)。这就是「对成」的意思——把两端都放在 1.0.1 上。
|
||
|
||
## 7. 混合架构集群实测:x86_64 原生 + armv7,同为 1.0.1
|
||
|
||
`ray/armv7/mixed_cluster.sh`:x86_64 用 1.0.1 的 `manylinux1_x86_64` wheel 里的
|
||
`redis-server` / `gcs_server` / `raylet` / `plasma_store_server` 原生跑;
|
||
armv7 那一侧用 qemu-arm 跑同版本的二进制。两端同源同版本,只差指令集。
|
||
|
||
实测:
|
||
|
||
```
|
||
=== 4) raylet x86_64(cpu=4)
|
||
I node_manager.cc:178] Initializing NodeManager with ID f85f933f3a48916f22e2e5b32636793c58faee04
|
||
I grpc_server.cc:74] NodeManager server started, listening on port 6403.
|
||
|
||
=== 5) raylet armv7(cpu=2,qemu)
|
||
I node_manager.cc:178] Initializing NodeManager with ID 9f3e5ae101ab5da23e975b27f8f09d0c9ca00f72
|
||
I grpc_server.cc:74] NodeManager server started, listening on port 6413.
|
||
|
||
--- 存活
|
||
raylet x86 ✅
|
||
raylet armv7 ✅
|
||
```
|
||
|
||
**互相看得见**(两侧日志里的节点通知是同一对 ID):
|
||
|
||
x86 raylet 看到:
|
||
```
|
||
9f3e5ae101ab5da23e975b27f8f09d0c9ca00f72, IsAlive = 1
|
||
f85f933f3a48916f22e2e5b32636793c58faee04, IsAlive = 1
|
||
```
|
||
armv7 raylet 看到:
|
||
```
|
||
9f3e5ae101ab5da23e975b27f8f09d0c9ca00f72, IsAlive = 1
|
||
f85f933f3a48916f22e2e5b32636793c58faee04, IsAlive = 1
|
||
I node_manager.cc:949] [HeartbeatAdded]: received heartbeat from unknown client id f85f933f3a48…
|
||
```
|
||
|
||
GCS 表里正好 4 条(2 个节点 × `NODE_RESOURCE` + `CLIENT`),
|
||
`ray/armv7/decode_gcs.py` 直接读 redis 分片解码:
|
||
|
||
```
|
||
shard 键总数: 4
|
||
NODE_RESOURCE node=9f3e5ae101ab5da23e975b27… value=49B → 1000000000 | 127.0.0.1
|
||
NODE_RESOURCE node=f85f933f3a48916f22e2e5b3… value=49B → 1000000000 | 127.0.0.1
|
||
CLIENT node=9f3e5ae101ab5da23e975b27… value=93B → /tmp/raylet_a.sock | /tmp/plasma_a.sock
|
||
CLIENT node=f85f933f3a48916f22e2e5b3… value=93B → /tmp/raylet_x.sock | /tmp/plasma_x.sock
|
||
```
|
||
|
||
CLIENT 条目里的 socket 路径一个 `_a`(armv7)一个 `_x`(x86),是两条独立的注册记录,
|
||
不是同一条被覆盖。
|
||
|
||
**这一步的意义**:armv7 节点不是「能启动」,而是真的作为一个成员挂在集群里,
|
||
和 x86 节点交换心跳、被 GCS 记账。跨指令集组集群这件事在 Ray 1.0.1 上是通的。
|
||
|
||
## 8. 复现
|
||
|
||
```bash
|
||
# 拿包(GitHub 直连,注意 zip 可能被代理截断,用 -C - 续传)
|
||
curl -sSL --http1.1 -C - -o ray_armv7.zip \
|
||
https://github.com/ray-project/ray/files/5703429/ray_armv7l_32bit.zip
|
||
|
||
# 环境:Debian 12 x86_64 容器
|
||
apt-get install -y qemu-user-static redis-tools
|
||
dpkg --add-architecture armhf
|
||
echo 'deb [arch=armhf] http://mirrors.ustc.edu.cn/debian bookworm main' >> /etc/apt/sources.list
|
||
apt-get update && apt-get install -y libc6:armhf libstdc++6:armhf libgcc-s1:armhf
|
||
|
||
# 解包 + 起节点
|
||
python3 -c "import zipfile;zipfile.ZipFile('ray_armv7.zip').extractall('.')"
|
||
python3 -c "import zipfile,glob;zipfile.ZipFile(glob.glob('*.whl')[0]).extractall('/tmp/r17')"
|
||
bash ray/armv7/run_node.sh # armv7 单节点(redis+gcs+plasma+raylet)
|
||
bash ray/armv7/run_gcs_only.sh # 只起 armv7 控制面
|
||
bash ray/armv7/compat_probe.sh # 探测 1.0.1 ⟷ 2.59 不兼容
|
||
bash ray/armv7/mixed_cluster.sh # x86_64 原生 + armv7 混合集群(同为 1.0.1)
|
||
python3 ray/armv7/decode_gcs.py # 解码 GCS 节点表(需集群在跑)
|
||
```
|