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

Switch dynamic FP8 grouped gemm to accept tensor inputs #3552

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
103 changes: 0 additions & 103 deletions fbgemm_gpu/experimental/gen_ai/bench/profile_grouped_gemm.py

This file was deleted.

9 changes: 1 addition & 8 deletions fbgemm_gpu/experimental/gen_ai/bench/quantize_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
"""

def quantize_fixed_nk(self, x, w):
group_size = len(x)

Check failure on line 472 in fbgemm_gpu/experimental/gen_ai/bench/quantize_ops.py

View workflow job for this annotation

GitHub Actions / run-lint (3.13)

F841 local variable 'group_size' is assigned to but never used
m_values = [i.shape[0] for i in x]
# Inputs for fixed nk mode must be contiguous, however in the benchmark
# script they typically are not. Do a little special processing to make them
Expand All @@ -486,11 +486,6 @@
# Apply quantization.
xq, x_scale = quantize_fp8_row(xq)
wq, w_scale = quantize_fp8_row(wq)
# View these unified tensors as lists of tensors.
xq = [x.squeeze() for x in xq.split(1, dim=0)]
wq = [w.squeeze() for w in wq.split(1, dim=0)]
x_scale = [xs.squeeze() for xs in x_scale.view(group_size, -1).split(1, dim=0)]
w_scale = [ws.squeeze() for ws in w_scale.view(group_size, -1).split(1, dim=0)]

# Return processed tensors.
return (
Expand Down Expand Up @@ -520,14 +515,13 @@
m_values = None
return xq, wq, x_scale, w_scale, m_values

def compute(self, xq, wq, x_scale, w_scale, m_values, kernel_name=None):
def compute(self, xq, wq, x_scale, w_scale, m_values):
if m_values is None:
return torch.ops.fbgemm.f8f8bf16_rowwise_grouped(
xq,
wq,
x_scale,
w_scale,
kernel_name=kernel_name,
)
else:
return torch.ops.fbgemm.f8f8bf16_rowwise_grouped_dynamic(
Expand All @@ -536,7 +530,6 @@
x_scale,
w_scale,
zero_start_index_M=m_values,
kernel_name=kernel_name,
)

def quantize_and_compute(self, x, w):
Expand Down
Loading
Loading