-
Notifications
You must be signed in to change notification settings - Fork 275
Enable Intel GPU #753
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
Enable Intel GPU #753
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
def device_sync(device): | ||
if "cuda" in device: | ||
torch.cuda.synchronize(device) | ||
elif "xpu" in device: | ||
torch.xpu.synchronize(device) | ||
elif ("cpu" in device) or ("mps" in device): | ||
pass | ||
else: | ||
|
@@ -288,7 +290,10 @@ def main( | |
|
||
for i in range(start, num_samples): | ||
if i==0: | ||
torch.cuda.reset_peak_memory_stats() | ||
if "cuda" in device: | ||
torch.cuda.reset_peak_memory_stats() | ||
elif "xpu" in device: | ||
torch.xpu.reset_peak_memory_stats() | ||
device_sync(device=device) # MKG | ||
if i >= 0 and interactive: | ||
prompt = input("What is your prompt? ") | ||
|
@@ -318,8 +323,15 @@ def callback(x): | |
if (i != num_samples - 1 or not profile): | ||
prof = contextlib.nullcontext() | ||
else: | ||
torch.profiler._utils._init_for_cuda_graphs() | ||
prof = torch.profiler.profile() | ||
if "cuda" in device: | ||
Comment on lines
325
to
+326
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please dismantle the pyramid of doom and use |
||
torch.profiler._utils._init_for_cuda_graphs() | ||
prof = torch.profiler.profile() | ||
elif "xpu" in device: | ||
prof = torch.profiler.profile( | ||
activities=[ | ||
torch.profiler.ProfilerActivity.CPU, | ||
torch.profiler.ProfilerActivity.XPU], | ||
) | ||
with prof: | ||
y = generate( | ||
model, | ||
|
@@ -369,7 +381,8 @@ def callback(x): | |
|
||
tokpersec = torch.mean(torch.tensor(aggregate_metrics['tokens_per_sec'])).item() | ||
bandwidth = model_size * tokpersec | ||
mem = torch.cuda.max_memory_reserved() /1e9 | ||
max_memory_reserved = torch.cuda.max_memory_reserved() if "cuda" in device else torch.xpu.max_memory_reserved() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels wrong, as it will dispatch to |
||
mem = max_memory_reserved / 1e9 | ||
print(f"Average tokens/sec: {tokpersec:.2f}") | ||
print(f"Average Bandwidth: {bandwidth:.02f} GB/s") | ||
print(f"Peak Memory Usage: {mem:.02f} GB") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below, can you please check that
torch.cuda.reset_peak_memory_stats
does not need to be applied to hip