feat: render torch.profiler GPU profiles in the Flyte report - #1414
Draft
pingsutw wants to merge 1 commit into
Draft
feat: render torch.profiler GPU profiles in the Flyte report#1414pingsutw wants to merge 1 commit into
pingsutw wants to merge 1 commit into
Conversation
Add torch_profile() to flyteplugins-pytorch: a context manager (sync and async) that runs torch.profiler over a region of a task body and renders the result into a Flyte report tab — summary tiles, top-ops tables, and an interactive Perfetto timeline (the gzipped chrome trace is base64- embedded and pushed into a lazy ui.perfetto.dev iframe via its postMessage deep-link API), plus a trace download button. Traces over an embed cap are uploaded to blob storage and linked instead. Rendering is best-effort and never fails the task; body exceptions are never suppressed. Verified end-to-end on the demo cluster (L4 GPU). Claude-Session: https://claude.ai/code/session_01FoFxbPpsYcWMny59J63BZM Signed-off-by: Kevin Su <pingsutw@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Users profiling GPU tasks with
torch.profilerhad to download traces and open them in Perfetto/chrome://tracing manually. This surfaces the profile directly in the Flyte UI report: an interactive Perfetto timeline (ProfilerStep /matmul_add/aten::mmspans on CPU and CUDA tracks) plus self-contained summary tables. Closest prior art isplugins/nsight(nsys summary deck); this brings the same idea to the in-process PyTorch profiler, with an explorable flamegraph.What
flyteplugins-pytorchgainstorch_profile(), a context manager usable in sync and async task bodies:Two knobs (
tab,max_embed_mb); everything else passes through totorch.profiler.profile. On exit it renders one report tab:ui.perfetto.dev, fed the gzipped chrome trace (base64-embedded) via Perfetto's documented PING/PONG postMessage API — lazy both to avoid loading the heavy app unprompted and because hidden report tabs aredisplay:nonemax_embed_mb(50 MB default, gzipped) skip the embed: uploaded viaFile.from_local_syncand linked insteadRendering is best-effort — a profiling/rendering failure never fails the task; body exceptions are never suppressed. Requires
@env.task(report=True)(runtime warning if missing). Single-process tasks; distributed rank-0 handling is a follow-up.Verification
plugins/pytorch/tests/test_profile.py), ruff clean.u8knbp7d4lxkzzwwwpknin flytesnacks/development — report shows 122.61 ms device time,cutlass_80_simt_sgemm/CUDAFunctor_addkernels, and the Perfetto timeline loads the trace in-place. Console renders it (report iframe sandbox grantsallow-scripts/allow-popups; no CSP blocks the child iframe).Gotcha encoded in the example
torch.profiler.schedulewithoutrepeat=1clears collected events when stepping past the active window → empty report. The example and docstring pinrepeat=1with a comment.