凤
weixin_44093752/GPT-Bird-Ascend-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

gmmeyer/gpt-bird Ascend NPU 适配

本仓对应阶段4模型 gmmeyer/gpt-bird。Google 搜索和官方 Hugging Face 页面于 2026-08-22 核实:官方仓库包含 nano_nopipes.pt、small_pipes.pt、model.onnx 和 config.json;本适配使用官方约 1.9M 参数的 nano checkpoint nano_nopipes.pt,不提交权重。

适配内容

  • 保留官方 GitHub gmmeyer/gptbird 的 dreaming_bird 运行时和 nano 模型结构。
  • inference.py 严格加载 checkpoint 内的 model_cfg、vocab_size 和 state_dict,支持 CPU、NPU 和自动设备选择。
  • 固定随机种子构造 64-token 合法输入,执行完整 forward,并调用官方 slot-constrained generate_state 生成 bird_y、pipe_dx、gap_y、status 四个合法字段。

真实 Ascend910 验证

官方 checkpoint 在 Ascend910 npu:0 严格加载并完成前向:

指标CPUNPU (Ascend910 npu:0)
参数量1,938,6241,938,624
输入 shape[1,64][1,64]
输出 shape[1,64,232][1,64,232]
输出 dtypefloat32float32
forward0.0104 s0.1866 s
全有限值truetrue

CPU/NPU logits 冒烟对拍 cosine 为 1.0000003576,max abs 为 0.0030924678,mean abs 为 0.0005154577;固定输入下四个生成 token 两端一致,且字段为 bird_y、pipe_dx、gap_y、status。这只证明真实 NPU 可运行,不替代完整任务精度评测。

运行

在已加载 CANN、安装 torch_npu 的 Ascend 容器内执行:

python inference.py --model-path /tmp/model-agent/gptbird78/nano_nopipes.pt --device npu

官方 Hugging Face 模型:gmmeyer/gpt-bird。官方源码:gmmeyer/gptbird,固定提交为 93461c58abb5455d2833462aac5cbdd46cb24433。

Agent workflow

NPU device call

Model result