Repository navigation
Pytorch backend: analysis #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TApplencourt
merged 30 commits into
argonne-lcf:devel
from
DonAurelio:pytorch-backend-analysis
Sep 29, 2026
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8451c47
Add PyTorch backend interval filter
a625d1f
Register pytorch backend with tally and default --backends lists
DonAurelio a4d774c
pytorch: fix entry/exit duration corruption on nested/reentrant ops
DonAurelio f56ba94
validate pytorch version
DonAurelio 020785b
LTTNG_UST_PYTORCH_LIBRARY_PATH
DonAurelio 5c02d90
Formatting
DonAurelio adbf879
Rename to pytorch_tracepoints.h, add overload_name support, re-write …
DonAurelio d547349
Delete trailing blank line
DonAurelio 8a02e8a
Merge branch 'argonne-lcf:devel' into pytorch-backend-analysis
DonAurelio be64fae
remove unnecesary import
DonAurelio 275b21e
Update get_pytorch_library_path
DonAurelio ea9f813
Do not raise on failure but report as warning
DonAurelio 6adfc70
integration test
DonAurelio c32177a
formating
DonAurelio 02a08e1
debug
DonAurelio c13d4e8
ci: add pytorch tracer load diagnostics on failure
DonAurelio 4a1a3f3
ci: document how to trigger the tmate SSH debug step
DonAurelio d662160
ci: time-box integration test so hangs trigger diagnostics
DonAurelio 6130340
ci: shorten debug timeouts (integration test 2m, probes 15s)
DonAurelio f5cef5c
ci: make pytorch tracer diagnostics hang-proof
DonAurelio 579bb97
ci: disable errexit in diagnostics step so probes actually print
DonAurelio 544170a
Refactor presubmit workflow for debugging
DonAurelio 398dc70
Remove tmate session setup from presubmit workflow
DonAurelio 195bf3f
Remove iprof debug step from presubmit workflow
DonAurelio 17d9360
Update LDFLAGS for libTracerPytorch
DonAurelio 5c5271a
Fix LDFLAGS syntax in Makefile.am
DonAurelio e19f8c2
remove debugging
DonAurelio 6d52b62
Merge branch 'devel' into pytorch-backend-analysis
DonAurelio 1afdaef
Add PyTorch installation to presubmit workflow
DonAurelio 22e97c8
Update PyTorch installation in presubmit workflow
DonAurelio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| :environment: | ||
| :entries: | ||
| - :name: hostname | ||
| :type: string | ||
| :stream_classes: | ||
| - :name: thapi_pytorch | ||
| :default_clock_class: {} | ||
| :packet_context_field_class: | ||
| :type: structure | ||
| :members: | ||
| - :name: cpu_id | ||
| :field_class: | ||
| :type: integer_unsigned | ||
| :cast_type: uint64_t | ||
| :field_value_range: 32 | ||
| :event_common_context_field_class: | ||
| :type: structure | ||
| :members: | ||
| - :name: vpid | ||
| :field_class: | ||
| :type: integer_signed | ||
| :cast_type: int64_t | ||
| :field_value_range: 64 | ||
| - :name: vtid | ||
| :field_class: | ||
| :type: integer_unsigned | ||
| :cast_type: uint64_t | ||
| :field_value_range: 64 | ||
| :event_classes: | ||
| - :name: lttng_ust_pytorch:op_entry | ||
| :payload_field_class: | ||
| :type: structure | ||
| :members: | ||
| - :name: name | ||
| :field_class: | ||
| :cast_type: char * | ||
| :type: string | ||
| - :name: overload_name | ||
| :field_class: | ||
| :cast_type: char * | ||
| :type: string | ||
| - :name: lttng_ust_pytorch:op_exit | ||
| :payload_field_class: | ||
| :type: structure | ||
| :members: | ||
| - :name: name | ||
| :field_class: | ||
| :cast_type: char * | ||
| :type: string | ||
| - :name: overload_name | ||
| :field_class: | ||
| :cast_type: char * | ||
| :type: string |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #include "xprof_utils.hpp" | ||
| #include <metababel/metababel.h> | ||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| // PyTorch requies a per-thread LIFO stack since there is reentrace and nesting calls. | ||
| struct data_s { | ||
| std::unordered_map<hpt_t, std::vector<int64_t>> entry_stack; | ||
| }; | ||
| typedef struct data_s data_t; | ||
|
|
||
| static void btx_initialize_component(void **usr_data) { *usr_data = new data_t; } | ||
|
|
||
| static void btx_finalize_component(void *usr_data) { delete static_cast<data_t *>(usr_data); } | ||
|
|
||
| // PyTorch identifies an operator by TWO strings: a schema name (e.g. | ||
| // "aten::abs") and an overload name (e.g. "" for the default overload, "out" | ||
| // Joining them here keeps e.g. "aten::abs" and "aten::abs.out" distinguishable | ||
| // in the trace instead of both showing up as plain "aten::abs". | ||
| static std::string qualified_name(const char *name, const char *overload_name) { | ||
| return (overload_name[0] == '\0') ? name : std::string(name) + "." + overload_name; | ||
| } | ||
|
|
||
| static void lttng_ust_pytorch_op_entry_callback(void *btx_handle, | ||
| void *usr_data, | ||
| int64_t ts, | ||
| const char *hostname, | ||
| int64_t vpid, | ||
| uint64_t vtid, | ||
| char * /*name*/, | ||
| char * /*overload_name*/) { | ||
| static_cast<data_t *>(usr_data)->entry_stack[{hostname, vpid, vtid}].push_back(ts); | ||
| } | ||
|
|
||
| static void lttng_ust_pytorch_op_exit_callback(void *btx_handle, | ||
| void *usr_data, | ||
| int64_t ts, | ||
| const char *hostname, | ||
| int64_t vpid, | ||
| uint64_t vtid, | ||
| char *name, | ||
| char *overload_name) { | ||
| auto *state = static_cast<data_t *>(usr_data); | ||
| auto &stack = state->entry_stack[{hostname, vpid, vtid}]; | ||
|
|
||
| // Empty means an exit arrived with no matching entry | ||
| const bool err = stack.empty(); | ||
| int64_t entry_ts = ts; | ||
| if (!err) { | ||
| entry_ts = stack.back(); | ||
| stack.pop_back(); | ||
| } | ||
|
|
||
| const std::string full_name = qualified_name(name, overload_name); | ||
| btx_push_message_lttng_host(btx_handle, hostname, vpid, vtid, entry_ts, BACKEND_PYTORCH, | ||
| full_name.c_str(), (ts - entry_ts), err); | ||
| } | ||
|
|
||
| void btx_register_usr_callbacks(void *btx_handle) { | ||
| btx_register_callbacks_initialize_component(btx_handle, &btx_initialize_component); | ||
| btx_register_callbacks_finalize_component(btx_handle, &btx_finalize_component); | ||
|
|
||
| btx_register_callbacks_lttng_ust_pytorch_op_entry(btx_handle, | ||
| <tng_ust_pytorch_op_entry_callback); | ||
| btx_register_callbacks_lttng_ust_pytorch_op_exit(btx_handle, <tng_ust_pytorch_op_exit_callback); | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| bats_require_minimum_version 1.5.0 | ||
|
|
||
| @test "PyTorch: trace contains aten::empty.memory_format" { | ||
| iprof --backends pytorch --analysis-output ./pytorch_out.txt -- \ | ||
| python3 ./integration_tests/pytorch_example.py | ||
| grep "aten::empty.memory_format" ./pytorch_out.txt | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| import torch | ||
| torch.empty(3) |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.