openxla/xprof

A profiling and performance analysis tool for machine learning

What it is

XProf is an open, scalable, and extensible profiler for the modern ML stack. It also ships as a TensorBoard plugin. In plain terms: it's a tool that records what your machine-learning model does during execution and shows you visual breakdowns of that activity, so you can find slowdowns or memory problems.

What it does

XProf provides four main tools:

  • Overview Page — A high-level summary of your model's performance, aggregated across the host machine and all devices. It shows a performance summary with step-time breakdowns, a graph of individual step times, and details about the run environment.
  • Trace Viewer — A timeline of your model's execution. It shows how long each operation (op) took, whether the host or a device executed it, and how devices communicated with each other.
  • Memory Profile — Monitors how much memory your model uses.
  • Graph Viewer — A visualization of the graph structure of your model's HLOs (the README doesn't define HLO, but it's the model's internal computation graph).

Installation

The standard way is via pip:

pip install xprof

Alternative options:

  • With TensorBoard: pip install xprof tensorboard
  • Google Cloud: The README recommends a separate tool called xprofiler for Google Cloud workloads.
  • Nightly releases: A xprof-nightly package is published every night with the latest developer changes. Install it after uninstalling the stable versions.
  • Build from source: Requires Bazel (the build system). Clone the repo, run bazel run --config=public_cache plugin:build_pip_package, then install the resulting package. On Apple Silicon Macs, you must build the native extension with specific SDK and OS-version flags (documented in the README).

Usage

Standalone

If you have profile data in a directory, view it with:

xprof --logdir=profiler/demo --port=6006

or equivalently:

xprof server --logdir=profiler/demo --port=6006

With TensorBoard

tensorboard --logdir=profiler/demo

Then open localhost:6006/#profile in your browser.

Important caveat: XProf needs internet access to load Google's Chart library. Some charts and tables may be missing if you run it fully offline, behind a corporate firewall, or in a datacenter.

Command-line options

Key flags (full table in the README):

  • --logdir / -l — Directory containing profile data (files ending in .xplane.pb). If omitted, XProf starts with no profiles loaded.
  • --port / -p — Web server port (default 8791).
  • --host — Host address to bind to (default 127.0.0.1; falls back to XPROF_HOST env var).
  • --grpc_port / -g — Port for the gRPC server used in distributed processing (default 50051; must differ from --port).
  • --worker_service_address / -w — Comma-separated worker addresses for distributed processing.
  • --hide_capture_profile_button / -h — Hides the "Capture Profile" button in the UI.
  • --enable_tab_name_label / -e — Shows a per-tab name label (default False).
  • --src_prefix / -s — Prefix for source-file paths, used for source-code linking.
  • --max_concurrent_worker_requests / -m — Max concurrent requests a worker's gRPC server handles (default 1).

Log directory structure

Profile data must live in a specific layout:

<log_dir>/plugins/profile/<session_name>/
  • <log_dir> is the root you pass to --logdir.
  • plugins/profile/ is a required subdirectory.
  • Each <session_name> subdirectory is one profiling session; its name appears in the UI's session dropdown.

Example:

/path/to/your/log_dir/
└── plugins/
    └── profile/
        ├── my_experiment_run_1/
        │   └── host0.xplane.pb
        └── benchmark_20251107/
            └── host1.xplane.pb

Loading profiles dynamically via URL

You can also load sessions from a GCS bucket or local filesystem using URL parameters, without restarting XProf:

  • session_path — Loads a single session directory directly. Example: http://localhost:8791/?session_path=gs://your-bucket/profile_runs/my_experiment_run_1
  • run_path — Points to a directory containing multiple session directories; all appear in the Sessions dropdown. Example: http://localhost:8791/?run_path=gs://your-bucket/profile_runs/

Precedence if multiple sources are given: session_path > run_path > logdir.

Distributed profiling

For very large profiles or many users, XProf can split work across machines:

  • Worker nodes run xprof server --grpc_port=50051 --port=9999 --hide_capture_profile_button (the capture button is hidden because workers aren't meant to be used directly).
  • Aggregator node runs xprof server --worker_service_address=<worker1_ip>:50051,<worker2_ip>:50051 --host=0.0.0.0 --port=6006 --logdir=profiler/demo. Users interact with the aggregator's UI, and requests are distributed to workers.

Note: distributed processing currently only benefits these tools: overview_page, framework_op_stats, input_pipeline, and pod_viewer. The README also warns that binding to 0.0.0.0 disables loopback host-header enforcement, so it should only be exposed behind firewall rules or an authenticating proxy.

Resources

The README links to profiling guides for JAX, PyTorch/XLA, TensorFlow, Cloud TPU, and Colab tutorials.

Citing

If you use XProf in academic work, the README provides a BibTeX entry for the MLSys 2026 paper: "XProf: An Open, Scalable and Extensible Profiling System for the Modern ML Stack" (Hundt et al.).

Related

  • Project
  • Project
  • Project
  • Project
  • Project