From flagos-skills
Automates FlagGems operator PR submission: code review, compliance checks, pre-commit tests, and direct PR creation with speedup data.
How this skill is triggered — by the user, by Claude, or both
Slash command
/flagos-skills:flaggems-pr-submit-flagosThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
提交流程:规范名查询 → 建分支 → 提取 worktree 代码(6文件) → 脚本验证 → pre-commit → push → 创建 PR → 回填链接。
LICENSE.txtREADME.mdreferences/common-issues.mdreferences/naming.mdreferences/pr-checklist.mdreferences/pr-template.mdreferences/workflow.mdscripts/check_operator.pyscripts/check_overload_consistency.pyscripts/extract_from_worktree.pyscripts/gen_pr_description.pyscripts/operator_registry.pyscripts/pr_gate_check.shscripts/submit_operator.py提交流程:规范名查询 → 建分支 → 提取 worktree 代码(6文件) → 脚本验证 → pre-commit → push → 创建 PR → 回填链接。
25+ 项检查已由
check_operator.py自动执行(详见下方检查表),以下仅列出模型需主动注意的规则。
check_operator.py --strict 必须 0 errorsoperator_registry.py lookup 查询operator_registry.py backfillgen_pr_description.py 输出 JSON,映射到模板(英文)_ 的算子,mark/yaml id/文件名去掉下划线,其余保留(详见 references/naming.md)utils.FLOAT_DTYPES,benchmark 用 consts.FLOAT_DTYPES;CUDA 不支持时可硬编码但必须加注释GenericBenchmark(input_fn=...);需要自定义 shape 时继承并覆盖 set_shapeseq / eq_scalar 模式flag_gems.device,不用 .is_cuda 或 device.type == "cuda"(多后端)logger.debug("GEMS <OP_NAME_UPPER>"),不用其他格式src/flag_gems/fused/,不放 src/flag_gems/ops/| 环境变量 | 必需 | 说明 | 默认值 |
|---|---|---|---|
FLAGGEMS_REPO | 是 | FlagGems 仓库本地路径 | — |
GH_TOKEN | 是 | GitHub Personal Access Token | — |
FLAGGEMS_FORK | 否 | Fork 仓库(自动从 git remote 推断) | XDYuanzhuLee/FlagGems |
FLAGGEMS_UPSTREAM | 否 | 上游仓库 | flagos-ai/FlagGems |
FLAGGEMS_NORM_XLSX | 否 | 规范名 Excel 路径 | /workspace/规范名.xlsx |
FLAGGEMS_PR_XLSX | 否 | 待提交算子 Excel 路径 | /workspace/第一批pr算子.xlsx |
FLAGGEMS_DOMESTIC_DIR | 否 | 国产 GPU 测试数据目录 | /workspace/国产GPU算子测试情况 |
每次新会话需确保 FLAGGEMS_REPO 和 GH_TOKEN 已设置(禁止硬编码)。
cd $FLAGGEMS_REPO
python <SCRIPTS_DIR>/operator_registry.py lookup <op>
cd $FLAGGEMS_REPO
git checkout -b pr/<op> upstream/master
确认算子不存在于上游。Never cherry-pick or rebase。
python <SCRIPTS_DIR>/extract_from_worktree.py <op> --repo-dir $FLAGGEMS_REPO
脚本自动从 worktree 提取 6 个文件:kernel、test、benchmark、ops/init.py、init.py、operators.yaml。 所有注册按字母序插入,所有代码从 worktree 原样提取。禁止手动编写 test/benchmark 代码。
脚本完成后检查 operators.yaml 的 description 是否需要补充(脚本可能使用默认占位描述)。
CUDA_VISIBLE_DEVICES=<N> python <SCRIPTS_DIR>/submit_operator.py <op> --repo-dir $FLAGGEMS_REPO
脚本串行执行 9 步(含 1.5 多重载检查):check_operator → 多重载一致性检查 → pre-commit → 本地测试 → 本地 benchmark → PR描述生成 → commit → push → 创建 PR → 回填链接。 任何一步失败立即中断退出。不允许手动执行单独步骤来绕过。
可选参数:
--dry-run — 只验证不提交(调试用)--skip-test — 跳过本地测试(仅当环境不支持时)--skip-benchmark — 跳过 benchmark,仅查国产卡数据references/workflow.md — Phase 2 六文件详细模板、代码 review 要点references/pr-template.md — PR 描述模板、JSON 字段映射references/naming.md — 下划线算子命名规则对照表references/pr-checklist.md — 提交前逐项检查清单references/common-issues.md — 历史 review 问题汇总scripts/check_operator.py — 自动化验证脚本(25+ 检查项)scripts/check_overload_consistency.py — 多重载算子 yaml/mark/op_name 一致性检查scripts/extract_from_worktree.py — 从 worktree 提取 6 个 PR 文件scripts/gen_pr_description.py — PR 描述数据生成scripts/submit_operator.py — 一站式提交(9 步串行)scripts/operator_registry.py — 规范名查询 + PR 链接回填scripts/pr_gate_check.sh — git push 前门禁(PreToolUse hook)| 检查 | 级别 |
|---|---|
| Kernel 文件存在 + KernelGen 首行 | error |
| 无 print()、无重复函数 | error |
| ops/init.py 注册 + 字母序 | error |
| _FULL_CONFIG 注册(映射到 wrapper) | error |
| Fallback 递归检测(kernel 中禁止 torch.()) | error |
| operators.yaml 完整性 + 唯一性 | error |
| 测试 pytest mark + import 方式 + gems_assert | error |
| gems_assert_close 无 rtol | error |
| dtype 硬编码检查(需常量或加注释) | error |
| 私有 API torch._xxx | error |
| Benchmark pytest mark + op_name + dtype | error |
| Git commit 无 Co-Authored-By | error |
| Inplace mark 守卫 | error |
| yaml/config 一致性交叉验证 | error |
| Anti-hack Layer 1 (AST) + Layer 2 (dual execution) | error |
| 单算子 PR(git diff 验证) | error |
| @use_tl_extra 未使用桩函数 | error |
| 硬编码超参无注释 | error |
| 上游冲突检查 | error |
| 测试函数命名规范 | warning |
| logging 模块、torch import | warning |
| 代码质量(行长、EOF、行尾空白) | warning |
| 别名封装、NaN 处理、Worktree 一致性、Wrapper dtype assert | warning |
| Benchmark case 数量 | info |
.is_cuda / device.type == "cuda" 硬编码设备判断 | error |
| Autotune configs 内联硬编码(应在 config 文件) | error |
Logger 格式不符合 "GEMS <OP_NAME_UPPER>" | error |
| Benchmark torch/gems 测量范围不一致 | error |
| 测试文件或 Benchmark 文件缺失 | error |
| Fused 算子放在 ops/ 而非 fused/ 目录 | error |
| 自定义 shapes 与 core_shapes.yaml 重复 | warning |
以下规则依赖领域判断,模型每次提交前必须逐项确认:
set_shapes?.is_cuda 或 device.type == "cuda"?必须用 flag_gems.devicelogger.debug 是否使用 "GEMS <OP_NAME_UPPER>" 格式?src/flag_gems/fused/ 而非 ops/?core_shapes.yaml 已有条目重复?submit_operator.py 使用 --strict 模式,所有 warning 升级为 error。模型不得手动绕过脚本。submit_operator.py 的 fatal() 自动追加事件到 pr状态记录.md,无需手动记录。npx claudepluginhub flagos-ai/skills --plugin flagos-skillsReviews FlagGems operator PRs with domain-specific rules for structure, naming, registration, tests, and benchmarks. Fetches diffs and posts inline comments on GitHub. Supports both PR review and self-review modes.
Orchestrates end-to-end AscendC operator development: project init, design, test gen, code gen, compile, API doc, precision eval (≥30 cases), performance eval (msprof). For building new custom operators from scratch.
Orchestrates git operations with safety tiers: read-only inline, safe writes via background agent, destructive with preflight confirmation. Manage commits, PRs, branches, worktrees, releases.