Skip to content

mx roofline: adjust mxfp8 formulas #1953

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

Merged
merged 23 commits into from
Mar 27, 2025
29 changes: 9 additions & 20 deletions torchao/testing/float8/roofline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,16 @@ def get_tensor_memory_traffic_ovhd_s(
"mxfp8_cutlass",
"mxfp8_cublas",
), "unsupported"

if tensor_role == "weight":
# x_bf16 = ...
# kernel 1: x_bf16 -> x_mxfp8_dim0
# kernel 2: x_bf16 -> x_mxfp8_dim1
if fuse_with_prev:
kernel_1_rw = 0 + BYTES_PER_EL_FLOAT8 * numel
else:
kernel_1_rw = BYTES_PER_EL_BF16 * numel + BYTES_PER_EL_FLOAT8 * numel
kernel_2_rw = BYTES_PER_EL_BF16 * numel + BYTES_PER_EL_FLOAT8 * numel
res_bytes = [kernel_1_rw, kernel_2_rw]
# For now, assume that we can't profitably fuse kernel 1 and kernel 2
# x_bf16 = ...
# kernel 1: x_bf16 -> x_mxfp8_dim0
# kernel 2: x_bf16 -> x_mxfp8_dim1
if fuse_with_prev:
kernel_1_rw = 0 + BYTES_PER_EL_FLOAT8 * numel
else:
# x_bf16 = ...
# kernel 1: x_bf16 -> x_mxfp8_dim0, x_mxfp8_dim1
if fuse_with_prev:
kernel_1_rw = 0 + BYTES_PER_EL_FLOAT8 * numel * 2
else:
kernel_1_rw = (
BYTES_PER_EL_BF16 * numel + BYTES_PER_EL_FLOAT8 * numel * 2
)
res_bytes = [kernel_1_rw]
kernel_1_rw = BYTES_PER_EL_BF16 * numel + BYTES_PER_EL_FLOAT8 * numel
kernel_2_rw = BYTES_PER_EL_BF16 * numel + BYTES_PER_EL_FLOAT8 * numel
res_bytes = [kernel_1_rw, kernel_2_rw]

# convert from bytes to seconds
res_s = [
Expand Down
Loading