Skip to content

Latest commit

 

History

History
89 lines (67 loc) · 3.13 KB

dev_environment.md

File metadata and controls

89 lines (67 loc) · 3.13 KB

开发环境搭建

前置条件

  • Python 3.10 / 3.11 / 3.12
  • 当前 Python 的开发头文件,以及 setuptools、wheel、pybind11
  • Git
  • GCC/G++(支持 C++17)、GNU Make、binutils、coreutils、tar、sed、awk
  • CANN >= 9.1.0 的完整 toolkit/ops 开发环境(Ascend NPU 开发需要)
  • CMake ≥ 3.18
  • Ninja(native target 需要)

克隆仓库

git clone https://gitcode.com/mindspore/hyper-parallel.git
cd hyper-parallel

Fork 工作流

采用 origin(fork)+ upstream(主仓库)模式:

# 在 GitCode 上 fork 仓库后
git remote add origin https://gitcode.com/<your-username>/hyper-parallel.git
git remote add upstream https://gitcode.com/mindspore/hyper-parallel.git

构建开发版本

# 仅 Python 源码开发(不编译 optional native 组件)
pip install -e .

# native 本地开发;先 source 用户选择的 CANN 官方环境
source /usr/local/Ascend/cann/set_env.sh
./build.sh --multicore on --soc-list ascend910b,ascend910_93
export PYTHONPATH="$PWD:${PYTHONPATH:-}"
source build/native/payload/hyper_parallel/core/multicore/lib/set_env.bash
python your_program.py

# 该命令同时生成 wheel;安装 build.sh 最后打印的精确路径
wheel_path=/absolute/path/printed/by/build.sh
pip install "${wheel_path}"
source "$(command -v hyper_parallel_multicore_set_env.bash)"

直接执行 python setup.py bdist_wheel 只生成 core-only wheel,不在 setup/pip 阶段下载或编译 native 依赖。 其他公共构建选项见安装指南。Multicore 的依赖和 CANN custom OPP 激活方式见 Multicore 构建与使用。

安装开发依赖

pip install pytest pylint markdownlint

代码规范

项目遵循以下代码规范(详见 .agent/rules/code-style.md):

  • License:所有 .py 文件需包含 Apache 2.0 header(前 16 行)
  • Style:PEP 8,~120 字符行宽
  • Naming:类 PascalCase,函数/变量 snake_case,私有 _leading_underscore
  • Docstrings:Google 风格(Args:、Returns:、Raises:、Example:)
  • Type hints:公共函数签名必须包含类型提示
  • Errors:使用 ValueError 配合描述性消息,仅在边界处验证
  • Imports:
    • core/、collectives/、tests/ 等:模块顶部 import
    • core/**:模块顶部直接 import Torch,不做后端分发
    • core/multicore/**:可选依赖(如 torch_npu、共享内存库)放在方法内 lazy import

Git 工作流

  • Commits:Conventional Commits 格式(feat:、fix:、docs:),~80 字符标题,祈使语气
  • Branch:功能分支命名 feat/xxx 或 fix/xxx 或 docs/xxx
  • Squash:打开 PR 前压缩 WIP commits

AI Agent 工具

项目配置了 AI Agent skills(.agent/skills/),支持:

Skill 用途
autogit GitCode fork 工作流自动化(commit、PR、status、squash)
code-review 分布式正确性、stream sync、内存安全审查
dist-op-dev 分布式算子开发流程
platform-dev 平台抽象层开发