Skip to content

[WIP - Do Not Merge] Prefer GPU and MPS over CPU for performance when available #331

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions export_aoti.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from torch.export import Dim

# CPU is always available and also exportable to ExecuTorch
default_device = "cpu" # 'cuda' if torch.cuda.is_available() else 'cpu'
# Prefer CUDA if available, otherwise MPS if available, otherwise CPU
default_device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.mps.is_available() else 'cpu'


def device_sync(device):
Expand Down
3 changes: 2 additions & 1 deletion torchchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
check_args,
)

default_device = "cpu"
# Prefer CUDA if available, otherwise MPS if available, otherwise CPU
default_device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.mps.is_available() else 'cpu'


if __name__ == "__main__":
Expand Down