Skip to content

unbreak float8 static quant tutorial #1709

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 44 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions torchao/dtypes/floatx/float8_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _linear_fp8_act_fp8_weight_impl(
):
"""Implements matmul between FP8 input and FP8 weight with compute using _scaled_mm"""
scaled_mm_config = weight_tensor._layout.mm_config
assert scaled_mm_config is not None
out_shape = get_out_shape(input_tensor.shape, weight_tensor.shape)

# Weight tensor preprocessing
Expand Down
3 changes: 2 additions & 1 deletion tutorials/calibration_flow/static_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,13 @@ def __init__(
weight, weight_scale, weight_zero_point, block_size, self.target_dtype
)
elif self.target_dtype == torch.float8_e4m3fn:
mm_config = Float8MMConfig(use_fast_accum=True)
self.qweight = to_affine_quantized_floatx_static(
weight,
weight_scale,
block_size,
target_dtype,
Float8Layout(mm_config=None),
Float8Layout(mm_config=mm_config),
)
else:
raise ValueError(f"Unsupported target dtype {self.target_dtype}")
Expand Down
Loading