Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .github/workflows/npu-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
amd_sdk_run_id:
description: Optional run containing amdnpu-candidate-sdk imported from Ryzen AI 1.8
description: Optional run containing an amdnpu-candidate-sdk; otherwise build lightweight IREE support
required: false
default: ""
type: string
Expand All @@ -20,19 +20,25 @@ permissions:

jobs:
build:
# Draft release assets are visible only to tokens with push access.
permissions:
contents: write
actions: read
runs-on: ubuntu-24.04
timeout-minutes: 180
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: "22"
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.11"
python-version: "3.12"
- name: Install AMD build dependencies
if: inputs.amd_sdk_run_id == ''
run: sudo apt-get update && sudo apt-get install -y clang lld ninja-build uuid-dev
- name: Cache pinned AMD build tools and model artifacts
if: inputs.amd_sdk_run_id == ''
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: .cache/amd-aie
key: amd-aie-${{ runner.os }}-${{ hashFiles('tools/npu/iree-source.lock.json', 'tools/npu/iree-frontend.requirements.txt', 'tools/npu/*iree*.py', 'tools/npu/*amdaie*.py', 'tools/npu/runtime/*', 'src/inference/amdnpu/runtime_api.h') }}
- name: Assemble pinned Intel native SDK
run: python tools/npu/build_openvino.py --package-cache .cache/npu --output-dir dist/npu-sdk/openvino
- name: Import acquired AMD candidate
Expand All @@ -43,11 +49,9 @@ jobs:
path: dist/npu-sdk/amdnpu
run-id: ${{ inputs.amd_sdk_run_id }}
github-token: ${{ github.token }}
- name: Fetch locked AMD deployment runtime and compiled recognition models
- name: Build lightweight AMD runtime and all recognition buckets
if: inputs.amd_sdk_run_id == ''
env:
GH_TOKEN: ${{ github.token }}
run: python tools/npu/fetch_amdnpu.py --package-cache .cache/npu --output-dir dist/npu-sdk/amdnpu
run: python tools/npu/build_amdaie.py --work-dir .cache/amd-aie --output-dir dist/npu-sdk/amdnpu --jobs 2
- name: Build the native addon with packaged NPU SDKs
shell: bash
run: |
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/npu-support-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ permissions:

