Skip to content

[CPU] Fix issue: No module named 'fbgemm_gpu.experimental' #2591

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

Closed
wants to merge 2 commits into from

Conversation

shiyang-weng
Copy link
Contributor

@shiyang-weng shiyang-weng commented Jul 24, 2025

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

Copy link

pytorch-bot bot commented Jul 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2591

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 916abda with merge base 12ff479 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 24, 2025
@shiyang-weng shiyang-weng marked this pull request as draft July 24, 2025 02:27
@shiyang-weng shiyang-weng marked this pull request as ready for review July 24, 2025 02:35
if (
importlib.util.find_spec("fbgemm_gpu") is None
or importlib.util.find_spec("fbgemm_gpu.experimental") is None
):
quantize_int4_preshuffle = None
Copy link

Choose a reason for hiding this comment

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

Is there any test for this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hard to test. If want to test this case, need to install the CPU version of fbgemm on ci envs.

@shiyang-weng
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Jul 24, 2025
@shiyang-weng
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged topic: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants