OpenNMT / OpenNMT/CTranslate2

[Feature Request] Expose Profiler to Python

Open
#1,736 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
4.7k
Forks
536
Avg merge
12h 12m
Merged PRs (30d)
4

Description

Problem

We am working on analyzing the performance of different layers of a workload and comparing the performance with different backends.

The current issue is that we are running whisper via python and were not able to use the built in profiler

I came across this comment which surprised me it still has not been implemented.

Solution

As a workaround, I exposed the profiler to python with some small code modifications and it seemed to function smoothly on my linux env.

see changes here:
https://github.com/OpenNMT/CTranslate2/compare/master...yehudaorel:CTranslate2:python_profiler

I am aware I hard coded threads and device but this can easily be fixed.

Usage:

import ctranslate2

ctranslate2.init_profiler()
 # Translate/Transcribe
ctranslate2.dump_profiler()

I understand this is a very niche request but would be extremely beneficial to have integrated and properly documented. Let me know if you would like me to refine the implementation and open a PR for the fix.
Either way I thought to leave this hear in case someone else would like to use it in the future.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with include/ctranslate2/profiler.h and the exposed ctranslate2 Python usage described in the issue; review the linked python_profiler changes for the proposed integration. Confirm how profiler initialization and output should be exposed without hard-coded threads or device settings, then document the supported usage and verify it works for Python workloads.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend-api-design, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.