jobs:
build:
# The AMD deployment archive remains a draft asset until v0.5.9 ships.
permissions:
contents: write
runs-on: ubuntu-24.04
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
Expand All @@ -34,10 +32,18 @@ jobs:
node-version: '22'
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.11'
python-version: '3.12'
- name: Install AMD build dependencies
if: matrix.provider == 'amdnpu'
run: sudo apt-get update && sudo apt-get install -y clang lld ninja-build uuid-dev
- name: Cache pinned AMD build tools and model artifacts
if: matrix.provider == 'amdnpu'
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: .cache/amd-aie
key: amd-aie-${{ runner.os }}-${{ hashFiles('tools/npu/iree-source.lock.json', 'tools/npu/iree-frontend.requirements.txt', 'tools/npu/*iree*.py', 'tools/npu/*amdaie*.py', 'tools/npu/runtime/*', 'src/inference/amdnpu/runtime_api.h') }}
- name: Prepare the selected provider only
env:
GH_TOKEN: ${{ github.token }}
PROVIDER: ${{ matrix.provider }}
RELEASE_VERSION: ${{ inputs.version }}
run: |
Expand All @@ -46,7 +52,7 @@ jobs:
if [[ "$PROVIDER" == openvino ]]; then
python tools/npu/build_openvino.py --package-cache .cache/npu --output-dir dist/sdk
else
python tools/npu/fetch_amdnpu.py --package-cache .cache/npu --output-dir dist/sdk
python tools/npu/build_amdaie.py --work-dir .cache/amd-aie --output-dir dist/sdk --jobs 2
fi
- name: Build a separate CPU and NPU addon
env:
Expand All @@ -73,6 +79,17 @@ jobs:
--sdk-dir dist/sdk --output-dir dist/package
mkdir -p dist/tarballs
npm pack ./dist/package --ignore-scripts --json --pack-destination dist/tarballs > dist/tarballs/pack-manifest.json
python tools/npu/record_support_pack.py --package-dir dist/package \
--pack-manifest dist/tarballs/pack-manifest.json --output-file dist/tarballs/support-size-report.json
- name: Test AMD package without NPU hardware
if: matrix.provider == 'amdnpu'
env:
LIGHT_OCR_AMD_TEST_PACKAGE: ${{ github.workspace }}/dist/package
LIGHT_OCR_AMD_TEST_BUNDLE: ${{ github.workspace }}/models/generated/ppocrv6-small-onnx-20260714.2
LIGHT_OCR_AMD_TEST_ARCHIVE: ${{ github.workspace }}/dist/tarballs/arcships-light-ocr-amdnpu-linux-x64-gnu-${{ inputs.version }}.tgz
run: |
node --test packages/runtime/test/*.test.cjs
python -m unittest tests.python.test_amdaie_runtime
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: npu-support-${{ matrix.provider }}-${{ inputs.version }}
Expand Down
15 changes: 11 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ Release preparation; npm publication and GitHub Release are pending.
pinned OpenVINO 2026.4.0 libraries; default platform packages do not. See
[Intel NPU 加速技术方案](docs/intel-npu-acceleration.md).
- Added a separately installed AMD NPU backend (`provider: "amdnpu"`) for Linux x64
glibc and Ryzen AI STX/KRK devices. It isolates the vendor ORT runtime,
loads 20 immutable BF16 recognition contexts, and runs detection on CPU.
glibc and Ryzen AI STX/KRK devices. The default deployment now uses a small
IREE C ABI runtime, 20 CPU/NPU recognition modules and one shared weight archive.
It offloads 19 dense pointwise convolutions, splits wide matrices to fit DMA
limits, keeps other recognition operators on IREE CPU, and runs detection on ORT CPU.
Added model compilation and SDK import tools, descriptor validation,
license/SBOM staging, and candidate/release workflows. AMD is excluded
from Auto and enabled only through `execution.provider: "amdnpu"` (or
`--provider amdnpu`). NPU device reports are optional for release;
`deviceValidated` remains false. The optional AMD support package includes Ryzen AI 1.8
deployment libraries and real compiled contexts bound to Small 0.3.4.
`deviceValidated` remains false. BF16 operands use BFP16ebs8 microkernels;
numerical parity and hardware execution remain unverified. Deployment artifacts
are bound to Small 0.3.4, with no vendor SDK, compiler, Python or XRT in the AMD payload.
Legacy vendor deployments retain their separate ORT API/namespace path.
Added hardware-free package/C ABI regression checks and sampled CPU transform
comparisons; fixed null deployment JSON leaking an unclassified TypeError.
These checks do not qualify the AMD BFP16ebs8 kernel or device execution.
Neither support package is automatically installed or selected by Auto.
The existing Small model bundle remains unchanged. See [AMD NPU 加速技术方案](docs/amd-npu-acceleration.md)
and [NPU SDK 构建与发布](docs/npu-runtime-release.md).
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(LIGHT_OCR_OPENVINO_SDK_DIR "" CACHE PATH
set(LIGHT_OCR_OPENVINO_C_LIBRARY "" CACHE FILEPATH
"OpenVINO C runtime loaded by direct C++ callers; defaults to <SDK>/lib/libopenvino_c.so")
set(LIGHT_OCR_AMDNPU_SDK_DIR "" CACHE PATH
"Verified Ryzen AI runtime SDK with precompiled BF16 recognition buckets (Linux x64 glibc)")
"Verified AMD runtime deployment with precompiled recognition buckets (Linux x64 glibc)")

if(LIGHT_OCR_ENABLE_SANITIZERS AND LIGHT_OCR_ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "Address/Undefined sanitizers and ThreadSanitizer require separate builds")
Expand Down
197 changes: 197 additions & 0 deletions docs/amd-aie-compilation-results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"schemaVersion": "1.0",
"stage": "development",
"date": "2026-10-07",
"sourceModelSha256": "5435fd747c9e0efe15a96d0b378d5bd157e9492ed8fd80edf08f30d02fa24634",
"sourceLockSha256": "a58136fc60e8eb5023798c3e8d3a7014abbeb2f3107f6a727c5b8f1f0cd0bf4a",
"compiler": {
"sourceCommits": {
"amdAie": "fddfec1be6ceefbdb890079d957947dfa1fe0848",
"third_party/aie-rt": "a6196ebd905ceaf92cabc2e594017fa11b9e4323",
"third_party/bootgen": "92e09bf37ea17d7b1f0e102a2548f27fb768651c",
"third_party/iree": "26083307b8753a11870b8caf590afea15c9429fa",
"third_party/mlir-air": "ca2448548d66d7e8e05bacb9e81e7df48a9ef729",
"third_party/openssl": "0e04e101507df752500093ff4b04cce5a898abaa",
"iree/third_party/benchmark": "192ef10025eb2c4cdd392bc502f0c852196baa48",
"iree/third_party/llvm-project": "8be29edc20dfb19245ab8cf49669c80125ece4f5",
"iree/third_party/flatcc": "9362cd00f0007d8cbee7bff86e90fb4b6b227ff3",
"iree/third_party/musl": "3f701faace7addc75d16dea8a6cd769fa5b3f260"
},
"localPatches": [
{
"path": "patches/check-matmul-map-ranks.patch",
"sha256": "5a0a9b3efe57cc4d257b8fd9d08f59a4c158a07c71a7242d21b812314ee9fb05",
"reason": "Reject scalar/rank-one generic maps before matmul dimension access"
}
],
"localSourceDiffSha256": "b62c2c5415db8739e8799ca8f1f28658c1e27229ad0897fafce505150d6cb6f9",
"binaries": [
{
"path": "tools/iree-compile",
"bytes": 6256,
"sha256": "a751017528d0e96e3331e119cfa87c9705e802a3fcc27c68b4a74f8afbe7e3f3"
},
{
"path": "tools/iree-opt",
"bytes": 6248,
"sha256": "5b7123611e66efbbc527c0dfb0ac225a1597193cf4bbdb69022fdc4c169366b4"
},
{
"path": "lib/libIREECompiler.so",
"bytes": 271528912,
"sha256": "352f1d6e4c7f3945f7fbbdf09255598cad153ec3afbac52f353241559cbc4408"
}
]
},
"runtimeBinaries": [
{
"path": "tools/iree-run-module",
"bytes": 1843488,
"sha256": "b269f29d707f00a426f09a2fb962806b61e7c3a4edabe7da4b13d9057f8ee3f5"
},
{
"path": "tools/iree-dump-module",
"bytes": 462336,
"sha256": "83eb65201baa9071dd14af67e265b70b0b3239b76bcf6bb7835dd5ddb4e8d34b"
}
],
"target": "npu4",
"deviceHAL": "amdxdna",
"coreRows": 2,
"coreCols": 2,
"deviceValidated": false,
"numericsValidated": false,
"fullRecognitionSupported": false,
"reports": {
"matrixTargets": {
"compileStage": "targets",
"status": "failed",
"kernelMode": "peano-bf16",
"kernelPrecision": "bf16 converted to bfp16ebs8 inside Peano matmul microkernel",
"results": [
{
"variant": "projection-matmul",
"status": "compiled",
"returnCode": 0,
"artifact": {
"path": "projection-matmul.mlir",
"bytes": 1248515,
"sha256": "e25ab9d86cb7e14fcf56e09f8a27bf915fe31e074526a2825650c18419c15a4d"
},
"log": {
"path": "projection-matmul.log",
"bytes": 0,
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
},
{
"variant": "projection-matmul-padded",
"status": "compiled",
"returnCode": 0,
"artifact": {
"path": "projection-matmul-padded.mlir",
"bytes": 1248480,
"sha256": "be7d04f2b328b244ac74aa475abbb5b59e0e8059395fcd99714b8ead5a62a256"
},
"log": {
"path": "projection-matmul-padded.log",
"bytes": 0,
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
},
{
"variant": "projection",
"status": "failed",
"returnCode": 1,
"log": {
"path": "projection.log",
"bytes": 5614,
"sha256": "96adc90f3fe65b0a682cfdb697640621073dced26f9b590f4d88289ddc6ff593"
}
},
{
"variant": "mlp-residual",
"status": "failed",
"returnCode": 1,
"log": {
"path": "mlp-residual.log",
"bytes": 8236,
"sha256": "00db9558a947f4b6c22fbc4b5e28e1998ac0b7bfd93f4365b336c09cbb11f4f2"
}
}
]
},
"matrixBinary": {
"compileStage": "binary",
"status": "compiled",
"kernelMode": "peano-bf16",
"kernelPrecision": "bf16 converted to bfp16ebs8 inside Peano matmul microkernel",
"results": [
{
"variant": "projection-matmul-padded",
"status": "compiled",
"returnCode": 0,
"artifact": {
"path": "projection-matmul-padded.vmfb",
"bytes": 612008,
"sha256": "c1d76da61b859a4aade426fa562eb997f32c73b40242cc359a07cf7d1f3613de"
},
"log": {
"path": "projection-matmul-padded.log",
"bytes": 0,
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
}
]
},
"graphSources": {
"compileStage": "sources",
"status": "compiled",
"kernelMode": "vector",
"kernelPrecision": "source IR types",
"results": [
{
"variant": "recognition",
"status": "compiled",
"returnCode": 0,
"artifact": {
"path": "recognition.mlir",
"bytes": 42484239,
"sha256": "2bb0403b4a48ad345e4837e37515b633a9b38d044d8aaa19f75d2d58c008b5dc"
},
"log": {
"path": "recognition.log",
"bytes": 0,
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
}
]
},
"graphTargets": {
"compileStage": "targets",
"status": "failed",
"kernelMode": "vector",
"kernelPrecision": "source IR types",
"results": [
{
"variant": "recognition",
"status": "crashed",
"returnCode": -11,
"log": {
"path": "recognition.log",
"bytes": 97,
"sha256": "beeae0292954fe1578e7f14762b2437daa2c88904dfa257b5362f332a124faf2"
},
"signal": 11
}
]
}
},
"remainingWork": [
"layout and precision conversion dispatch lowering or coarse CPU/NPU partition",
"reduce full graph PackOp/packTranspose crash",
"evaluate BFP16 precision changes",
"share weights across widths",
"native backend and optional package integration"
]
}
Loading
Loading