Skip to content

[feature]支持transformers的quick start文档测试看护 - #173

Open
yzeyu71 wants to merge 5 commits into
Ascend:mainfrom
yzeyu71:transformers-quick-start-guard
Open

yzeyu71 wants to merge 5 commits into
Ascend:mainfrom
yzeyu71:transformers-quick-start-guard

Conversation

@yzeyu71

@yzeyu71 yzeyu71 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

为 transformers 快速开始文档接入 quick-start CI 看护,参照已合并的 peft 看护模式(#135 / workflows 仓已跑通的 transformers 示例):

  • 新增 sources/transformers/quick_start.md:单卡 NPU 文本生成 Pipeline 快速开始,含环境自检(python / torch_npu / npu-smi)、版本表、安装与推理步骤。示例模型为公开的 Qwen/Qwen2.5-1.5B,无需 HF token。文档正文面向用户,不含任何 CI 内部概念;#test / #test-result 标签位于围栏 info 字符串中,不参与页面渲染。
  • 新增 tests/transformers/test_quick_start_ascend.py:复用 quick-start-template 引擎,prepare_environment 包含 CANN env 注入、CUDA 排除清单(PIP/UV constraint)、镜像 torch 栈探测复用、HF 缓存状态校验与损坏清除(report_huggingface_state / purge_huggingface_corrupt)。DEFAULT_COMMAND_TIMEOUT=7200
  • 新增 .github/workflows/transformers-quick-start.yml:薄触发器,cron 40 */3 * * *(与 peft 的 30 分错峰)+ workflow_dispatch + PR path 过滤(sources/transformers/**tests/transformers/**)。upstream 监控 huggingface/transformers release,新 release 触发重测。
  • 修改 sources/transformers/index.rst:toctree 中 quick_start.rst -> quick_start(新 md 版接入看护)。旧 quick_start.rst 文件保留未删除,是否移除交由维护者决定。

Links

Test plan

  • PR 触发 transformers-quick-start guard(path 过滤命中 sources/transformers/**tests/transformers/**
  • 文档 #test 块解析正常(4 组 id:check-py / check-torch / check-npu-smi / install-transformers / transformers-pipeline 共 5 组断言)
  • gh-pages 构建通过(toctree 中 quick_start 条目解析为 quick_start.md)
  • 手动 dispatch 一次完整 NPU 验证

- 新增 sources/transformers/quick_start.md:单卡 NPU 文本生成 Pipeline 快速开始,
  含环境自检、版本表与可复制脚本,示例模型为公开的 Qwen/Qwen2.5-1.5B(无需 token)
- 新增 tests/transformers/test_quick_start_ascend.py:复用 quick-start 看护引擎,
  HF 缓存校验 + CUDA 排除清单 + torch 栈探测,命令块与已验证 workflows 版本一致
- 新增 .github/workflows/transformers-quick-start.yml:薄触发器(12h 3 点错峰 cron
  + dispatch + PR path 过滤),upstream 监控 huggingface/transformers release
- index.rst toctree:quick_start.rst -> quick_start(新 md 版接入看护,旧 rst 保留)
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

yzeyu71, thanks for your pull request. All authors of the commits have signed the CLA. 👍

- 与本仓 toctree 惯例一致(显式扩展名,如 sources/peft/index.md)
- 旧 quick_start.rst 已被看护版 quick_start.md 取代,一并移除
- 显式 snapshot_download(Qwen/Qwen2.5-1.5B),与运行步骤解耦,便于排查网络问题
- 补充国内镜像 HF_ENDPOINT 提示;环境准备一节同步指向新章节
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

yzeyu71, thanks for your pull request. All authors of the commits have signed the CLA. 👍

- 恢复官方文档三段式结构:AutoModelForCausalLM / pipeline / 全流程对话
- 设备选择沿用官方写法 "npu:0" if torch.npu.is_available() else "cpu",
  移除 accelerate 的 Accelerator().device;accelerate 保留(device_map="auto" 依赖)
- 示例模型换为公开的 Qwen/Qwen2.5-1.5B-Instruct(官方 Meta-Llama-3-8B-Instruct
  为 gated 模型,CI 无法下载),并去掉 llama3 专属的 <|eot_id|> 终止符
- 测试类 _MODEL_ID 同步更新为 Qwen2.5-1.5B-Instruct
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

yzeyu71, thanks for your pull request. All authors of the commits have signed the CLA. 👍

yzeyu71 added a commit to cosdt-ci-test/workflows that referenced this pull request Sep 11, 2026
与 Ascend/docs 仓 sources/transformers/quick_start.md(PR Ascend/docs#173)保持同构:
推理部分从单一 accelerate pipeline smoke 扩展为官方文档的三段式结构:

- 使用 AutoModelForCausalLM:官方写法加载(bfloat16 + device_map="auto"),
  断言模型落在 NPU(torch.bfloat16 / npu:0)
- 使用 pipeline:pycon 示例改为官方设备选择("npu:0" if torch.npu.is_available()),
  保留 "The secret to baking a good cake is" 断言契约(tests/test_quick_start_ascend.py
  提取首个 pycon 块执行,prompt 回显保证断言稳定)
- 全流程对话:messages + apply_chat_template + generate(do_sample/temperature/top_p
  沿用官方参数),断言 response: 前缀
- 模型切换 Qwen/Qwen2.5-1.5B -> Qwen/Qwen2.5-1.5B-Instruct(对话模板示例需要 Instruct),
  同步更新 workflow 的 ModelScope 预下载与项目 README
- 硬件一节 runner 描述 a2-2 -> a2-1,与 workflow 实际 runs-on 对齐
- 加速比说明:accelerate 仍保留(device_map="auto" 依赖)

CI 验证方式:workflow_dispatch 支持指定分支运行,
gh workflow run transformers-quick-start --ref transformers-official-flow-quickstart
(dispatch 不经过 monitor 门,测试使用分支 checkout 中的本地文档)
github-actions Bot pushed a commit that referenced this pull request Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

📖 文档预览https://ascend.github.io/docs/pr-preview/pr-173/sources/transformers/

也可打开整站首页

构建自 7766d57624052e5bba55bd9dc87df0c48cff32a5
每次推送后自动更新,PR 关闭时自动清理。

Signed-off-by: yangzeyu <yangzeyu7@huawei.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

yzeyu71, thanks for your pull request. All authors of the commits have signed the CLA. 👍

github-actions Bot pushed a commit that referenced this pull request Sep 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants