Skip to content
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
1 change: 1 addition & 0 deletions test/kernel/test_blockwise_triton.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_blockwise_fp8_gemm(M, N, K, dtype):
A_q, A_s = fp8_blockwise_act_quant(A, dtype=dtype)
B_q, B_s = fp8_blockwise_weight_quant(B, dtype=dtype)
C_q = blockwise_fp8_gemm(A_q, A_s, B_q, B_s)
assert C_q.dtype == torch.bfloat16, "unsupported"
error = torch.linalg.vector_norm(C - C_q) / torch.linalg.vector_norm(C)
print(f"Relative Error: {error.item():.6f}")

Expand Down
4 changes: 2 additions & 2 deletions torchao/kernel/blockwise_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def blockwise_fp8_gemm(
M = a.numel() // K
N = b.size(0)
M_BUCKET = math.ceil(math.log2(M))
c = a.new_empty(*a.size()[:-1], N, dtype=torch.get_default_dtype())
c = a.new_empty(*a.size()[:-1], N, dtype=torch.bfloat16)
grid = lambda META: (
triton.cdiv(M, META["BLOCK_SIZE_M"]),
triton.cdiv(N, META["BLOCK_SIZE_N"]),
Expand All @@ -105,7 +105,7 @@ def blockwise_fp8_gemm(
@blockwise_fp8_gemm.register_fake
def _(a, a_s, b, b_s, block_size=128):
N = b.size(0)
c = a.new_empty(*a.size()[:-1], N, dtype=torch.get_default_dtype())
c = a.new_empty(*a.size()[:-1], N, dtype=torch.bfloat16)
return c

@triton.jit
Expand Down
Loading