Skip to content
Closed
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
17 changes: 11 additions & 6 deletions recipes_source/torch_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@

import torch

# exit cleanly if we are on a device that doesn't support torch.compile
if torch.cuda.get_device_capability() < (7, 0):
print("Skipping because torch.compile is not supported on this device.")
else:
@torch.compile()
# Use torch.compile if supported, fallback to eager mode otherwise
try:
@torch.compile
def fn(x, y):
z = x + y
return z + 2

inputs = (torch.ones(2, 2, device="cuda"), torch.zeros(2, 2, device="cuda"))
except (RuntimeError, AssertionError):
print("⚠️ torch.compile is not supported on this system. Falling back to eager mode.")

def fn(x, y):
z = x + y
return z + 2

inputs = (torch.ones(2, 2, device="cuda"), torch.zeros(2, 2, device="cuda"))
inputs = (torch.ones(2, 2), torch.zeros(2, 2))


# print separator and reset dynamo
Expand Down
Loading