Skip to content

Commit 740eb42

Browse files
xieofxiehualxientrogh
authored
update profiling doc for AITK (#9644)
* update profiling with OP * WIP * add genai * fix * Update docs/intelligentapps/profiling.md Co-authored-by: Nick Trogh <ntrogh@hotmail.com> * Update docs/intelligentapps/profiling.md Co-authored-by: Nick Trogh <ntrogh@hotmail.com> --------- Co-authored-by: hualxie <hualxie@microsoft.com> Co-authored-by: Nick Trogh <ntrogh@hotmail.com>
1 parent 3c46b7a commit 740eb42

10 files changed

Lines changed: 53 additions & 25 deletions
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

docs/intelligentapps/images/profiling/by-model-file-config.png

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

docs/intelligentapps/images/profiling/by-process-id-or-name.png

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Loading

docs/intelligentapps/images/profiling/the-next-session-guide.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/intelligentapps/profiling.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ MetaDescription: Profiling Quickstart in AI Toolkit.
55
---
66
# Profiling an app using Windows Machine Learning
77

8-
Profiling is a tool designed to help developers and AI engineers to diagnose the CPU, GPU, NPU resource usages of processes, ONNX model on different execution providers, and Windows ML events.
8+
Profiling is a tool designed to help developers and AI engineers to diagnose CPU, GPU, and NPU resource usage of processes, profile ONNX models on different execution providers, and capture Windows ML events.
99

10-
In this article, you could learn how to start profiling and how to inspect the resource usages view and the events view.
10+
In this article, you learn how to start profiling and how to inspect the resource usage view and the events view.
1111

1212
## Prerequisites
1313

@@ -17,9 +17,9 @@ In this article, you could learn how to start profiling and how to inspect the r
1717
## Profile on app startup
1818

1919
In this mode, the profiling tool profiles the next app that is started and that is sending out Windows ML events.
20-
This option is ideal for testing a run-once app. In this case, you start profiling, then run the app, and the resource usages will begin showing up.
20+
This option is ideal for testing a run-once app. In this case, you start profiling, then run the app, and the resource usage will appear.
2121

22-
![Screenshot that shows how to start by the next session](./images/profiling/the-next-session-guide.png)
22+
![Screenshot that shows how to start by the next session](./images/profiling/the-next-session-guide-2.png)
2323

2424
The tool starts profiling a newly started app. This means that for profiling a Python notebook, if the kernel is already running, you need to restart the kernel to begin profiling for it. Just starting a new notebook does not automatically start profiling.
2525

@@ -38,15 +38,15 @@ In this mode, the profiling tool starts profiling an already running app. You ca
3838

3939
This option is ideal for profiling an app that is already running and you're unable to restart it for profiling purposes.
4040

41-
![Screenshot that shows how to start by process id or name](./images/profiling/by-process-id-or-name.png)
41+
![Screenshot that shows how to start by process id or name](./images/profiling/by-process-id-or-name-2.png)
4242

4343
## Profile an ONNX model
4444

45-
In this mode, the profiling tool starts profiling an ONNX model file on a target execution provider (EP) or device policy for a given duration. You can see the resource usage while it's running.
45+
In this mode, the profiling tool starts profiling an ONNX model file on a target execution provider (EP) for a given duration. You can see the resource usage while it's running.
4646

47-
This option is ideal for profiling an ONNX model on different EPs or device policies.
47+
This option is ideal for profiling an ONNX model on different EPs.
4848

49-
![Screenshot that shows how to start by model file](./images/profiling/by-model-file-config.png)
49+
![Screenshot that shows how to start by model file](./images/profiling/by-model-file-config-2.png)
5050

5151
After profiling, a notification shows up to guide you to open or save the report.
5252

@@ -56,28 +56,47 @@ The report contains detailed profiling statistics and results for the ONNX model
5656

5757
![Screenshot that shows the report data](./images/profiling/by-model-file-result.png)
5858

59-
## Resource Usages view
59+
### Benchmark time for each operation
6060

61-
In the main window, the plot on the top shows usage of CPU, GPU, NPU, and memory. The usage is updated every second, and kept for 10 minutes. You can use the tools on the top right to navigate the timeline by zooming in, zooming out, and panning.
61+
If OP Profiling is enabled, op level data will be generated to allow you to inspect the model in more detail.
6262

63-
![Screenshot that shows the resource usages view](./images/profiling/resource-usage-view.png)
63+
![Screenshot that shows the succeeded notification with OP profiling enabled](./images/profiling/by-model-file-op-succeeded.png)
64+
65+
The report contains detailed latencies for each op.
66+
67+
![Screenshot that shows the report data for each OP](./images/profiling/by-model-file-op-result.png)
68+
69+
## Profile an ONNX GenAI model
70+
71+
In this mode, the profiling tool starts profiling an ONNX GenAI model on a target execution provider (EP) for a specified number of prompts. You can see the resource usage while it's running.
72+
73+
![Screenshot that shows how to start by genai model](./images/profiling/by-genai-model-file-config.png)
74+
75+
> [!NOTE]
76+
> You need to select the folder of the GenAI model, this is the folder that contains `genai_config.json`.
77+
78+
## Resource Usage view
79+
80+
In the main window, the plot on the top shows usage of CPU, GPU, NPU, and memory. The usage is updated every second, and is kept for 10 minutes. You can use the tools on the top right to navigate the timeline by zooming in, zooming out, and panning.
81+
82+
![Screenshot that shows the resource usage view](./images/profiling/resource-usage-view.png)
6483

6584
> [!NOTE]
6685
> This feature uses performance counters. To achieve higher accuracy, you could also try [Windows Performance Recorder](https://learn.microsoft.com/en-us/windows-hardware/test/wpt/windows-performance-recorder).
6786
6887
## Windows ML Events view
6988

70-
In the main window, the plot on the bottom shows Windows ML events. Its timeline is synced with the Resource Usages view, so you can easily determine how resources are used when certain events occur.
89+
In the main window, the plot on the bottom shows Windows ML events. Its timeline is synchronized with the Resource Usage view, so you can easily determine how resources are used when certain events occur.
7190

72-
> [!Important]
91+
> [!IMPORTANT]
7392
> To receive Windows ML events, the tool needs to be run in admin mode. If VS Code is not started in admin mode, a notification shows up and guides you to restart VS Code. You need to close all other VS Code instances to make the restart in admin mode work.
7493
> ![Screenshot that shows a notification to restart VS Code in admin mode](./images/profiling/events-view-admin.png)
7594
76-
Currently, we only show events of the following types:
95+
Currently, only the following event types are shown:
7796

7897
- Ensure ExecutionProvider Ready: when Windows ML is preparing the EP
7998
- Session Creation: when the session is created
80-
- Inference: when the model inferences on the session
99+
- Inference: when the model runs inference on the session
81100

82101
![Screenshot that shows the Windows ML events view](./images/profiling/events-view.png)
83102

@@ -86,7 +105,7 @@ Currently, we only show events of the following types:
86105
In this article, you learned how to:
87106

88107
- Start profiling in different ways
89-
- Inspect the Resource Usages view
108+
- Inspect the Resource Usage view
90109
- Inspect the Windows ML Events view
91110

92111
## See also

0 commit comments

Comments
 (0)