pytorch测试集缺少monkeytype
近日为 pytorch riscv 进行测试,过程中有缺少 python 包 monkeytype 的报错,但是 requirements.txt 中没有相关包。 找到 import monkeytype 的源码。 monkeytype 可以通过在运行时监控实际运行的类型信息,自动为现有的 python 代码库生成静态类型注解。 看起来影响不大,先不管。
近日为 pytorch riscv 进行测试,过程中有缺少 python 包 monkeytype 的报错,但是 requirements.txt 中没有相关包。 找到 import monkeytype 的源码。 monkeytype 可以通过在运行时监控实际运行的类型信息,自动为现有的 python 代码库生成静态类型注解。 看起来影响不大,先不管。
cross MLIR 试了一下直接用系统的clang,有 /usr/bin/ld: unrecognised emulation mode: elf64lriscv,看来还真得源码构建一遍llvm。 Build Local LLVM/MLIR 缺 pybind11 nanobind python-numpy Build Local buddy-mlir 缺 python-distlib pkg-config texinfo 震惊了,在缺依赖的构建中发现竟然构建了一整个 riscv-gnu-toolchain ,我麻了,跟各种构建系统和依赖斗智斗勇,头好晕,要长脑子了。
vim 移动到行首 shift+6。 RISC-V 机器 pacman 里面没有 nanobind ,在 prepare 阶段从源码构建一个。 prepare() { cd "$srcdir/$pkgname" # vendor nanobind git submodule add https://github.com/wjakob/nanobind.git third_party/nanobind || true git submodule update --init --recursive } build 阶段指定 nanobind 的路径 -DCMAKE_PREFIX_PATH="$srcdir/$pkgname/third_party/nanobind" CMake Warning: Manually-specified variables were not used by the project: NANOBIND_BUILD_TESTS 太好玩了,buddy-mlir 依赖 nanobind,但是 ArchLinux RISCV-V 没有这个包,虽然我可以手动打出来但是 status page 显示缺少依赖 python-tensorflow。咨询了肥猫大佬,是在 checkpkg 阶段跑测试依赖的。 虽然我现在打出来的 nanobind 应该也没啥问题,但是需要在 buddy-mlir 的 PKGBUILD 里面重新 build 一遍才能成功打出来。可能还是直接 cross build 比较好。
没想到 build 个 2.8 比 mainline 还困难, 看起来 python 3.14 有很多兼容性问题需要修,还是算了。 /build/python-pytorch/src/pytorch/torch/csrc/dynamo/cpython_defs.c:228:20: error: invalid use of incomplete typedef ‘_PyInterpreterFrame’ {aka ‘struct _PyInterpreterFrame’} 228 | Py_DECREF(frame->f_funcobj);
近日我非常想回家过年不想干活,但是回家过年的时候心里又非常不安年后的组会。于是我一边回家过年一边不安。 Command: g++ /tmp/tmpbsdfhbwi/header.hpp -D TORCH_INDUCTOR_CPP_WRAPPER -D STANDALONE_TORCH_HEADER -D C10_USING _CUSTOM_GENERATED_MACROS -O3 -DNDEBUG -fno-trapping-math -funsafe-math-optimizations -ffinite-math-on ly -fno-signed-zeros -fno-math-errno -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contra ct=off -fexcess-precision=fast -fno-tree-loop-vectorize -march=rv64gc -fPIC -Wall -std=c++17 -Wno-unu sed-variable -Wno-unknown-pragmas -pedantic -fopenmp -I/usr/include/python3.11 -I/home/chenyixuan/pyt orch/torch/include -I/home/chenyixuan/pytorch/torch/include/torch/csrc/api/include -E -P -o /tmp/tmpbsdfhbwi/header.i Output: In file included from /home/chenyixuan/pytorch/torch/include/torch/csrc/inductor/cpp_wrapper/cpu.h:3, from /tmp/tmpbsdfhbwi/header.hpp:1: /home/chenyixuan/pytorch/torch/include/torch/csrc/inductor/cpp_wrapper/common.h:9:10: fatal error: pybind11/gil_simple.h: No such file or directory 9 | #include <pybind11/gil_simple.h> | ^~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. 经过漫长的等待终于发现了这个常见错误,然而无论安装使用系统的 pybind11 还是在 python 虚拟环境里也装一个,或者是学习 ArchLinux 的 PKGBUILD中 使用环境变量 export use_system_pybind11 = on 都无法解决。当然,使用 export use_system_pybind11 = off 也无法解决。 ...
近日我测试 pytorch 在 RISC-V 上有什么可以修的简单项。发现即便是在虚拟环境中 test/run_test.py 也会先找系统中的 pytorch。 所以我对着旧版本 pytorch 的 fail 项修了半天不生效。 虽然之前明明没有 LAPACK, sycl 但却进行测试,还有旧的函数调用等种种迹象都暗含可能测错,但我竟没有引起警惕。 export PYTHONPATH=$PWD 之后终于正确了,之前 fail 的 test cpp extension 等模块竟然会在测试过程中没有的话就自动编译安装,于是 花费的时间大幅上升,export MAX_JOBS=32 竟然把机器给跑挂了,现在改成16继续测。 与此同时我接到了 MLIR 相关通知,于是又开始在archlinux上打包 pytorch 2.8以免把虚拟环境中的2.11创烂。 虽然可能有同时存在 2.8 和 2.11 随便我用的方法,但机器性能估计不足以维系,先使用 cross build。
虽然还难以下手支持 RVV,但想到也许我该先测一个 Baseline 来见证 RVV 的负优化。 正常使用在 PyTorch 文件夹路径下使用 python test/run_test.py --keep-going即可。 虽然官方会在缺依赖的时候提醒你使用 .ci 路径下的 requirement.txt 安装依赖,但是某些包(比如 numpy)和本人使用的 openEuler python 3.12 有在 fortran 相关依赖上的冲突。于是选择缺什么安什么。 大致安装了如下依赖,如果有漏的,也可以顺着网线来找我。 使用系统包管理器安装 sudo dnf install python3-scipy 使用 pip 在 python 虚拟环境中安装 pip install expecttest boto3 pytest-rerunfailures pytest-flakefinder
Device-agnostic Eager-Mode Custom Modules Optimizers Quantization Graph-Mode Custom Fusion Passes oneDNN Fusion Passes ATen Ops Custom Ops Graph Ops Custom Fuses Ops oneDNN Fused Ops Kernels GPU related GPU Custom & ATen Kernels oneDNN GPU Kernels oneMKL GPU Kernels CPU related CPU Custom & ATen Kernels oneDNN CPU Kernels oneMKL CPU Kernels
训练和推理后端 torch.compile(m, backend="inductor") torch.compile(m, backend="cudagraphs") torch.compile(m, backend="ipex") 仅推理后端 torch.compile(m, backend="tensorrt") torch.compile(m, backend="ipex") torch.compile(m, backend="tvm") torch.compile(m, backend="openvino")
上一次组会leader说让我弄清楚 torch.compile 的过程,这一次内容就是 Aten 的开源贡献了, 我填入会议 agenda 的时候大受震撼。但是不影响 ATen 本来就在 RISC-V 上面可以编译运行。 这次组会有人也和我的想法差不多,让 RISC-V 成为 torch.compile 可以调用的某个后端,或者更下一层 Triton 的 后端。但貌似他们想造个别的什么轮子。