Revert "[cutlass backend] re-add pip cutlass path (#160180)"

This reverts commit d556586448.

Reverted https://github.com/pytorch/pytorch/pull/160180 on behalf of https://github.com/atalman due to broke macos nightly ([comment](https://github.com/pytorch/pytorch/pull/160180#issuecomment-3192311552))
This commit is contained in:
PyTorch MergeBot 2025-08-15 18:00:41 +00:00
parent 8780d28c65
commit 30d2f98daa
2 changed files with 6 additions and 44 deletions

View File

@ -3546,15 +3546,13 @@ def _cuda_compiler() -> Optional[str]:
return "nvcc"
def _cutlass_path() -> Optional[str]:
def _cutlass_path() -> str:
if config.is_fbcode():
from libfb.py import parutil
return parutil.get_dir_path("cutlass-4-headers")
else:
from torch._inductor.codegen.cuda.cutlass_utils import try_import_cutlass
return config.cuda.cutlass_dir if try_import_cutlass() else None
return config.cuda.cutlass_dir
def _cutlass_paths() -> list[str]:
@ -3569,8 +3567,6 @@ def _cutlass_paths() -> list[str]:
def _clone_cutlass_paths(build_root: str) -> list[str]:
paths = _cutlass_paths()
cutlass_root = _cutlass_path()
if cutlass_root is None:
return []
for path in _cutlass_paths():
old_path = os.path.join(cutlass_root, path)
new_path = os.path.join(build_root, path)
@ -3579,12 +3575,10 @@ def _clone_cutlass_paths(build_root: str) -> list[str]:
def _cutlass_include_paths() -> list[str]:
cutlass_root = _cutlass_path()
if cutlass_root is None:
return []
cutlass_path = _cutlass_path()
return [
# Use realpath to get canonical absolute paths, in order not to mess up cache keys
os.path.realpath(os.path.join(cutlass_root, path))
os.path.realpath(os.path.join(cutlass_path, path))
for path in _cutlass_paths()
]

View File

@ -1,7 +1,6 @@
# mypy: allow-untyped-defs
import atexit
import functools
import importlib.metadata
import logging
import os
import shutil
@ -12,7 +11,6 @@ from pathlib import Path
from typing import Any, Optional
import sympy
from packaging.version import Version
import torch
from torch._inductor.runtime.runtime_utils import dynamo_timed
@ -75,9 +73,7 @@ def try_import_cutlass() -> bool:
"""
We want to support three ways of passing in CUTLASS:
1. fbcode, handled by the internal build system.
2. pip install nvidia-cutlass, which provides the cutlass_library package
and the header files in the cutlass_library/source directory.
3. User specifies cutlass_dir. The default is ../third_party/cutlass/,
2. User specifies cutlass_dir. The default is ../third_party/cutlass/,
which is the directory when developers build from source.
"""
if config.is_fbcode():
@ -93,34 +89,6 @@ def try_import_cutlass() -> bool:
return True
try:
cutlass_version = Version(importlib.metadata.version("cutlass"))
if cutlass_version < Version("3.7"):
log.warning("CUTLASS version < 3.7 is not recommended.")
import cutlass_library # type: ignore[import-not-found] # noqa: F811
log.debug(
"Found cutlass_library in python search path, overriding config.cuda.cutlass_dir"
)
cutlass_library_dir = os.path.dirname(cutlass_library.__file__)
assert os.path.isdir(cutlass_library_dir), (
f"{cutlass_library_dir} is not a directory"
)
config.cuda.cutlass_dir = os.path.abspath(
os.path.join(
cutlass_library_dir,
"source",
)
)
return True
except (ModuleNotFoundError, importlib.metadata.PackageNotFoundError):
log.debug(
"cutlass_library not found in sys.path, trying to import from config.cuda.cutlass_dir",
exc_info=True,
)
# Copy CUTLASS python scripts to a temp dir and add the temp dir to Python search path.
# This is a temporary hack to avoid CUTLASS module naming conflicts.
# TODO(ipiszy): remove this hack when CUTLASS solves Python scripts packaging structure issues.
@ -188,7 +156,7 @@ def try_import_cutlass() -> bool:
)
try:
import cutlass # noqa: F401
import cutlass # noqa: F401, F811
import cutlass_library.generator # noqa: F401
import cutlass_library.library # noqa: F401
import cutlass_library.manifest # noqa: F401