Skip to content

feat: Safety Mode for Runtime #2512

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
merged 4 commits into from
Dec 8, 2023
Merged

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Dec 4, 2023

Description

  • Add safety mode for Torch-TensorRT runtime
  • Add C++ TorchBind bindings and relevant lambda functions to get and set necessary attributes
  • Add runtime augmentations to support different modes
  • Add Python-runtime device checks
  • Add testing for safe mode settings

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [ x ] My code follows the style guidelines of this project (You can use the linters)
  • [ x ] I have performed a self-review of my own code
  • [ x ] I have commented my code, particularly in hard-to-understand areas and hacks
  • [ x ] I have made corresponding changes to the documentation
  • [ x ] I have added tests to verify my fix or my feature
  • [ x ] New and existing unit tests pass locally with my changes
  • [ x ] I have added the relevant labels to my PR in so that relevant reviewers are notified

@gs-olive gs-olive self-assigned this Dec 4, 2023
@github-actions github-actions bot added component: api [Python] Issues re: Python API component: core Issues re: The core compiler component: runtime component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Dec 4, 2023
@gs-olive gs-olive force-pushed the runtime_safety branch 3 times, most recently from 09b01e0 to cc32a3c Compare December 6, 2023 06:37
Copy link
Collaborator Author

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doc. to PR in runtime, which is linked to by the warning message.
"""
Detected run on multi-gpu system. Safety Doc w/threadpool mention
--> Perf implications of unsafe mode
"""

@github-actions github-actions bot added the component: build system Issues re: Build system label Dec 7, 2023
@gs-olive gs-olive force-pushed the runtime_safety branch 2 times, most recently from 45675d6 to 518e0a6 Compare December 7, 2023 01:43
- Add safety mode for Torch-TensorRT runtime
- Add C++ TorchBind bindings and relevant lambda functions to get and
set necessary attributes
- Add runtime augmentations to support different modes
- Add testing for safe mode settings
- Add support for device checks in the Python Runtime, to mirror those
in the C++ runtime
- Fix various issues in partitioning and runtime accordingly
@@ -31,13 +33,13 @@ c10::optional<RTDevice> get_most_compatible_device(const RTDevice& target_device
if (device.device_name == target_device.device_name) {
// First priority is selecting a candidate which agrees with the current device ID
// If such a device is found, we can select it and break out of the loop
if (device.id == current_device.id && best_match.id != current_device.id) {
if (device.id == current_device.id) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing these?

Copy link
Collaborator Author

@gs-olive gs-olive Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During review, it was determined that these are not actually necessary conditions. Since the ID of each device is unique on a given machine, it should not be possible that best_match.id == current_device.id at this point in the code, so the check is not needed here.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 7, 2023
@gs-olive gs-olive requested a review from narendasan December 7, 2023 20:01
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor things that shouldnt require additional review

@gs-olive gs-olive merged commit aad7d06 into pytorch:main Dec 8, 2023
@gs-olive gs-olive deleted the runtime_safety branch December 8, 2023 00:18
gs-olive added a commit that referenced this pull request Dec 8, 2023
gs-olive added a commit that referenced this pull request Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: build system Issues re: Build system component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: runtime component: tests Issues re: Tests documentation Improvements or additions to documentation priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants