콘텐츠로 이동

Python Kineto API

1
import hapti.kineto

PyTorch 프로파일러와 LPU 활동 내역을 통합하기 위한 Kineto 플러그인 등록 API입니다.

함수 시그니처 비고
register () -> None Kineto 플러그인을 동적 로드하여 LPU 하드웨어 활동 내역이 torch.profiler 출력 결과에 포함되도록 등록함. 여러 번 호출해도 안전하며, 플러그인 라이브러리를 찾지 못한 경우 FileNotFoundError 발생

사용 시 주의사항

Kineto 플러그인은 torch.profiler의 profile() 블록 구간 동안에만 LPU 활동을 수집합니다. 또한 haprof 런처와 동일 프로세스 내에서 중복 활성화할 경우 디바이스 레코드 링 접근 충돌로 인해 한쪽 트레이스에서 디바이스 활동이 누락될 수 있으므로 둘 중 하나의 방식만 선택하여 사용해야 합니다.


예제

register

torch.profiler 구간에 LPU 활동이 들어오게 합니다. ProfilerActivity.PrivateUse1을 함께 지정해야 합니다.

예제
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")