Skip to content

Commit bd3b8eb

Browse files
committed
staging
1 parent 5289f8b commit bd3b8eb

265 files changed

Lines changed: 41917 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: fce7cb1b8411bb39c82e3f640c660ea1
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

.buildinfo.bak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: c3e3db8b3779f59ff79e6e85bca34a83
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

404.html

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

_images/rai-sw.png

89.3 KB
Loading

_sources/ai_analyzer.rst

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
###########
2+
AI Analyzer
3+
###########
4+
5+
AMD AI Analyzer is a tool that supports analysis and visualization of model compilation and inference on Ryzen AI. The primary goal of the tool is to help you better understand how the models are processed by the hardware, and to identify performance bottlenecks that may be present during model inference. Using AI Analyzer, you can visualize graph and operator partitions between the NPU and CPU.
6+
7+
Installation
8+
~~~~~~~~~~~~
9+
10+
If you installed the Ryzen AI software using automatic installer, AI Analyzer is already installed in the conda environment.
11+
12+
If you manually installed the software, you need to install the AI Analyzer wheel file in your environment.
13+
14+
15+
.. code-block::
16+
17+
python -m pip install path\to\RyzenAI\installation\files\aianalyzer-<version>.whl
18+
19+
20+
Enabling Profiling and Visualization
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
23+
Profiling and Visualization can be enabled by passing additional provider options to the ONNXRuntime Inference Session. Here is an example:
24+
25+
.. code-block::
26+
27+
provider_options = [{
28+
'config_file': 'vaip_config.json',
29+
'cacheDir': str(cache_dir),
30+
'cacheKey': 'modelcachekey',
31+
'ai_analyzer_visualization': True,
32+
'ai_analyzer_profiling': True,
33+
}]
34+
session = ort.InferenceSession(model.SerializeToString(), providers=providers,
35+
provider_options=provider_options)
36+
37+
38+
The ``ai_analyzer_profiling`` flag enables generation of artifacts related to the inference profile. The ``ai_analyzer_visualization`` flag enables generation of artifacts related to graph partitions and operator fusion. These artifacts are generated as JSON files in the current run directory.
39+
40+
AI Analyzer also supports native ONNX Runtime profiling, which you can use to analyze the parts of the session that run on the CPU. You can enable ONNX Runtime profiling through session options and pass it along with the provider options, as shown here:
41+
42+
.. code-block::
43+
44+
# Configure session options for profiling
45+
sess_options = ort.SessionOptions()
46+
sess_options.enable_profiling = True
47+
48+
provider_options = [{
49+
'config_file': 'vaip_config.json',
50+
'cacheDir': str(cache_dir),
51+
'cacheKey': 'modelcachekey',
52+
'ai_analyzer_visualization': True,
53+
'ai_analyzer_profiling': True,
54+
}]
55+
56+
session = ort.InferenceSession(model.SerializeToString(), sess_options, providers=providers,
57+
provider_options=provider_options)
58+
59+
60+
Launching AI Analyzer
61+
~~~~~~~~~~~~~~~~~~~~~
62+
63+
After the artifacts are generated, `aianalyzer` can be invoked through the command line as follows:
64+
65+
66+
.. code-block::
67+
68+
aianalyzer <logdir> <additional options>
69+
70+
71+
**Positional Arguments**
72+
73+
``logdir``: Path to the folder containing generated artifacts
74+
75+
Additional Options
76+
77+
``-v``, ``--version``: Show the version info and exit.
78+
79+
``-b ADDR``, ``--bind ADDR``: Hostname or IP address on which to listen, default is 'localhost'.
80+
81+
``-p PORT``, ``--port PORT``: TCP port on which to listen, default is '8000'.
82+
83+
``-n``, ``--no-browser``: Prevents the opening of the default url in the browser.
84+
85+
``-t TOKEN``, ``--token TOKEN``: Token used for authenticating first-time connections to the server. The default is to generate a new, random token. Setting to an empty string disables authentication altogether, which is not recommended.
86+
87+
88+
Features
89+
~~~~~~~~
90+
91+
AI Analyzer provides visibility into how your AI model is compiled and executed on Ryzen AI hardware. Its two main use cases are:
92+
93+
1. Analyzing how the model was partitioned and mapped onto Ryzen AI's CPU and NPU accelerator
94+
2. Profiling model performance as it executes inferencing workloads
95+
96+
When launched, the AI Analyzer server scans the folder specified with the logdir argument and detect and load all files relevant to compilation and/or inferencing per the `ai_analyzer_visualization` and `ai_anlayzer_profiling` flags.
97+
98+
You can instruct the AI Analyzer server to either start a browser on the same host or return an URL that you can then load into a browser on any host.
99+
100+
101+
User Interface
102+
~~~~~~~~~~~~~~
103+
104+
AI Analyzer has the following three sections as seen in the left-panel navigator:
105+
106+
1. PARTITIONING - A breakdown of your model was assigned to execute inference across CPU and NPU
107+
2. NPU INSIGHTS - A detailed look at the how your model was optimized for inference execution on NPU
108+
3. PERFORMANCE - A breakdown of inference execution through the model
109+
110+
111+
These sections are described in more detail in the following sections:
112+
113+
114+
115+
PARTITIONING
116+
@@@@@@@@@@@@
117+
118+
This section is comprised of two pages: Summary and Graph
119+
120+
**Summary**
121+
122+
The Summary page gives an overview of how the models operators have been assigned to Ryzen's CPU and NPU along with charts capturing GigaOp (GOP) offloading by operator type .
123+
124+
There is also table titled "CPU Because" that shows the reasons why certain operators were not offloaded to the NPU.
125+
126+
**Graph**
127+
128+
The graph page shows an interactive diagram of the partitioned ONNX model, showing graphically how the layers are assigned to the Ryzen hardware.
129+
130+
131+
132+
Toolbar
133+
134+
- You can choose to show/hide individual NPU partitions, if any, with the **Filter by Partition** button
135+
- You can show or hide a panel that displays properties for selected objects through the **Show Properties** toggle button
136+
- You can show or hide the model table through the **Show Table** toggle button.
137+
- Settings
138+
139+
- Show Processor separates operators that run on CPU and NPU respectively
140+
- Show Partition separates operators running on the NPU by their respective NPU partition, if any
141+
- Show Instance Name displays the full hierarchical name for the operators in the ONNX model
142+
143+
All objects in the graph have properties that can be viewed to the right of the graph.
144+
145+
146+
147+
*Model Table*
148+
149+
This table following the graph lists all objects in the partitioned ONNX model:
150+
151+
- Processor (NPU or CPU)
152+
- Function (Layer)
153+
- Operator
154+
- Ports
155+
- NPU Partitions
156+
157+
158+
NPU INSIGHTS
159+
@@@@@@@@@@@@
160+
161+
This section is comprised of three pages: Summary, Original Graph, and Optimized Graph.
162+
163+
164+
165+
**Summary**
166+
167+
The Summary page gives an overview of how your model was mapped to the AMD Ryzen NPU. Charts are displayed showing statistics on the number of operators and total GMACs that have been mapped to the NPU (and if necessary, back to CPU via the `Failsafe CPU` mechanism). The statistics are shown per operator type and NPU partition.
168+
169+
170+
171+
**Original Graph**
172+
173+
This is an interactive graph representing your model, lowered to supported NPU primitive operators and divided into partitions if necessary. As with the PARTITIONING graph, a companion table lists all model elements and supports cross-probing with the graph view. The objects in both the graph and the table also cross-probe with the PARTITIONING graph.
174+
175+
Toolbar
176+
177+
You can choose to show/hide individual NPU partitions, if any, with the **Filter by Partition** button
178+
A panel that displays properties for selected objects can be shown or hidden using the **Show Properties** toggle button
179+
A code viewer showing the MLIR source code with cross-probing can be shown/hidden through the **Show Code View** button
180+
The following table can be shown and hidden using the **Show Table** toggle button.
181+
Display options for the graph can be accessed with the **Settings** button
182+
183+
184+
185+
**Optimized Graph**
186+
187+
This page shows the final model that is mapped to the NPU after all transformations and optimizations such as fusion and chaining. It also reports the operators that had to be moved back to the CPU through the `Failsafe CPU` mechanism. As usual, there is a companion table below that contains all of the graph's elements, and cross-selection is supported to and from the PARTITIONING graph and the Original Graph.
188+
189+
Toolbar
190+
191+
You can choose to show/hide individual NPU partitions, if any, with the **Filter by Partition** button
192+
A panel that displays properties for selected objects can be shown or hidden using the **Show Properties** toggle button
193+
The following table can be shown and hidden using the **Show Table** toggle button.
194+
Display options for the graph can be accessed with the **Settings** button
195+
196+
197+
PERFORMANCE
198+
@@@@@@@@@@@
199+
200+
Use this section to view the performance of your model on RyzenAI when running one or more inferences. It is comprised of two pages: Summary and Timeline.
201+
202+
203+
204+
**Summary**
205+
206+
The performance summary page displays several overall statistics for the inference(s), along with charts that break down operator runtime by operator.
207+
When the ONNX Runtime profiler is enabled, the total inference time, including layers executed on the CPU, is shown.
208+
When NPU profiling is enabled using the `ai_analyzer_profiling` flag, additional NPU-specific statistics are displayed, including GOP and MAC efficiency, as well as a chart showing runtime per NPU operator type.
209+
210+
The clock frequency field shows the assumed NPU clock frequency, but it is editable. When the frequency is changed, all timestamp data—collected as clock cycles but displayed in time units—is adjusted accordingly.
211+
212+
**Timeline**
213+
214+
The Performance timeline shows a layer-by-layer breakdown of your model's execution. The upper section is a graphical depiction of layer execution across a timeline, while the lower section shows the same information in tabular format. It is important to note that the Timeline page shows one inference at a time, so if you have captured profiling data for two or more inferences, you can choose which one to display with the **Inferences** chooser.
215+
216+
217+
Within each inference, you can examine the overall model execution or the detailed NPU execution data by using the **Partition** chooser.
218+
219+
220+
221+
Toolbar
222+
223+
A panel that displays properties for selected objects can be shown or hidden using the **Show Properties** toggle button
224+
The following table can be shown and hidden using the **Show Table** toggle button.
225+
The graphical timeline can be downloaded to SVG using the **Export to SVG** button
226+
227+
228+
..
229+
------------
230+
231+
#####################################
232+
License
233+
#####################################
234+
235+
Ryzen AI is licensed under `MIT License <https://github.com/amd/ryzen-ai-documentation/blob/main/License>`_ . Refer to the `LICENSE File <https://github.com/amd/ryzen-ai-documentation/blob/main/License>`_ for the full license text and copyright notice.
236+

0 commit comments

Comments
 (0)