Skip to content

Python Kineto API

1
import hapti.kineto

API for registering the Kineto plugin, which integrates LPU activity with the PyTorch profiler.

Function Signature Notes
register () -> None Dynamically loads the Kineto plugin and registers it so that LPU hardware activity is included in the torch.profiler output. Safe to call more than once (idempotent). Raises FileNotFoundError if the plugin library cannot be found

Usage notes

The Kineto plugin collects LPU activity only during the profile() block of torch.profiler. If it is enabled in the same process as the haprof launcher, the two contend for access to the device record ring and device activity can be missing from one of the traces, so use only one of the two.


Example

register

Adds LPU activity to the torch.profiler trace. ProfilerActivity.PrivateUse1 must also be specified.

Example
1
2
3
4
5
6
7
8
9
import hapti.kineto
from torch.profiler import ProfilerActivity, profile

hapti.kineto.register()

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.PrivateUse1]) as prof:
    model(x)

prof.export_chrome_trace("trace.json")