Skip to content
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

Matmul Python Benchmarks #2088

Merged
merged 6 commits into from
Apr 19, 2024
Merged

Matmul Python Benchmarks #2088

merged 6 commits into from
Apr 19, 2024

Conversation

Priya2698
Copy link
Collaborator

@Priya2698 Priya2698 commented Apr 17, 2024

Fixes #2082


def matmul_fusion(fd: FusionDefinition, dtype: DataType) -> None:
# Decide contiguity based on layout
a = fd.define_tensor(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should pass a and b here instead as torch.Tensors then use fd.from_pytorch to define these. The reason is that this definition as stated will not adapt to different layouts, but we will get the right stride order for the operands from fd.from_pytorch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That of course assumes we have #2058 fixed first. until then we probably need to pass in the layout or better yet bools indicating whether we need to transpose each operand first. For transposed operands we should allocate them like for example randn(k, m) instead of randn(m, k).

Copy link
Collaborator Author

@Priya2698 Priya2698 Apr 17, 2024

Choose a reason for hiding this comment

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

So, fd.from_pytorch, should be able to allocate the inputs correctly, right?
But fd.define_tensor with the contiguity flags will not work.

benchmarks/python/test_matmul.py Outdated Show resolved Hide resolved
benchmarks/python/test_matmul.py Show resolved Hide resolved
benchmarks/python/test_matmul.py Outdated Show resolved Hide resolved
@Priya2698 Priya2698 marked this pull request as ready for review April 17, 2024 19:24
@Priya2698
Copy link
Collaborator Author

Priya2698 commented Apr 17, 2024

For future, we should probably have a separate benchmark for baselines (eager / torchcompile).
While we run through ATen right now, those will be required later. Wdyt? @jacobhinkle. I can add them to this PR.

@jacobhinkle
Copy link
Collaborator

Maybe we should do that in another PR since the current one is enough to benchmark aten vs nvfuser using env vars.

@Priya2698
Copy link
Collaborator Author

@jacobhinkle Should we merge this PR?

Copy link
Collaborator

@jacobhinkle jacobhinkle left a comment

Choose a reason for hiding this comment

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

Full speed ahead! Thanks for the changes.

@Priya2698 Priya2698 merged commit 5be8b33 into main Apr 19, 2024
4 checks passed
@Priya2698 Priya2698 deleted the pm/benchmark_matmul branch April 19, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Python Benchmarks for Matmuls
2 participants