[submodule] [Snapshot/Profiler] Memory Snapshot On Demand (#150559)

Summary:
Profiler side of memory snapshot.

1. Add API to actually do snapshot when client interface is called
2. Add ifdefs to builds so that kineto hooks snapshot correctly.

Design Philosophy: There is one interesting part of this implementation and it is during export. For export we are callign the python impl of the export rather than CPP even though we are already in CPP. This is because it is better to simply have one path of export rather than 2. Personally, I want there to be parity between auto-trace and on-demand so it if we can limit the side paths then we will have an easier time maintaining this relationship

Test Plan: {F1976563426}

Reviewed By: sanrise

Differential Revision: D70733247

Pull Request resolved: https://github.com/pytorch/pytorch/pull/150559
Approved by: https://github.com/sanrise
This commit is contained in:
Shivam Raikundalia
2025-04-07 13:04:38 +00:00
committed by PyTorch MergeBot
parent e209625334
commit 99c9a31386
10 changed files with 160 additions and 6 deletions

View File

@ -1725,6 +1725,7 @@ def define_buck_targets(
compiler_flags = get_pt_compiler_flags() + ["-Wno-error"],
exported_preprocessor_flags = get_pt_preprocessor_flags() + [
"-DUSE_KINETO",
"-DTMP_IMPL_MEMORY_PROFILING_ON_DEMAND",
# Need this otherwise USE_KINETO is undefed
# for mobile
"-DEDGE_PROFILER_USE_KINETO",
@ -1750,6 +1751,7 @@ def define_buck_targets(
exported_preprocessor_flags = get_pt_preprocessor_flags() + [
"-DUSE_KINETO",
"-DEDGE_PROFILER_USE_KINETO",
"-DTMP_IMPL_MEMORY_PROFILING_ON_DEMAND",
],
# @lint-ignore BUCKLINT link_whole
link_whole = True,
@ -1836,6 +1838,7 @@ def define_buck_targets(
# Need this otherwise USE_KINETO is undefed
# for mobile
"-DEDGE_PROFILER_USE_KINETO",
"-DTMP_IMPL_MEMORY_PROFILING_ON_DEMAND",
] + (["-DFB_XPLAT_BUILD"] if not IS_OSS else []),
extra_flags = {
"fbandroid_compiler_flags": ["-frtti"],