26k and fix bpu round
This commit is contained in:
@@ -55,6 +55,30 @@ cd /Users/chenyouyuan/cyy_ws/deploy_go1_pro/deploy_45dim_rl_gym/bpu_quantization
|
||||
./quantize_policy_x5.sh --samples 128 --compare-limit 128
|
||||
```
|
||||
|
||||
速度优先 int8 对照:
|
||||
|
||||
```bash
|
||||
./quantize_policy_x5.sh --quant int8
|
||||
```
|
||||
|
||||
本次 `policy_35k` int8 结果不建议直接实机使用:
|
||||
|
||||
- 产物:`mapper_output_35k_int8_gemm/policy_35k_int8_gemm.bin`
|
||||
- `actions` cosine:`0.981343`
|
||||
- L1/L2/Chebyshev:`0.053474 / 0.018129 / 0.113345`
|
||||
- mapper 编译估计延迟:`314.2 us + 49.7 us`
|
||||
- 板端 `hrt_model_exec perf` 实测:`1.583870 ms`
|
||||
- 板端 C++ bench:`1.56478 ms`
|
||||
|
||||
对比当前 int16:
|
||||
|
||||
- `actions` cosine:`0.998524`
|
||||
- 板端 `hrt_model_exec perf` 实测:`1.401526 ms`
|
||||
- 板端 C++ bench:`1.37792 ms`
|
||||
|
||||
结论:这个模型上默认 int8 既更慢,输出误差也更大。当前继续用
|
||||
`policy_35k_int16_gemm.bin` 更合理。
|
||||
|
||||
Gym BPU 部署入口支持快速切换轮次:
|
||||
|
||||
```bash
|
||||
@@ -105,25 +129,31 @@ cd /root/go1_pro_deploy/deploy_45dim_rl_gym/bpu_deploy_x5/cpp
|
||||
1000
|
||||
```
|
||||
|
||||
已经完成 `policy_robotlab_15000.onnx` 和 `policy_robotlab_6500.onnx` 的 int16
|
||||
量化。RobotLab BPU 部署默认仍使用 6500 版本:
|
||||
已经完成 `policy_robotlab_15000.onnx`、`policy_robotlab_6500.onnx` 和
|
||||
`policy_robotlab_26000.onnx` 的 int16 量化。RobotLab BPU 部署当前默认使用
|
||||
26000 版本:
|
||||
|
||||
- 原始模型:`../policy_robotlab_6500.onnx`
|
||||
- 原始模型:`../policy_robotlab_26000.onnx`
|
||||
- 原始输入:`obs [1, 450]`
|
||||
- BPU 编译输入:`obs_4d [1, 1, 1, 450]`
|
||||
- BPU 输出:`actions [1, 12, 1, 1]`
|
||||
- Docker 镜像:`openexplorer/ai_toolchain_ubuntu_20_x5_cpu:v1.2.8`
|
||||
- `hb_mapper`:`1.24.3`
|
||||
- `hbdk`:`3.49.15`
|
||||
- 当前产物:`mapper_output_6500_gemm/policy_robotlab_6500_int16_gemm.bin`
|
||||
- 当前产物:`mapper_output_26000_gemm/policy_robotlab_26000_int16_gemm.bin`
|
||||
|
||||
`mapper_output*/`、`.hb_check/`、校准数据、中间 ONNX、`hb_mapper` 日志都被
|
||||
`.gitignore` 忽略;需要时按下面步骤重新生成。仓库里只保留脚本和 YAML 配置。
|
||||
|
||||
6500 量化使用 `calibration_data_fast64/` 的 64 个真实样本。原因是
|
||||
26000 量化使用 `calibration_data_26000_robotlab_fast64/` 的 64 个真实样本。原因是
|
||||
`hb_mapper` 会先尝试 calibration batch 8,但当前 4D featuremap 包装会被工具链
|
||||
内部改成固定 batch 的 reshape,batch 8 失败后会退回 batch 1;用 64 样本可以把
|
||||
校准时间从 512 次 batch1 显著降下来。
|
||||
校准时间压到可接受范围。
|
||||
|
||||
如果你要回退到旧版:
|
||||
|
||||
- `mapper_output_6500_gemm/policy_robotlab_6500_int16_gemm.bin`
|
||||
- `mapper_output_gemm/policy_robotlab_15000_int16_gemm.bin`
|
||||
|
||||
## 1. 生成校准数据
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
model_parameters:
|
||||
onnx_model: "./policy_robotlab_26000_bpu4d_gemm.onnx"
|
||||
march: "bayes-e"
|
||||
layer_out_dump: false
|
||||
working_dir: "mapper_output_26000_gemm"
|
||||
output_model_file_prefix: "policy_robotlab_26000_int16_gemm"
|
||||
|
||||
input_parameters:
|
||||
input_name: "obs_4d"
|
||||
input_shape: "1x1x1x450"
|
||||
input_type_rt: "featuremap"
|
||||
input_layout_rt: "NCHW"
|
||||
input_type_train: "featuremap"
|
||||
input_layout_train: "NCHW"
|
||||
norm_type: "no_preprocess"
|
||||
|
||||
calibration_parameters:
|
||||
cal_data_dir: "./calibration_data_26000_robotlab_fast64"
|
||||
cal_data_type: "float32"
|
||||
calibration_type: "default"
|
||||
optimization: "set_all_nodes_int16"
|
||||
per_channel: true
|
||||
|
||||
compiler_parameters:
|
||||
compile_mode: "latency"
|
||||
debug: false
|
||||
optimize_level: "O3"
|
||||
Binary file not shown.
@@ -12,6 +12,7 @@ FLAT_DIM=""
|
||||
SAMPLES=64
|
||||
MIN_SAMPLES=32
|
||||
LOG_PREFIX="rlgym_go1_deploy"
|
||||
CAL_TAG="gym"
|
||||
DOCKER_IMAGE="openexplorer/ai_toolchain_ubuntu_20_x5_cpu:v1.2.8"
|
||||
COMPARE_LIMIT=64
|
||||
RUN_CHECKER=1
|
||||
@@ -33,6 +34,7 @@ Options:
|
||||
--samples N calibration sample count; default 64 for faster mapping
|
||||
--min-samples N minimum valid samples required; default 32
|
||||
--log-prefix PREFIX log dir prefix below logs/, default rlgym_go1_deploy
|
||||
--cal-tag TAG calibration dir tag, default gym
|
||||
--docker-image IMAGE D-Robotics CPU toolchain image
|
||||
--compare-limit N float ONNX equivalence sample count, default 64
|
||||
--quant int16|int8 int16 keeps current conservative path; int8 omits set_all_nodes_int16
|
||||
@@ -50,6 +52,7 @@ while [[ $# -gt 0 ]]; do
|
||||
--samples) SAMPLES="$2"; shift 2 ;;
|
||||
--min-samples) MIN_SAMPLES="$2"; shift 2 ;;
|
||||
--log-prefix) LOG_PREFIX="$2"; shift 2 ;;
|
||||
--cal-tag) CAL_TAG="$2"; shift 2 ;;
|
||||
--docker-image) DOCKER_IMAGE="$2"; shift 2 ;;
|
||||
--compare-limit) COMPARE_LIMIT="$2"; shift 2 ;;
|
||||
--quant) QUANT="$2"; shift 2 ;;
|
||||
@@ -88,7 +91,7 @@ if [[ -z "${NAME}" ]]; then
|
||||
NAME="$(basename "${POLICY_ABS}" .onnx)"
|
||||
fi
|
||||
|
||||
CAL_DIR="calibration_data_${ROUND}_gym_fast${SAMPLES}"
|
||||
CAL_DIR="calibration_data_${ROUND}_${CAL_TAG}_fast${SAMPLES}"
|
||||
if [[ "${QUANT}" = "int16" ]]; then
|
||||
OUTPUT_DIR="mapper_output_${ROUND}_gemm"
|
||||
OUTPUT_PREFIX="${NAME}_int16_gemm"
|
||||
|
||||
Reference in New Issue
Block a user