Skip to content

名留青册,虚位以待 · Reserve the AMD NPU provider contract - #65

Merged
eric8810 merged 3 commits into
mainfrom
feat/amdnpu-provider-contract
Sep 29, 2026
Merged

eric8810 merged 3 commits into
mainfrom
feat/amdnpu-provider-contract

Conversation

@eric8810

Copy link
Copy Markdown
Contributor

Summary

  • Adds the no-hardware Phase 0 deliverable from the AMD NPU pre-study: the reserved amdnpu execution provider name across the C++ enum, the Node addon, TypeScript types, CLI flags (--provider), the document CLI, and the server EXECUTION_MODE.
  • No build ships an AMD NPU backend, so the contract fails fast and structurally: any runtime policy that lists amdnpu fails with provider_abi_mismatch (fatal in Auto as well, per D112 — a descriptor the Core cannot honor is a package error, never silently skipped), and explicit provider: "amdnpu" on current packages returns unsupported_capability.
  • The precision contract keeps only the default (automatic); the INT8/BF16 choice is pre-study open question feat: add encoded JPEG/PNG image input #2 and deliberately not encoded yet. deviceId stays rejected.
  • Includes the AMD NPU pre-study document (constraints: Ryzen AI SW is Windows-first, Vitis AI EP has no standalone C API, model compilation is Windows-only, CNN models require INT8/BF16 derived artifacts) and links it from linux-device-acceleration.md §6.
  • CHANGELOG records the reservation; cli-design.md and the package README document the value as reserved.

Verification

  • C++: fresh CMake configure + build (build/amdnpu-dev, Release), light_ocr_unit_tests 90/90 passed including 4 new amdnpu tests (precision contract, bundled-provider gate, abi mismatch, Auto fail-fast); ctest 4/4 passed (unit, integration, memory gate, tiled).
  • Node: packages/runtime 35/35 passed, packages/light-ocr-server 20/20 passed.
  • bindings/node adapter tests: 15/19 passed locally; the 3 failures require a prebuilt addon via LIGHT_OCR_NODE_BINARY and are environment preconditions, not regressions (CI builds the addon first).

Checklist

  • The change is focused; relevant tests were added or updated when behavior changed, otherwise this is N/A.
  • Documentation and CHANGELOG.md were updated for user-visible changes, otherwise this is N/A.
  • No credentials, private OCR inputs, generated build trees, or unrelated artifacts are included.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自审报告

已核实正确

  • 接入点对称完整:enum(types.hpp)→ addon parse/string → TS 类型 → CLI/帮助文本 → document CLI → server EXECUTION_MODE → benchmark → docs/CHANGELOG,无遗漏。
  • 失败链路完整且被测试锁定:known_provider 加 amdnpu 后,runtime descriptor 可合法声明它(valid_runtime_policy 通过),Core 候选处返回 provider_abi_mismatch;该原因不在 D112 skippable 列表,Auto 下同样 fatal——auto_policy_with_amdnpu_fails_fast_instead_of_silently_skipping 专门防止将来被改成静默跳过。
  • 精度契约:仅 automatic(fp16/fp32 均拒绝),与预研待决问题 #2(INT8 vs BF16)不预设的决策一致;deviceId 拒绝。
  • capability 语义:ProviderCapabilityInfo{"amdnpu", false, false, false} —— 当 policy available_providers 含 amdnpu 而 ordered_candidates 不含时创建可走 cpu 成功,此时 capability 准确反映"Core 无法兑现";ordered 含 amdnpu 时创建必败、capability 不可达。与 openvino 的 package_included=true 差异是有意的:无后端构建不应声称包内包含。
  • 测试结构与 openvino 系列完全对称(同款 test policy 形态);本地验证:unit 90/90(含 4 个新测试)、ctest 4/4、runtime 35/35、server 20/20。
  • PR 描述已按模板填写 Summary/Verification/Checklist。

小问题(非阻塞,可本 PR 修或留 follow-up)

  1. docs/amd-npu-acceleration.md §7 第 1 条:"D113 未覆盖的 新维度"——"的"与"新"之间多一个空格。
  2. amdnpu_accepts_only_automatic_precision 只覆盖 fp16;fp32 同样应拒绝,对称测试各测了一个精度,建议本测试两个都断言。
  3. tests/integration/main.cpp 的 accelerators 列表只查 webgpu/openvino:当前 builtin policy 永不含 amdnpu,正确;将来引入 LIGHT_OCR_HAS_AMDNPU 构建时需同步(预研文档 Phase B 已覆盖此边界)。
  4. engine.cpp capability push 的单行初始化格式与相邻条目的多行格式略不一致,纯风格。

@eric8810

Copy link
Copy Markdown
Contributor Author

自审报告中的问题 1(文档空格)与问题 2(fp32 断言)已在 c3b7c93 修复;补测时顺带修正了重用已 move 的 bundle 的笔误,每段断言独立构造 bundle。本地重跑 unit 90/90 通过。问题 3、4 留作记录,不需要本 PR 处理。

@eric8810
eric8810 merged commit 39979d4 into main Sep 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant