meta-pytorch / meta-pytorch/data

[RFC] Performance Profiling Tools

Open
#1,149 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

topic: new feature
Dominant language
Python
Stars
1.3k
Forks
179
Avg merge
6d 1h
Merged PRs (30d)
2

Description

🚀 The feature
  1. Store usage statistics in Prefetcher

    • By tracking statistics within Prefetcher, we can reasonably determine whether upstream processes or downstream processes are faster. For example, the emptiness of the buffer queue may imply consumers are faster than producers. Users can insert this into various points in the pipeline to examine various behaviors. A common pattern we expect is to examine whether the pipeline is IO bound or compute bound.
    • #1141
  2. DataLoader2 main process

    • torch profilers (e.g. torch.profiler.profile) currently work with DataLoader2, however, it only tracks functions and DataPipes that are executed within the main process. Nonetheless, we should validate that the information is helpful if most of the computations take place within the main process (e.g. using InProcessReadingService or dispatching process.
    • After 1 is completed, we can add APIs to DataLoader2 to fetch the relevant statistics from Prefetcher's buffer, such as the one that exists at the end of the main loop. It should allow users to examine whether the model is consuming faster than the preparation of samples.
    • PR pending
    • Tutorial pending
  3. DataLoader2 worker process profiling

    • Two main options under considerations are:
      1. Attaching the profiler to worker process in order to get worker level metrics/trace. This will allow us to use existing profilers without re-implementing their features.
      2. MultiprocessingReadingService can provide methods to retrieve and aggregate metrics from certain DataPipes (mainly Prefetcher)
  4. Integration with other tools (e.g. tracers)

    • We will likely want main and worker processes' to be visible within tracers (e.g. useful when integrated with TorchTNT).
Motivation, pitch

This set of tools and features aim to answer the questions:

  1. Is my model training bottlenecked by data loading?
  2. If so, which part of the pipeline? IO? Compute?
Alternatives

No response

Additional context

Comments and suggestions are welcomed.

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 by reading the Prefetcher and DataLoader2 entry points, including InProcessReadingService and MultiprocessingReadingService, then review how torch.profiler.profile currently observes the main process. The RFC is complete only when the profiling scope, worker-process metrics, aggregation APIs, and tracer integration have concrete designs and validation plans.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.