pytorch / pytorch/executorch

ETDump adds runtime overhead by serializing the flatbuffer during inference

Open
#20,467 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🚀 The feature, motivation and pitch

Problem

ETDump builds its output flatbuffer inline, while inference is running. Every event that gets traced (op profiling, intermediate-output logging, allocations) drives the flatbuffer builder synchronously, which includes building tables, pushing size/stride vectors, interning strings, etc. That serialization work is paid per event, on the critical path, so enabling ETDump adds significant latency to the run. When doing per-op profiling, this can be subtracted out in the inspector post-processing, but it can give a misleading indicator of "framework tax." Ie, how much latency does the framework itself add to a run? Some users wind up profiling models once with ETDump enabled and once without, just to be able to get both E2E & per-op profiling.

Proposed idea

Decouple data collection from serialization. During inference, record events into in-memory objects (cheap appends, no flatbuffer work). Then, after inference completes (or rather, when user requests the data), walk those collected objects once and serialize the flatbuffer in a single pass. This keeps the flatbuffer format and downstream tooling unchanged. The downside to this approach is that it will increase the memory needs, but that may be worth the trade off for some. I'd recommend that this be an alternative implementation of ETDumpGen rather than a replacement.

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

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 locating ETDumpGen and tracing its current event collection and flatbuffer serialization path. Compare the inference-time work with the post-inference data request path, then preserve the existing flatbuffer format and downstream tooling while validating latency and memory effects.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot, machine-learning, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.