Skip to content

Add hardware check to fp8 quant #1314

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 6 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions torchao/quantization/quant_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from .utils import _get_per_token_block_size

logger = logging.getLogger(__name__)
is_cuda_8_9 = torch.cuda.is_available() and torch.cuda.get_device_capability() >= (8, 9)

__all__ = [
"swap_conv2d_1x1_to_linear",
Expand Down Expand Up @@ -939,6 +940,9 @@ def float8_dynamic_activation_float8_weight(
mm_config (Float8MMConfig): Configuration for the matrix multiplication. Default uses fast accumulation.

"""
assert (
is_cuda_8_9
), "Float8 dynamic activation quantization is only supported on CUDA 8.9 and above"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also be supported on AMD. We should probably update this check.

cc @jeffdaily

if mm_config is None:
mm_config = Float8MMConfig(use_fast_accum=True)

Expand Down Expand Up @@ -993,6 +997,9 @@ def float8_static_activation_float8_weight(
weight_dtype (torch.dtype): The target data type for weight quantization. Default is torch.float8_e4m
mm_config (Float8MMConfig): Configuration for the matrix multiplication. Default uses fast accumulation.
"""
assert (
is_cuda_8_9
), "Float8 static activation quantization is only supported on CUDA 8.9 and above"
if mm_config is None:
mm_config = Float8MMConfig(use_fast_accum=True)

Expand Down
Loading