Skip to content
Merged
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
5 changes: 4 additions & 1 deletion torchao/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,10 @@ def is_package_at_least(package_name: str, min_version: str):
def _is_fbgemm_gpu_genai_available():
# TODO: use is_package_at_least("fbgemm_gpu", "1.2.0") when
# https://github.com/pytorch/FBGEMM/issues/4198 is fixed
if importlib.util.find_spec("fbgemm_gpu") is None:
if (
importlib.util.find_spec("fbgemm_gpu") is None
or importlib.util.find_spec("fbgemm_gpu.experimental") is None
Copy link
Contributor

Choose a reason for hiding this comment

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

oh maybe just do importlib.util.find_spec(fbgemm_gpu.experimental.gen_ai) is None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to check fbgemm first, otherwise the following error will occur.

  File "/home/wengshiy/ao/torchao/quantization/quantize_/workflows/int4/int4_preshuffled_tensor.py", line 25, in <module>
    if not _is_fbgemm_gpu_genai_available():
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/wengshiy/ao/torchao/utils.py", line 1159, in _is_fbgemm_gpu_genai_available
    importlib.util.find_spec("fbgemm_gpu.experimental") is None
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib.util>", line 91, in find_spec
ModuleNotFoundError: No module named 'fbgemm_gpu'

):
return False

import fbgemm_gpu.experimental.gen_ai # noqa: F401
Expand Down
Loading