Skip to content
Merged
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
2 changes: 1 addition & 1 deletion benchmarks/float8/profile_lowp_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def cast_with_to_blocked(x_hp):
gemm_kernel_choice=config.gemm_kernel_choice,
)
m, k = x_hp.shape
scale_blocked = to_blocked(x_mx._scale_e8m0.reshape(m, k // config.block_size))
scale_blocked = to_blocked(x_mx.scale.reshape(m, k // config.block_size))
return x_mx._data, scale_blocked

# this function is used for cast_only_dim0_dim1
Expand Down
6 changes: 3 additions & 3 deletions torchao/prototype/moe_training/scaled_grouped_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def backward(ctx, grad_out: torch.Tensor):
scale_calculation_mode=ScaleCalculationMode.FLOOR,
)
grad_out_t_data = grad_out_t_mx.qdata
grad_out_t_scales = grad_out_t_mx._scale_e8m0
grad_out_t_scales = grad_out_t_mx.scale

# Transpose A so we can scale along the M dimension, then un-transpose.
# A shape: (M, K)
Expand All @@ -410,7 +410,7 @@ def backward(ctx, grad_out: torch.Tensor):
scale_calculation_mode=ScaleCalculationMode.FLOOR,
)
A_t_data = A_t_mx.qdata
A_t_scales = A_t_mx._scale_e8m0
A_t_scales = A_t_mx.scale

# Convert scales to blocked format for 2d-2d grouped mm
scale_group_offsets = offs // block_size
Expand Down Expand Up @@ -463,7 +463,7 @@ def _to_mxfp8_dim1_3d(
)
B_data = B_t_mx.qdata.t() # (K, E*N) -> (E*N, K)
B_data = B_data.reshape(E, N, K) # (E*N, K) -> (E, N, K)
B_scales = B_t_mx._scale_e8m0.view(torch.uint8) # (K, E*N//block_size)
B_scales = B_t_mx.scale.view(torch.uint8) # (K, E*N//block_size)
B_scales = B_scales.reshape(
K, E, N // block_size
) # (K, E*N//block_size) -> (K, E, N//block_size)
Expand Down
Loading