搭建开发环境
conda create -y -n temp python=3.12
conda activate temp
# A100: torch==2.10 否则会报驱动错误
pip install torch==2.10 pre-commit
pip uninstall -y triton
RES="--index-url=https://resource.flagos.net/repository/flagos-pypi-hosted/simple \
--trusted-host=https://resource.flagos.net"
# flagtree 需要时安装最新版本
# https://github.com/flagos-ai/FlagTree/tags
python3 -m pip install flagtree==0.5.0+3.1 $RES
conda install -y numpy sqlalchemy
# FlagGems
git clone git@github.com:siliconflow/FlagGems.git
cd FlagGems
pip install -U scikit-build-core>=0.11 pybind11 ninja cmake
pip install --no-build-isolation -e .
pre-commit install
# set env
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
# exec unit test
pytest tests/test_special_ops.py -m reflection_pad2d
代码目录
- LLM 的算子一般在 src/flag_gems/fused
- 单元测试用例在 tests 目录,例如 tests/test_conv3d.py
- 性能测用例在 benchmark 目录
Git upstream
git clone git@github.com:siliconflow/FlagGems.git
cd FlagGems
git remote add upstream git@github.com:flagos-ai/FlagGems.git
git fetch upstream master
# git remote -v 显示
# origin https://github.com/siliconflow/FlagGems.git
# upstream https://github.com/flagos-ai/FlagGems.git
Git 开发流程
- 在本仓库提交 feature 分支
pre-commit run --all-files
pre-commit run isort --files file1 file2
- git push origin my-feature
- 创建 Pull Request
- 标题如 [SiliconFlow] Op: Reflection pad2d
- 参考 addcmul, acos
- 检查 Pull Request 页面各种检查是否有不通过的情况
- Pull Request 合并后,将 upstream/master 更新到 origin/master
Pull Request 配置
base repository: flagos-ai/FlagGems
base branch: master
head repository: siliconflow/FlagGems
compare: my-feature
更新 upstream
git checkout master
git pull upstream master
git push origin master
搭建开发环境
代码目录
Git upstream
Git 开发流程
pre-commit run --all-filespre-commit run isort --files file1 file2Pull Request 配置
更新 upstream