-
Notifications
You must be signed in to change notification settings - Fork 417
xprof user guide #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
xprof user guide #2300
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Xprof User Guide for Maxtext Developers | ||
|
||
|
||
## Introduction to Xprof | ||
|
||
Xprof is a powerful tool designed for profiling and analyzing the training performance of AI models. For Maxtext developers, understanding and utilizing Xprof can significantly help in optimizing model performance, identifying bottlenecks, and improving training efficiency. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Xprof is not open sourced? We probably should recommend to use tensorboard or other OSS tools instead, like cloud version? |
||
|
||
|
||
## Profiling Jax | ||
|
||
Xprof supports profiling Jax models, which is crucial for Maxtext developers working with Jax. You can profile your Jax models using various methods, including: | ||
|
||
|
||
|
||
* **Sampling Mode:** This mode allows for continuous profiling by sampling data during model execution. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curious, how to do |
||
* **Programmatic Mode:** This provides more granular control over when and what to profile, allowing you to instrument your code with specific profiling markers. This method is integrated with Maxtext code. | ||
|
||
|
||
Below is an example of how programmatic Xprof works with Python code. | ||
|
||
|
||
``` | ||
jax.profiler.trace(profile_diretory) | ||
batch = next(data_iterator) | ||
with jax.profiler.StepTraceAnnotation("train_step", step_num=i): | ||
state, metrics = train_step(state, batch) | ||
jax.profiler.stop() | ||
``` | ||
|
||
|
||
`jax.profiler.TraceAnnotation` is a tool for adding custom annotations to JAX traces. | ||
|
||
|
||
## Xprof UI Features | ||
|
||
The Xprof User Interface (UI) offers several key features to help you analyze your profiling data: | ||
|
||
|
||
|
||
* Trace Viewer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be great if we have some screenshot to show customers especially for someone is not familiar with tool, like Trace View. But not mandatory (if you think this is clear) :) Similar comments for other section. |
||
|
||
Visualize the execution timeline of your model, allowing you to see the duration of different operations and identify sequential dependencies. | ||
|
||
|
||
At the XLA Operations level, you can click on each HLO operation to view its shape, wall-duration, and timing statistics. | ||
|
||
|
||
* Graph Viewer | ||
|
||
A High-Level Optimizer (HLO) graph browser tool. It enables a graph view to visualize HLOs with their input and output compute flow. | ||
|
||
|
||
|
||
* HLO Profile | ||
|
||
|
||
Provides insights into the HLO operations, including their costs and execution times. | ||
|
||
|
||
Top overall FLOPS/bandwidth utilization showed weight average across all ops in the captured graph. | ||
|
||
|
||
You can click each individual ops, which shows individual op flops utilization and HBM utilization. | ||
|
||
|
||
|
||
* HLO Op Stats | ||
|
||
roofline analysis of operations | ||
|
||
* Roofline Model | ||
|
||
You can view both Program-Level Analysis and operation-level analysis | ||
|
||
|
||
`achievable FLOP/s = min(peak FLOP/s, peak BW \* operational intensity)` | ||
|
||
|
||
`operational intensity = FLOPs / bytes` | ||
|
||
|
||
For each HLO operation, you can view FLOPs rate, HBM rate, and roofline efficiency. It also indicates whether the operation is HBM or compute-bound based on these calculations. | ||
|
||
|
||
|
||
* **Memory Viewer** | ||
|
||
Analyze memory usage patterns during model training, crucial for optimizing memory-intensive operations. | ||
|
||
From this tab, you can view each buffer allocation's source code, shape, and spanned time frame. | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of this is maxtext specific, is there any xprof documentation we can point to instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would find some xprof folks to review this as well and comment if we can't find any, rjesha@ probably knows who to reach out to