huggingface / huggingface/optimum-amd

[RyzenAI] Erroneous `vitis_ai_report.json` with RyzenSDK 1.1

Open
#118 0 comments 0 reactions 0 assignees View on GitHub
bug Ryzen AI
Dominant language
Jupyter Notebook
Stars
101
Forks
21
Avg merge
58m
Merged PRs (30d)
1

Description

Ryzen SDK: 1.1

Upon executing tests, the terminal logs exhibit the following entries:

```bash
[Vitis AI EP] No. of Operators : CPU 2 IPU 334 30.12% CPU 2 IPU 334 30.12% CPU 2 IPU 372 33.54% CPU 2 IPU 372 33.54% CPU 3 IPU 1106 99.73%
[Vitis AI EP] No. of Subgraphs : CPU 1 IPU 1 Actually running on IPU 1 CPU 1 IPU 1 Actually running on IPU 1 CPU 1 IPU 1 Actually running on IPU 1 CPU 1 IPU 1 Actually running on IPU 1 CPU 1 IPU 1 Actually running on IPU 1
```

Similarly, the generated `vitis_ai_report.json` also contains multiple entries for "All", "DPU" and "CPU" operators.

This issue arises when running multiple models in a loop, where it appears that the results of the previous model are unintentionally appended to the current results.

See: https://github.com/huggingface/optimum-amd/actions/runs/8356674296/job/22874227285#step:5:272

Steps to Reproduce:
```
* Run: $env:RUN_SLOW=1; pytest -s -m "prequantized_model_test" .\tests\ryzenai\test_modeling.py
* Review the generated prints and `vitis_ai_report.json` for each model in the `ryzen_cache` folder.Check the generated prints and `vitis_ai_report.json` for each model in `ryzen_cache` folder.
```

Minimal example to test:
```python
import os

import requests
from PIL import Image

from optimum.amd.ryzenai import RyzenAIModelForImageClassification, pipeline
from tests.ryzenai.testing_utils import DEFAULT_VAIP_CONFIG

def test_pipeline(model_id):
os.environ["XLNX_ENABLE_CACHE"] = "0"
os.environ["XLNX_USE_SHARED_CONTEXT"] = "1"

cache_dir = ".image-classification-pipeline-cache"
cache_key = model_id.replace("/", "_").lower()

provider_options = {}
provider_options["cacheDir"] = cache_dir
provider_options["cacheKey"] = cache_key

model_instance = RyzenAIModelForImageClassification.from_pretrained(
model_id, vaip_config=DEFAULT_VAIP_CONFIG, provider_options=provider_options
)

pipe = pipeline("image-classification", model=model_instance, vaip_config=DEFAULT_VAIP_CONFIG)

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
pipe(image)[0]

model_ids = ["mohitsha/timm-resnet18-onnx-quantized-ryzen", "mohitsha/transformers-resnet18-onnx-quantized-ryzen"]
for model_id in model_ids:
test_pipeline(model_id)
```

Expected behavior:
* Clean log statements with no carryover of results from previous model executions.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.