|
| 1 | +[[中文版](./install_rpu_cn.md)|English] |
| 2 | + |
| 3 | +## 💫 Huixi Intelligence(辉羲智能)[rpu](https://github.com/flagos-ai/FlagTree/tree/triton_v3.6.x/third_party/rpu/) |
| 4 | + |
| 5 | +- Based on Triton 3.6, aarch64 |
| 6 | + |
| 7 | +The **Rhino RPU** is the AI accelerator inside Huixi Intelligence's 光至 R1 SoC |
| 8 | +([rhino.auto](https://www.rhino.auto/)). Unlike the CPU/GPU backends, the RPU |
| 9 | +backend has **no preinstalled image and no CPU simulator** — it compiles and |
| 10 | +runs only on a physical R1 SoC board, and its driver, runtime, and toolchain are |
| 11 | +obtained from the vendor. Build and test directly on the board. |
| 12 | + |
| 13 | +> The RPU driver, runtime, and LLVM toolchain are not publicly distributed. |
| 14 | +> Contact **Huixi Intelligence** ([rhino.auto](https://www.rhino.auto/)) to |
| 15 | +> obtain them. |
| 16 | +
|
| 17 | +### 1. Build and run environment |
| 18 | + |
| 19 | +#### 1.1 Hardware and OS |
| 20 | + |
| 21 | +- An R1 SoC board running aarch64 Linux that exposes the RPU device node |
| 22 | + `/dev/rpu` (kernel module loaded). |
| 23 | +- Minimum 24 GB RAM and 60 GB free disk. |
| 24 | +- Python 3.10+, `cmake >= 3.20`, `ninja`, and a recent `pip`. |
| 25 | + |
| 26 | +There is no Docker image for the RPU backend; all steps below run natively on |
| 27 | +the R1 SoC board. Verify the device node: |
| 28 | + |
| 29 | +```shell |
| 30 | +ls /dev/rpu |
| 31 | +``` |
| 32 | + |
| 33 | +#### 1.2 RPU driver and runtime (vendor-provided) |
| 34 | + |
| 35 | +Install, per the vendor's instructions: |
| 36 | + |
| 37 | +- the RPU kernel driver that provides `/dev/rpu`; |
| 38 | +- the `rhino-launch-kernel` runtime library (`librhino_launch.so`), used by the |
| 39 | + on-board launch_kernel test. |
| 40 | + |
| 41 | +#### 1.3 RPU LLVM toolchain (vendor-provided) |
| 42 | + |
| 43 | +The RPU backend uses a custom LLVM as its `.rpubin` emitter. Point |
| 44 | +`RPU_LLVM_ROOT` at the toolchain install prefix (the directory containing |
| 45 | +`bin/clang`): |
| 46 | + |
| 47 | +```shell |
| 48 | +# Toolchain layout: |
| 49 | +# $RPU_LLVM_ROOT/bin/clang |
| 50 | +# $RPU_LLVM_ROOT/lib/... |
| 51 | +export RPU_LLVM_ROOT=/opt/rpu/llvm |
| 52 | +``` |
| 53 | + |
| 54 | +### 2. Installation Commands |
| 55 | + |
| 56 | +The RPU backend is built from source on the board. There is no source-free |
| 57 | +(pip wheel) installation. |
| 58 | + |
| 59 | +#### 2.1 Pull the source code |
| 60 | + |
| 61 | +```shell |
| 62 | +cd ~ |
| 63 | +git clone https://github.com/flagos-ai/FlagTree.git |
| 64 | +cd FlagTree |
| 65 | +git checkout -b triton_v3.6.x origin/triton_v3.6.x |
| 66 | +``` |
| 67 | + |
| 68 | +#### 2.2 Build from source |
| 69 | + |
| 70 | +```shell |
| 71 | +export FLAGTREE_BACKEND=rpu |
| 72 | +export MAX_JOBS=8 # tune to available RAM |
| 73 | + |
| 74 | +cd ~/FlagTree/python |
| 75 | +pip3 install -r requirements.txt # build-time dependencies |
| 76 | + |
| 77 | +cd ~/FlagTree |
| 78 | +# Initial build |
| 79 | +pip3 install . --no-build-isolation -v |
| 80 | +# Rebuild after source changes |
| 81 | +pip3 install . --no-build-isolation --force-reinstall -v |
| 82 | +``` |
| 83 | + |
| 84 | +The Triton MLIR LLVM is downloaded automatically from the public oaitriton blob |
| 85 | +the first time setup runs; no manual action is needed. |
| 86 | + |
| 87 | +### 3. Testing and validation |
| 88 | + |
| 89 | +#### 3.1 Unit tests |
| 90 | + |
| 91 | +The compile tests drive the real toolchain, so set `RPU_LLVM_ROOT` first (the |
| 92 | +directory containing `bin/clang`). If it is unset or its path is missing, the |
| 93 | +tests stop with a clear message naming the variable. |
| 94 | + |
| 95 | +```shell |
| 96 | +cd ~/FlagTree |
| 97 | +export RPU_LLVM_ROOT=/opt/rpu/llvm |
| 98 | +pytest -s third_party/rpu/python/test/unit |
| 99 | +``` |
| 100 | + |
| 101 | +#### 3.2 On-board launch_kernel check |
| 102 | + |
| 103 | +This needs the `launch_kernel_runner` CLI, a thin front-end over the |
| 104 | +`rhino-launch-kernel` runtime library. Build it together with the backend by |
| 105 | +enabling `RPU_BUILD_LAUNCH_RUNNER` (off by default; it needs the |
| 106 | +`rhino-launch-kernel` install), then run the smoke test on a board with |
| 107 | +`/dev/rpu`: |
| 108 | + |
| 109 | +```shell |
| 110 | +TRITON_APPEND_CMAKE_ARGS="-DRPU_BUILD_LAUNCH_RUNNER=ON -DCMAKE_PREFIX_PATH=/path/to/rhino-launch-kernel/install" \ |
| 111 | + pip3 install . --no-build-isolation --force-reinstall -v |
| 112 | +export RPU_LK_RUNNER=$PWD/third_party/rpu/tools/launch_runner/launch_kernel_runner |
| 113 | +python3 third_party/rpu/python/test/board/lk_board_smoke.py --require-board |
| 114 | +``` |
| 115 | + |
| 116 | +It compiles a small kernel, dispatches it on the device, and compares the result |
| 117 | +to a numpy golden. |
| 118 | + |
| 119 | +Refer to [Tests of rpu backend](https://github.com/flagos-ai/FlagTree/blob/triton_v3.6.x/.github/workflows/rpu3.6-build-and-test.yml) |
0 commit comments