-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(profiling): add support for pytorch profiling (#9154)
PR does - Patches `torch.profiler.profile` class by adding our own `on_trace_ready` handler - Adds GPU time/flops/memory samples via libdatadog interface in `on_trace_ready` event handler - Ensures that libdd exporter is enabled if pytorch is enabled - Hides functionality behind a FF set to False by default - changelog entry - Is there a minimum python version? - the biggest requirement is that the current pytorch profiler API which we instrument was introduced in torch version 1.8.1 (https://pytorch.org/blog/introducing-pytorch-profiler-the-new-and-improved-performance-tool/), do we just want to document or we could disable the instrumentation if we detect an outdated version with `torch.__version__` - Some documentation on needed user configuration, conflicting features, gotchas ~~Probably should make experimental/beta collectors not part of the ALL template (Is this blocking since we haven't done in the past??)~~ ## Testing Done - Tested by running on ec2 GPU instance - Tested by running `prof-pytorch` service in staging - I'm not entirely sure if we need unit tests for this feature, or where they would live. Would we want the unit test suite to depend on torch? Maybe this is solved for tracing integrations, though ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --------- Co-authored-by: sanchda <[email protected]> Co-authored-by: Peter Griggs <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]> Co-authored-by: Emmett Butler <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]> Co-authored-by: Taegyun Kim <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
- Loading branch information
1 parent
1dd528c
commit 00ec1f7
Showing
20 changed files
with
770 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
name: Pytorch Unit Tests (with GPU) | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'mq-working-branch**' | ||
paths: | ||
- 'ddtrace/profiling/collector/pytorch.py' | ||
pull_request: | ||
paths: | ||
- 'ddtrace/profiling/collector/pytorch.py' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: APM-4-CORE-GPU-LINUX | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Include all history and tags | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v5 | ||
name: Install Python | ||
with: | ||
python-version: '3.12' | ||
|
||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- name: Install latest stable toolchain and rustfmt | ||
run: rustup update stable && rustup default stable && rustup component add rustfmt clippy | ||
|
||
- name: Install hatch | ||
uses: pypa/hatch@install | ||
with: | ||
version: "1.12.0" | ||
|
||
- name: Install PyTorch | ||
run: pip install torch | ||
|
||
- name: Run tests | ||
run: hatch run profiling_pytorch:test |
This file contains 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 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 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 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 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 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 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 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 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.