Repository navigation
Bugfix: Preserve Configuration-Specific PyTorch Traces - #893
Open
Shenghsun Cho (shcho) wants to merge 5 commits into
Open
Shenghsun Cho (shcho) wants to merge 5 commits into
Shenghsun Cho (shcho) wants to merge 5 commits into
Conversation
Derive the benchmark configuration from the executor's benchmarks/<name>/rank<N> working directory and retain an independent configuration-qualified copy after writing the legacy trace. Preserve legacy filenames and last-write behavior, and retain legacy-only output outside the recognized executor layout. Validated on MI300X and GB200: successful configuration/rank captures remain distinct and legacy copies match the last corresponding capture. The unchanged diagnosis converter preserves old-baseline/new-target conversion results. Focused exporter checks, YAPF, and Flake8 pass.
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Parallel local workers can overwrite shared profiler trace files, causing configuration-qualified traces to contain another worker’s events or incomplete JSON.
2 open issues
What changed in this PR
This PR extends PyTorch trace export to preserve configuration-specific captures while retaining legacy filenames and their existing overwrite behavior.
Changes:
- Detects the executor’s
benchmarks/<configuration>/rank<N>working-directory layout. - Copies exported traces to configuration-qualified filenames.
- Keeps legacy-only output outside the recognized layout.
| File | Description |
|---|---|
superbench/benchmarks/model_benchmarks/pytorch_base.py |
Detects configuration context and adds a separate trace copy after the legacy JSON write. |
Review effort: Balanced
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
==========================================
- Coverage 86.58% 86.17% -0.42%
==========================================
Files 107 107
Lines 8419 8457 +38
==========================================
- Hits 7290 7288 -2
- Misses 1129 1169 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Use the validated executor-directory rank for configuration-qualified filenames. Serialize each worker's own events directly to its qualified file so concurrent writes to the shared legacy file cannot corrupt the preserved trace. Keep legacy filenames and writes unchanged. Validation: six CUDA/HIP mocked exporter race and rank checks, five legacy compatibility checks against the pre-PR exporter, and the existing PyTorch base CPU unit test pass. One CUDA-only test was skipped. YAPF, Flake8, scoped mypy, and whitespace checks pass. No hardware captures were rerun for this revision.
Exercise the real profiler exporter with CPU-safe CUDA/HIP mocks. Cover multiple configurations and local/distributed ranks, independent legacy and qualified files, forced legacy overwrite/truncation, CPU event filtering, and legacy-only fallback. Validation: 15 tests passed and 1 CUDA-only test skipped in the existing PyTorch base test file. All seven new executable production lines are covered locally (100% patch coverage). YAPF, Flake8, scoped mypy, and whitespace checks pass. Production code is unchanged.
Encode and bound qualified filenames with stable configuration hashes. Carry complete configuration keys through the executor and restore the caller's environment after each launch. Use global distributed ranks to prevent shared-output collisions while preserving legacy filenames and independent trace writes. Add regressions for filename limits, reserved and multibyte names, configuration collisions, nested annotations, global ranks, and legacy-only fallback. Validation: 52 tests passed, 1 CUDA-only test skipped; YAPF, Flake8, scoped mypy, and whitespace checks passed. No hardware rerun.
This branch has not been deployed
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.

Description
Preserve PyTorch traces for separate benchmark configurations without removing the legacy filenames used by existing consumers. Follow-up to #817.
Currently, configurations sharing an internal model name and local rank write the same file, so a later configuration replaces the earlier trace.
Major Revision
benchmarks/<configuration>/rank<N>before profiling.torch-profiler-sb-<model>__cfg=<configuration>-<rank>.json, including non-distributed local workers.Minor Revision
Validation
--cov=superbenchcover all 7 newly added executable production lines: 100% local patch coverage. Earlier isolated compatibility checks also confirmed legacy filename/JSON-byte equivalence against the pre-PR exporter.tests/benchmarks/model_benchmarks/test_pytorch_base.py: 15 passed, 1 CUDA-only test skipped, using Python 3.10 and PyTorch 2.4.1 with hardware-only tests disabled.--follow-imports=skip), and whitespace checks passed. The latest test-only commit leaves the production exporter unchanged.Earlier Hardware Validation
The MI300X and GB200 smoke/full-profile runs below used the earlier revision
c8030384, before the local-worker rank/direct-write fix. They were not rerun for the latest revision6ee090f9:Multiple configurations sharing the same model/rank remain distinct. All 96 qualified GB200 JSON files were checked for valid, finite timing data and positive GPU timings.
Using real historical LSTM traces and an unchanged downstream converter, old-baseline/new-target conversion produced byte-identical outputs to the legacy-only control on both platforms. New/new comparisons discovered the additional qualified pairs. The existing new-baseline/old-target missing-counterpart warnings remain unchanged.
Validation Limits
The full suites completed with some benchmark failures; this is not an all-benchmarks-pass claim. On MI300X, the 16 absent qualified files corresponded to failed captures, not lost successful exports. No LLM-generated report validation is claimed. Hardware testing covers the earlier revision only; this follow-up changes the exporter bytes and has local CPU/mocked validation, not a fresh hardware capture. The pre-existing shared legacy-file race in parallel local mode remains unchanged; this fix protects the new qualified outputs. The PR changes two existing files: the ten-line production patch and its automated tests. No new source/test files or coverage-threshold changes are introduced.