g1 / README.md
JingwuLuo's picture
Add README.md
4df08ca verified
|
Raw History Blame Contribute Delete
4.71 kB
---
license: other
tags:
- robotics
- unitree-g1
- pi0.5
- ggml
---
# G1 pi0.5 deployment bundle
Migration snapshot of an on-Orin pi0.5 inference stack for a Unitree G1:
a WebSocket policy server running `pi0.5-ggml` (CUDA, `sm_87`) on the robot's
Jetson Orin NX, plus the GGUF exports it serves and the client it talks to.
Captured 2026-09-17 from `unitree-g1-nx` (Jetson Orin NX, JetPack / CUDA 12.6,
15 GB unified memory).
## Contents
| path | size | what |
|---|---:|---|
| `g1-migration-code.zip` | 124 MB | all source (see below) |
| `models/gguf_fp16/` | 6.3 GB | FP16 GGUF export — the accuracy baseline |
| `models/gguf_q8_h32/` | 3.9 GB | Q8_0 GGUF export — the quantized candidate |
| `models/stack-cube-eef-24k_pytorch/` | 7.3 GB | source PyTorch checkpoint (copy of `LGG100/stack-cube-eef-24k`) |
`g1-migration-code.zip` unpacks to:
```
pi0.5-server/ the policy server + open-loop eval harness (written for this deployment)
g1-client/ robot-side client (git: luo-jingw/g1-client)
pi05-main/ pi0.5-ggml, master (git: luo-jingw/pi0.5-ggml)
pi05-neowise/ pi0.5-ggml, amir_neowise_q8 branch
datasets/ 3 episodes of LGG100/Stack-the-cubes, for the open-loop test
models/ckpt_h32/config.json the corrected export config (see below)
```
`build/` directories, `.git/`, and `__pycache__` were excluded. The three source
trees are live git repos upstream — prefer cloning them and using this zip only
for `pi0.5-server/` and to see exactly which commits were deployed.
Start at `pi0.5-server/README.md`.
## Two corrections baked into these exports
Both were real bugs found while bringing this up; the models here have them fixed.
**1. `action_horizon` must be 32, not 10.** The PyTorch checkpoint's
`config.json` says `action_horizon = 10`, which is a placeholder borrowed during
conversion, not the training value. Exporting with 10 made the arm travel only
**4–5 mm per chunk** — it looked like the robot was barely moving. At 32 it is
20–38 mm. Corroborated independently: GGUFs built from this checkpoint through
the correct pipeline elsewhere all carry `action_horizon = 32`.
`models/ckpt_h32/config.json` in the zip is the corrected config used for these
exports.
**2. Do not feed the model a discrete state vector.** `pi05_g1_eef` was not
trained with state as an input (confirmed by the model owner). pi0.5-ggml only
wants one for checkpoints trained with `discrete_state_input=True`
(`include/pi05.h:92`); passing it otherwise wraps the prompt into a
`Task:/State:` form the model never saw. The server accepts
`observation.state` on the wire but does not forward it unless
`--discrete-state` is given.
Measured open-loop, FP16, mean EEF position error over a chunk:
**22.2 mm with state vs 9.0 mm without**.
## Measured on this hardware
Open-loop against `LGG100/Stack-the-cubes` (24 samples / 3 episodes,
`--steps 10`, state omitted). Mean EEF position error, both arms:
| | t=0 | whole chunk | latency | peak host mem |
|---|---:|---:|---:|---:|
| FP16 (stock ggml) | **8.7 mm** | **9.0 mm** | ~1484 ms | 9.8 GB |
| Q8_0 + NEOWISE variant 4 | 24.4 mm | 28.5 mm | ~1150 ms | 10.0 GB |
| "hold current pose" baseline | — | 17.0 mm | — | — |
The NEOWISE Q8 INT8 kernel (`amir_neowise_q8` branch) costs **~3.2× accuracy**
here and does not beat a do-nothing baseline. Its published −25 % speedup was
measured on AGX Thor (Blackwell); `docs/neowise.md` listed Orin as unmeasured.
On this Orin NX it is also *slower* than stock in end-to-end benchmark
(1227.8 ms vs 1199.7 ms) and uses 2.5 GB more memory.
Caveats on the accuracy numbers: `Stack-the-cubes` stores **joint** actions
while this is an **EEF** checkpoint, so ground truth is pushed through the same
forward kinematics the runtime uses — this is not the checkpoint's training set,
and the FK frame convention is unverified against training. A frame mismatch
would shift all absolute errors; the FP16-vs-Q8 comparison is unaffected. The
dataset is also `Unitree_G1_Dex1_Sim` (simulation), and open-loop error is not a
success rate.
## Rebuilding
```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DGGML_CUDA=ON -DGGML_CUDA_NO_VMM=ON \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
-DCUDAToolkit_ROOT=/usr/local/cuda \
-DCMAKE_CUDA_ARCHITECTURES=87 \
-DCMAKE_CUDA_RUNTIME_LIBRARY=Shared \
-DPython_EXECUTABLE=<py3.11 env>/bin/python
cmake --build build -j6
```
`sm_87` for Orin; CMake < 3.24 cannot auto-detect it. `nvcc` is not on PATH on
JetPack. Python 3.11 + pybind11. For the neowise build add
`-DUSE_NEOWISE_Q8=ON -DCUSTOM_KERNEL_VERSION=4` (variant 6 is a Blackwell
CUTLASS kernel and cannot run on Ampere).