Skip to content

Commit 6e3e081

Browse files
committed
Use public hybrid artifacts
1 parent b9e6223 commit 6e3e081

File tree

3 files changed

+57
-29
lines changed

3 files changed

+57
-29
lines changed

src/lemonade/tools/ort_genai/oga.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
PassthroughTokenizerResult,
3030
)
3131
from lemonade.cache import Keys
32-
from lemonade_install.install import DEFAULT_AMD_OGA_NPU_DIR, DEFAULT_AMD_OGA_HYBRID_DIR
32+
from lemonade_install.install import (
33+
DEFAULT_AMD_OGA_NPU_DIR,
34+
DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR,
35+
)
3336

3437

3538
# ONNX Runtime GenAI models will be cached in this subfolder of the lemonade cache folder
@@ -407,9 +410,9 @@ def run(
407410

408411
if device == "hybrid":
409412
# Locate the directory containing hybrid-llm-artifacts_1.3.0
410-
if os.path.exists(DEFAULT_AMD_OGA_HYBRID_DIR):
411-
hybrid_artifacts_path = os.path.join(
412-
DEFAULT_AMD_OGA_HYBRID_DIR, "hybrid-llm-artifacts_1.3.0"
413+
if os.path.exists(DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR):
414+
hybrid_artifacts_path = (
415+
DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR
413416
)
414417
else:
415418
if "AMD_OGA_HYBRID" not in os.environ:

src/lemonade_install/install.py

+49-24
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import subprocess
1111
import sys
12+
import shutil
1213
from typing import Optional
1314
import zipfile
1415
import requests
@@ -22,6 +23,10 @@
2223
DEFAULT_AMD_OGA_HYBRID_DIR = os.path.join(
2324
lemonade_install_dir, "install", "ryzen_ai", "hybrid"
2425
)
26+
DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR = os.path.join(
27+
DEFAULT_AMD_OGA_HYBRID_DIR,
28+
"hybrid-llm-artifacts_1.3.0_lounge",
29+
)
2530

2631

2732
def download_lfs_file(token, file, output_filename):
@@ -62,6 +67,13 @@ def download_lfs_file(token, file, output_filename):
6267
raise ValueError(f"Error: {output_filename} does not exist.")
6368

6469

70+
def download_file(url, output_filename):
71+
response = requests.get(url)
72+
73+
with open(output_filename, "wb") as file:
74+
file.write(response.content)
75+
76+
6577
def unzip_file(zip_path, extract_to):
6678
"""Unzips the specified zip file to the given directory."""
6779
with zipfile.ZipFile(zip_path, "r") as zip_ref:
@@ -116,25 +128,47 @@ def run(
116128
):
117129

118130
if ryzenai is not None:
131+
if ryzenai == "npu":
132+
file = "ryzen_ai_13_ga/npu-llm-artifacts_1.3.0.zip"
133+
install_dir = DEFAULT_AMD_OGA_NPU_DIR
134+
wheels_full_path = os.path.join(install_dir, "amd_oga/wheels")
135+
license = "https://account.amd.com/content/dam/account/en/licenses/download/amd-end-user-license-agreement.pdf"
136+
license_tag = "Beta "
137+
elif ryzenai == "hybrid":
138+
file = "https://www.xilinx.com/bin/public/openDownload?filename=hybrid-llm-artifacts_1.3.0_012725.zip"
139+
install_dir = DEFAULT_AMD_OGA_HYBRID_DIR
140+
wheels_full_path = os.path.join(
141+
DEFAULT_AMD_OGA_HYBRID_ARTIFACTS_PARENT_DIR,
142+
"hybrid-llm-artifacts",
143+
"onnxruntime_genai",
144+
"wheel",
145+
)
146+
license = r"https://www.xilinx.com/bin/public/openDownload?filename=AMD%20End%20User%20License%20Agreement.pdf"
147+
license_tag = ""
148+
else:
149+
raise ValueError(
150+
f"Value passed to ryzenai argument is not supported: {ryzenai}"
151+
)
152+
119153
if yes:
120154
print(
121-
"\nYou have accepted the AMD Beta Software End User License Agreement for "
155+
f"\nYou have accepted the AMD {license_tag}Software End User License Agreement for "
122156
f"Ryzen AI {ryzenai} by providing the `--yes` option. "
123157
"The license file is available for your review at "
124158
# pylint: disable=line-too-long
125-
"https://github.com/aigdat/ryzenai-sw-ea/blob/main/ryzen_ai_13_ga/llm-eula-beta-software.pdf\n"
159+
f"{license}\n"
126160
)
127161
else:
128162
print(
129-
"\nYou must accept the AMD Beta Software End User License Agreement in "
163+
f"\nYou must accept the AMD {license_tag}Software End User License Agreement in "
130164
"order to install this software. To continue, type the word yes "
131165
"to assert that you agree and are authorized to agree "
132166
"on behalf of your organization, to the terms and "
133-
"conditions, in the Beta Software End User License Agreement, "
167+
f"conditions, in the {license_tag}Software End User License Agreement, "
134168
"which terms and conditions may be reviewed, downloaded and "
135169
"printed from this link: "
136170
# pylint: disable=line-too-long
137-
"https://github.com/aigdat/ryzenai-sw-ea/blob/main/ryzen_ai_13_ga/llm-eula-beta-software.pdf\n"
171+
f"{license}\n"
138172
)
139173

140174
response = input("Would you like to accept the license (yes/No)? ")
@@ -145,22 +179,6 @@ def run(
145179
"Exiting because the license was not accepted."
146180
)
147181

148-
if ryzenai == "npu":
149-
file = "ryzen_ai_13_ga/npu-llm-artifacts_1.3.0.zip"
150-
install_dir = DEFAULT_AMD_OGA_NPU_DIR
151-
wheels_full_path = os.path.join(install_dir, "amd_oga/wheels")
152-
elif ryzenai == "hybrid":
153-
file = "ryzen_ai_13_ga/hybrid-llm-artifacts_1.3.0.zip"
154-
install_dir = DEFAULT_AMD_OGA_HYBRID_DIR
155-
wheels_full_path = os.path.join(
156-
install_dir,
157-
"hybrid-llm-artifacts_1.3.0/hybrid-llm-artifacts/onnxruntime_genai/wheel",
158-
)
159-
else:
160-
raise ValueError(
161-
f"Value passed to ryzenai argument is not supported: {ryzenai}"
162-
)
163-
164182
archive_file_name = f"oga_{ryzenai}.zip"
165183
archive_file_path = os.path.join(install_dir, archive_file_name)
166184

@@ -170,9 +188,16 @@ def run(
170188
token_to_use = os.environ.get("OGA_TOKEN")
171189

172190
# Retrieve the installation artifacts
173-
os.makedirs(install_dir, exist_ok=True)
174-
print(f"\nDownloading {file} from GitHub LFS to {install_dir}\n")
175-
download_lfs_file(token_to_use, file, archive_file_path)
191+
if os.path.exists(install_dir):
192+
# Remove any artifacts from a previous installation attempt
193+
shutil.rmtree(install_dir)
194+
os.makedirs(install_dir)
195+
if ryzenai == "npu":
196+
print(f"\nDownloading {file} from GitHub LFS to {install_dir}\n")
197+
download_lfs_file(token_to_use, file, archive_file_path)
198+
elif ryzenai == "hybrid":
199+
print(f"\nDownloading {file}\n")
200+
download_file(file, archive_file_path)
176201

177202
# Unzip the file
178203
print(f"\nUnzipping archive {archive_file_path}\n")

src/turnkeyml/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "5.0.3"
1+
__version__ = "5.0.4"

0 commit comments

Comments
 (0)