Skip to content

Commit afe7e27

Browse files
Merge pull request #5 from lemonade-sdk/4-support-ryzen-ai-sw-17
Upgrade to Ryzen AI SW 1.7
2 parents e523cae + 59f35bc commit afe7e27

File tree

9 files changed

+172
-147
lines changed

9 files changed

+172
-147
lines changed

.github/workflows/build_and_release.yml

Lines changed: 68 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ permissions:
1313
contents: write
1414

1515
jobs:
16-
build-ryzenai-server:
17-
name: Build RyzenAI Server
18-
runs-on: [rai-160-sdk, Windows]
16+
build-and-test:
17+
name: Build and Test RyzenAI Server
18+
runs-on: [rai-170-sdk, Windows]
1919
steps:
2020
- uses: actions/checkout@v4
2121
with:
@@ -75,7 +75,7 @@ jobs:
7575
mkdir build
7676
cd build
7777
78-
# Configure - Ryzen AI should be at C:\Program Files\RyzenAI\1.6.0
78+
# Configure - Ryzen AI should be at C:\Program Files\RyzenAI\1.7.0
7979
cmake .. -G "Visual Studio 17 2022" -A x64
8080
if ($LASTEXITCODE -ne 0) {
8181
Write-Host "ERROR: CMake configuration failed!" -ForegroundColor Red
@@ -119,37 +119,6 @@ jobs:
119119
120120
$fileCount = (Get-ChildItem $releaseDir -File | Measure-Object).Count
121121
Write-Host "`nFound $fileCount files in release directory" -ForegroundColor Green
122-
Write-Host "Contents will be uploaded as artifact (GitHub will zip automatically)" -ForegroundColor Gray
123-
124-
- name: Upload RyzenAI Server Package
125-
uses: actions/upload-artifact@v4
126-
with:
127-
name: ryzenai-server
128-
path: |
129-
build/bin/Release/*.exe
130-
build/bin/Release/*.dll
131-
build/bin/Release/*.pdb
132-
build/bin/Release/AMD_LICENSE
133-
retention-days: 7
134-
135-
test-ryzenai-server:
136-
name: Test RyzenAI Server
137-
needs: build-ryzenai-server
138-
runs-on: [rai300_400, Windows]
139-
strategy:
140-
fail-fast: false
141-
matrix:
142-
mode: [cpu, npu, hybrid]
143-
steps:
144-
- uses: actions/checkout@v4
145-
with:
146-
clean: true
147-
148-
- name: Download RyzenAI Server artifact
149-
uses: actions/download-artifact@v4
150-
with:
151-
name: ryzenai-server
152-
path: build/bin/Release
153122
154123
- name: Set up Python
155124
uses: actions/setup-python@v5
@@ -164,92 +133,106 @@ jobs:
164133
python -m pip install -r test/requirements.txt
165134
Write-Host "Test dependencies installed!" -ForegroundColor Green
166135
167-
- name: Download model checkpoint
136+
- name: Test all modes
168137
shell: PowerShell
169138
run: |
170139
$ErrorActionPreference = "Stop"
171140
172141
# Set HF_HOME to local directory
173142
$env:HF_HOME = "${{ github.workspace }}/hf_home"
174-
Write-Host "HF_HOME set to: $env:HF_HOME" -ForegroundColor Cyan
175143
176-
# Create directory if it doesn't exist
177144
if (-not (Test-Path $env:HF_HOME)) {
178145
New-Item -ItemType Directory -Path $env:HF_HOME -Force | Out-Null
179146
}
180147
181148
# Model mapping based on mode
182149
$modelMap = @{
183-
"npu" = "amd/Qwen2.5-3B-Instruct-onnx-ryzenai-npu"
184-
"hybrid" = "amd/Qwen2.5-3B-Instruct-onnx-ryzenai-hybrid"
150+
"npu" = "amd/Llama-3.2-1B-Instruct-onnx-ryzenai-npu"
151+
"hybrid" = "amd/Qwen2.5-0.5B-Instruct-onnx-ryzenai-1.7-hybrid"
185152
"cpu" = "amd/Qwen2.5-0.5B-Instruct-quantized_int4-float16-cpu-onnx"
186153
}
187154
188-
$mode = "${{ matrix.mode }}"
189-
$modelName = $modelMap[$mode]
190-
191-
Write-Host "Downloading model for $mode mode: $modelName" -ForegroundColor Cyan
155+
$modes = @("cpu", "npu", "hybrid")
156+
$failed = @()
192157
193-
# Download the model using huggingface_hub
194-
python -c @"
158+
foreach ($mode in $modes) {
159+
$modelName = $modelMap[$mode]
160+
$logDir = "${{ github.workspace }}/test_logs"
161+
162+
Write-Host "`n============================================================" -ForegroundColor Cyan
163+
Write-Host " Testing mode: $mode ($modelName)" -ForegroundColor Cyan
164+
Write-Host "============================================================`n" -ForegroundColor Cyan
165+
166+
# Download the model
167+
Write-Host "Downloading model..." -ForegroundColor Cyan
168+
python -c @"
195169
import os
196170
os.environ['HF_HOME'] = r'${{ github.workspace }}/hf_home'
197-
198171
from huggingface_hub import snapshot_download
199-
200172
model_name = '$modelName'
201173
print(f'Downloading {model_name}...')
202-
203-
local_path = snapshot_download(
204-
repo_id=model_name,
205-
local_dir=None, # Use default HF cache
206-
)
207-
174+
local_path = snapshot_download(repo_id=model_name, local_dir=None)
208175
print(f'Model downloaded to: {local_path}')
209176
"@
210-
211-
if ($LASTEXITCODE -ne 0) {
212-
Write-Host "ERROR: Failed to download model!" -ForegroundColor Red
213-
exit $LASTEXITCODE
177+
178+
if ($LASTEXITCODE -ne 0) {
179+
Write-Host "ERROR: Failed to download model for $mode!" -ForegroundColor Red
180+
$failed += $mode
181+
continue
182+
}
183+
184+
# Run tests
185+
Write-Host "Running tests for $mode..." -ForegroundColor Cyan
186+
python test/test_server.py --mode $mode --server-exe build/bin/Release/ryzenai-server.exe --log-dir $logDir
187+
188+
if ($LASTEXITCODE -ne 0) {
189+
Write-Host "ERROR: Tests failed for mode $mode!" -ForegroundColor Red
190+
$failed += $mode
191+
} else {
192+
Write-Host "All tests passed for mode: $mode" -ForegroundColor Green
193+
}
214194
}
215195
216-
Write-Host "Model download complete!" -ForegroundColor Green
217-
218-
- name: Run verification tests
219-
shell: PowerShell
220-
run: |
221-
$ErrorActionPreference = "Stop"
222-
223-
# Set HF_HOME
224-
$env:HF_HOME = "${{ github.workspace }}/hf_home"
225-
226-
$mode = "${{ matrix.mode }}"
227-
$logDir = "${{ github.workspace }}/test_logs"
228-
229-
Write-Host "Running verification tests for mode: $mode" -ForegroundColor Cyan
230-
Write-Host "Log directory: $logDir" -ForegroundColor Gray
231-
232-
# Run the test script with log directory
233-
python test/test_server.py --mode $mode --server-exe build/bin/Release/ryzenai-server.exe --log-dir $logDir
234-
235-
if ($LASTEXITCODE -ne 0) {
236-
Write-Host "ERROR: Tests failed for mode $mode!" -ForegroundColor Red
237-
exit $LASTEXITCODE
196+
# Summary
197+
Write-Host "`n============================================================" -ForegroundColor Cyan
198+
Write-Host " Test Summary" -ForegroundColor Cyan
199+
Write-Host "============================================================" -ForegroundColor Cyan
200+
foreach ($mode in $modes) {
201+
if ($failed -contains $mode) {
202+
Write-Host " $mode : FAILED" -ForegroundColor Red
203+
} else {
204+
Write-Host " $mode : PASSED" -ForegroundColor Green
205+
}
238206
}
207+
Write-Host "============================================================`n" -ForegroundColor Cyan
239208
240-
Write-Host "All tests passed for mode: $mode" -ForegroundColor Green
209+
if ($failed.Count -gt 0) {
210+
Write-Host "ERROR: $($failed.Count) mode(s) failed: $($failed -join ', ')" -ForegroundColor Red
211+
exit 1
212+
}
241213
242214
- name: Upload server logs on failure
243215
if: failure()
244216
uses: actions/upload-artifact@v4
245217
with:
246-
name: server-logs-${{ matrix.mode }}
218+
name: server-logs
247219
path: ${{ github.workspace }}/test_logs/
248220
retention-days: 7
249221

222+
- name: Upload RyzenAI Server Package
223+
uses: actions/upload-artifact@v4
224+
with:
225+
name: ryzenai-server
226+
path: |
227+
build/bin/Release/*.exe
228+
build/bin/Release/*.dll
229+
build/bin/Release/*.pdb
230+
build/bin/Release/AMD_LICENSE
231+
retention-days: 7
232+
250233
create-release:
251234
name: Create GitHub Release
252-
needs: [build-ryzenai-server, test-ryzenai-server]
235+
needs: build-and-test
253236
runs-on: ubuntu-latest
254237
if: startsWith(github.ref, 'refs/tags/v')
255238
steps:
@@ -295,12 +278,12 @@ jobs:
295278
296279
- Windows 11 (64-bit)
297280
- AMD Ryzen AI 300-series processor
298-
- Ryzen AI Software 1.6.0 with LLM patch
281+
- Ryzen AI Software 1.7.0
299282
300283
### Usage
301284
302285
```cmd
303-
ryzenai-server.exe -m C:\path\to\onnx\model --mode hybrid
286+
ryzenai-server.exe -m C:\path\to\onnx\model
304287
```
305288
306289
See the [README](https://github.com/lemonade-sdk/ryzenai-server#readme) for full documentation.

CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(ryzenai-server VERSION 1.0.2 LANGUAGES CXX)
2+
project(ryzenai-server VERSION 1.7.0 LANGUAGES CXX)
33

44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -17,10 +17,10 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
1717
find_package(Threads REQUIRED)
1818

1919
# ONNX Runtime GenAI
20-
set(OGA_ROOT "C:/Program Files/RyzenAI/1.6.0" CACHE PATH "Path to Ryzen AI installation")
20+
set(OGA_ROOT "C:/Program Files/RyzenAI/1.7.0" CACHE PATH "Path to Ryzen AI installation")
2121

2222
if(NOT EXISTS ${OGA_ROOT})
23-
message(FATAL_ERROR "Ryzen AI not found at ${OGA_ROOT}. Please install Ryzen AI 1.6.0 or set OGA_ROOT")
23+
message(FATAL_ERROR "Ryzen AI not found at ${OGA_ROOT}. Please install Ryzen AI 1.7.0 or set OGA_ROOT")
2424
endif()
2525

2626
message(STATUS "Using Ryzen AI from: ${OGA_ROOT}")
@@ -95,8 +95,11 @@ target_link_libraries(ryzenai-server PRIVATE
9595
Threads::Threads
9696
)
9797

98-
# Enable multi-threading for cpp-httplib
99-
target_compile_definitions(ryzenai-server PRIVATE CPPHTTPLIB_THREAD_POOL_COUNT=8)
98+
# Pass version info from CMake to C++ as compile definitions
99+
target_compile_definitions(ryzenai-server PRIVATE
100+
CPPHTTPLIB_THREAD_POOL_COUNT=8
101+
RYZENAI_SERVER_VERSION="${PROJECT_VERSION}"
102+
)
100103

101104
# Windows-specific settings
102105
if(WIN32)
@@ -110,13 +113,15 @@ if(WIN32)
110113
"${OGA_ROOT}/deployment/onnxruntime.dll"
111114
"${OGA_ROOT}/deployment/onnxruntime_providers_shared.dll"
112115
"${OGA_ROOT}/deployment/onnxruntime_providers_vitisai.dll"
116+
"${OGA_ROOT}/deployment/onnxruntime_providers_ryzenai.dll"
113117
"${OGA_ROOT}/deployment/onnxruntime_vitisai_ep.dll"
114118
"${OGA_ROOT}/deployment/onnxruntime_vitis_ai_custom_ops.dll"
115119
"${OGA_ROOT}/deployment/onnx_custom_ops.dll"
116-
"${OGA_ROOT}/deployment/abseil_dll.dll"
117-
"${OGA_ROOT}/deployment/libutf8_validity.dll"
118120
"${OGA_ROOT}/deployment/dyn_dispatch_core.dll"
119121
"${OGA_ROOT}/deployment/DirectML.dll"
122+
"${OGA_ROOT}/deployment/D3D12Core.dll"
123+
"${OGA_ROOT}/deployment/flexmlrt.dll"
124+
"${OGA_ROOT}/deployment/cert_dtrace.dll"
120125
"${OGA_ROOT}/deployment/zlib.dll"
121126
"${OGA_ROOT}/deployment/zstd.dll"
122127
"${OGA_ROOT}/deployment/ryzenai_onnx_utils.dll"

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ This server enables running Large Language Models on AMD Ryzen AI 300-series pro
2424
- Windows 11 (64-bit)
2525
- Visual Studio 2022
2626
- CMake 3.20 or higher
27-
- **Ryzen AI Software 1.6.0** with LLM patch
28-
- Base installation must be at `C:\Program Files\RyzenAI\1.6.0`
29-
- LLM patch must be applied on top of base installation
27+
- **Ryzen AI Software 1.7.0**
28+
- Default installation path: `C:\Program Files\RyzenAI\1.7.0`
3029
- Download from: https://ryzenai.docs.amd.com
3130

3231
**Hardware Requirements:**
@@ -67,7 +66,7 @@ All necessary Ryzen AI DLLs are automatically copied to the output directory dur
6766
If Ryzen AI is installed in a custom location:
6867

6968
```cmd
70-
cmake .. -G "Visual Studio 17 2022" -A x64 -DOGA_ROOT="C:\custom\path\to\RyzenAI\1.6.0"
69+
cmake .. -G "Visual Studio 17 2022" -A x64 -DOGA_ROOT="C:\custom\path\to\RyzenAI\1.7.0"
7170
```
7271

7372
## Code Structure
@@ -133,7 +132,7 @@ ryzenai-server/
133132

134133
**Inference Engine:** Wraps ONNX Runtime GenAI API, managing model loading, generation parameters, and streaming callbacks. Applies chat templates and handles tool call extraction.
135134

136-
**Execution Providers:** Supports three modes:
135+
**Execution Providers:** Supports three modes (auto-detected from model config):
137136
- **Hybrid**: NPU + iGPU
138137
- **NPU**: Pure NPU execution
139138
- **CPU**: CPU-only fallback
@@ -153,14 +152,11 @@ These dependencies must be manually installed by the developer:
153152
### Starting the Server
154153

155154
```cmd
156-
# Specify NPU mode
157-
ryzenai-server.exe -m C:\path\to\onnx\model --mode npu
155+
# Start the server (execution mode is auto-detected from the model)
156+
ryzenai-server.exe -m C:\path\to\onnx\model
158157
159-
# Hybrid mode with custom port
160-
ryzenai-server.exe -m C:\path\to\onnx\model --mode hybrid --port 8081
161-
162-
# CPU mode
163-
ryzenai-server.exe -m C:\path\to\onnx\model --mode cpu
158+
# Custom port
159+
ryzenai-server.exe -m C:\path\to\onnx\model --port 8081
164160
165161
# Verbose logging
166162
ryzenai-server.exe -m C:\path\to\onnx\model --verbose
@@ -171,12 +167,13 @@ ryzenai-server.exe -m C:\path\to\onnx\model --verbose
171167
- `-m, --model PATH` - Path to ONNX model directory (required)
172168
- `--host ADDRESS` - Server host address (default: 127.0.0.1)
173169
- `-p, --port PORT` - Server port (default: 8080)
174-
- `--mode MODE` - Execution mode: npu, hybrid, cpu (default: hybrid)
175170
- `-c, --ctx-size SIZE` - Context size in tokens (default: 2048)
176171
- `-t, --threads NUM` - Number of CPU threads (default: 4)
177172
- `-v, --verbose` - Enable verbose logging
178173
- `-h, --help` - Show help message
179174

175+
The execution mode (NPU, Hybrid, or CPU) is automatically detected from the model's `genai_config.json` configuration.
176+
180177
### Model Requirements
181178

182179
Models must be in ONNX format compatible with Ryzen AI. Required files:
@@ -206,7 +203,7 @@ Returns server status and Ryzen AI-specific information:
206203
"model": "phi-3-mini-4k-instruct",
207204
"execution_mode": "hybrid",
208205
"max_prompt_length": 4096,
209-
"ryzenai_version": "1.6.0"
206+
"ryzenai_version": "1.7.0"
210207
}
211208
```
212209

@@ -269,7 +266,7 @@ print(response.choices[0].message.content)
269266

270267
**Check:**
271268
1. Model path is correct and contains required ONNX files
272-
2. Ryzen AI 1.6.0 is installed at the correct path
269+
2. Ryzen AI 1.7.0 is installed at the correct path
273270
3. NPU drivers are up to date (Windows Update)
274271
4. Model is compatible with your Ryzen AI version
275272

@@ -278,7 +275,7 @@ print(response.choices[0].message.content)
278275
All required DLLs should be automatically copied during build. If you get DLL errors:
279276
1. Verify Ryzen AI is installed correctly
280277
2. Rebuild with `cmake --build . --config Release`
281-
3. Manually copy DLLs from `C:\Program Files\RyzenAI\1.6.0\deployment\` to the executable directory
278+
3. Manually copy DLLs from `C:\Program Files\RyzenAI\1.7.0\deployment\` to the executable directory
282279

283280
### Port Already in Use
284281

include/ryzenai/inference_engine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct CompletionTimingData {
2525

2626
class InferenceEngine {
2727
public:
28-
InferenceEngine(const std::string& model_path, const std::string& mode);
28+
InferenceEngine(const std::string& model_path);
2929
~InferenceEngine();
3030

3131
// Synchronous completion
@@ -57,6 +57,7 @@ class InferenceEngine {
5757
void setupExecutionProvider();
5858
void loadRaiConfig();
5959
std::string detectRyzenAIVersion();
60+
std::string detectExecutionMode();
6061
std::string resolveModelPath(const std::string& path);
6162
std::vector<int32_t> truncatePrompt(const std::vector<int32_t>& input_ids);
6263
bool validateModelDirectory(const std::string& path);

include/ryzenai/types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct CommandLineArgs {
1313
std::string model_path; // -m, --model (required)
1414
std::string host = "127.0.0.1"; // --host
1515
int port = 8080; // --port
16-
std::string mode = "hybrid"; // --mode (npu|hybrid|cpu)
1716
int ctx_size = 2048; // --ctx-size
1817
int threads = 4; // --threads
1918
bool verbose = false; // --verbose

0 commit comments

Comments
 (0)