Skip to content

Commit f0ae23d

Browse files
support quantize fp32 embedding tables (#2794)
Summary: Pull Request resolved: #2794 Reviewed By: aporialiao Differential Revision: D71762539 Pulled By: iamzainhuda fbshipit-source-id: d468abc22b96bc40befaf0a8975bf5c06a0b6c41
1 parent 7652c5d commit f0ae23d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torchrec/quant/embedding_modules.py

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ def quantize_state_dict(
252252
if tensor.dtype == torch.float:
253253
tensor = tensor.half()
254254
quant_res = tensor.view(torch.uint8)
255+
elif data_type == DataType.FP32:
256+
if tensor.dtype == torch.float16:
257+
tensor = tensor.float()
258+
quant_res = tensor.view(torch.uint8)
255259
else:
256260
quant_res = (
257261
torch.ops.fbgemm.FloatOrHalfToFusedNBitRowwiseQuantizedSBHalf(

0 commit comments

Comments
 (0)