Skip to content

Commit 6501fb8

Browse files
shiyang-wengpytorchmergebot
authored andcommitted
[CPU] Fix issue: No module named 'fbgemm_gpu.experimental' (#2591)
Fix the following issue ``` File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/transformers/modeling_utils.py", line 50, in <module> from torchao.quantization import Int4WeightOnlyConfig File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/torchao-0.13.0+git38de0e9-py3.10.egg/torchao/__init__.py", line 43, in <module> from torchao.quantization import ( File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/torchao-0.13.0+git38de0e9-py3.10.egg/torchao/quantization/__init__.py", line 44, in <module> from .quant_api import ( File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/torchao-0.13.0+git38de0e9-py3.10.egg/torchao/quantization/quant_api.py", line 70, in <module> from torchao.quantization.quantize_.workflows import ( File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/torchao-0.13.0+git38de0e9-py3.10.egg/torchao/quantization/quantize_/workflows/__init__.py", line 1, in <module> from .int4.int4_preshuffled_tensor import ( File "/opt/conda/envs/pytorch/lib/python3.10/site-packages/torchao-0.13.0+git38de0e9-py3.10.egg/torchao/quantization/quantize_/workflows/int4/int4_preshuffled_tensor.py", line 31, in <module> from fbgemm_gpu.experimental.gen_ai.quantize import ( ModuleNotFoundError: No module named 'fbgemm_gpu.experimental' ``` We want to use torchrec on CPU. On CPU, torchrec dependent on the CPU version of fbgemm_gpu. On CPU, fbgemm_gpu not include fbgemm_gpu.experimental. ``` >>> import fbgemm_gpu >>> fbgemm_gpu.experimental Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'fbgemm_gpu' has no attribute 'experimental' ``` env: `pip install fbgemm-gpu --index-url https://download.pytorch.org/whl/cpu` Reproduce: `from torchao.quantization import Int4WeightOnlyConfig` Pull Request resolved: #2591 Approved by: https://github.com/Xia-Weiwen
1 parent 376d6d2 commit 6501fb8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

torchao/quantization/quantize_/workflows/int4/int4_preshuffled_tensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
aten = torch.ops.aten
2525

2626

27-
if importlib.util.find_spec("fbgemm_gpu") is None:
27+
if (
28+
importlib.util.find_spec("fbgemm_gpu") is None
29+
or importlib.util.find_spec("fbgemm_gpu.experimental") is None
30+
):
2831
quantize_int4_preshuffle = None
2932
quantize_fp8_row = None
3033
else:

0 commit comments

Comments
 (0)