Upload 12 files
Browse files- .gitattributes +6 -0
- wheel/python3.12/torch2.8.0/SpargeAttn/setup.py +232 -0
- wheel/python3.12/torch2.8.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/SageAttention/sageattention-2.2.0-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/SpargeAttn/setup.py +232 -0
- wheel/python3.12/torch2.9.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.7.4-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.8.2-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/long-context-attention/yunchang-0.6.4-py3-none-any.whl +0 -0
- wheel/python3.12/torch2.9.0/nunchaku/nunchaku-1.3.0.dev20260304+cu13.0torch2.9-cp312-cp312-linux_x86_64.whl +3 -0
- wheel/python3.12/torch2.9.0/nunchaku/third_party/cutlass/include/cutlass/matrix.h +0 -0
- wheel/python3.12/torch2.9.0/xdit-comfyui-private/xdit_comfyui_private-0.0.1-py3-none-any.whl +0 -0
- wheel/python3.12/torch2.9.0/xdit-comfyui-private/先装ray和long-context-attention +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
wheel/python3.12/torch2.8.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.7.4-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.8.2-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
wheel/python3.12/torch2.9.0/nunchaku/nunchaku-1.3.0.dev20260304+cu13.0torch2.9-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
wheel/python3.12/torch2.9.0/SageAttention/sageattention-2.2.0-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
wheel/python3.12/torch2.9.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
wheel/python3.12/torch2.8.0/SpargeAttn/setup.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Copyright (c) 2025 by SpargeAttn team.
|
| 3 |
+
|
| 4 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
you may not use this file except in compliance with the License.
|
| 6 |
+
You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
See the License for the specific language governing permissions and
|
| 14 |
+
limitations under the License.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
import subprocess
|
| 20 |
+
from packaging.version import parse, Version
|
| 21 |
+
from typing import List, Set
|
| 22 |
+
import warnings
|
| 23 |
+
|
| 24 |
+
from setuptools import setup, find_packages
|
| 25 |
+
import torch
|
| 26 |
+
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME
|
| 27 |
+
|
| 28 |
+
HAS_SM90 = False
|
| 29 |
+
SAGE2PP_ENABLED = True
|
| 30 |
+
|
| 31 |
+
def run_instantiations(src_dir: str):
|
| 32 |
+
base_path = Path(src_dir)
|
| 33 |
+
py_files = [
|
| 34 |
+
path for path in base_path.rglob('*.py')
|
| 35 |
+
if path.is_file()
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
for py_file in py_files:
|
| 39 |
+
print(f"Running: {py_file}")
|
| 40 |
+
os.system(f"python {py_file}")
|
| 41 |
+
|
| 42 |
+
def get_instantiations(src_dir: str):
|
| 43 |
+
# get all .cu files under src_dir
|
| 44 |
+
base_path = Path(src_dir)
|
| 45 |
+
return [
|
| 46 |
+
os.path.join(src_dir, str(path.relative_to(base_path)))
|
| 47 |
+
for path in base_path.rglob('*')
|
| 48 |
+
if path.is_file() and path.suffix == ".cu"
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# Supported NVIDIA GPU architectures.
|
| 52 |
+
SUPPORTED_ARCHS = {"8.0", "8.6", "8.7", "8.9", "9.0"}
|
| 53 |
+
|
| 54 |
+
# Compiler flags.
|
| 55 |
+
CXX_FLAGS = ["-g", "-O3", "-fopenmp", "-lgomp", "-std=c++17", "-DENABLE_BF16"]
|
| 56 |
+
NVCC_FLAGS = [
|
| 57 |
+
"-O3",
|
| 58 |
+
"-std=c++17",
|
| 59 |
+
"-U__CUDA_NO_HALF_OPERATORS__",
|
| 60 |
+
"-U__CUDA_NO_HALF_CONVERSIONS__",
|
| 61 |
+
"--use_fast_math",
|
| 62 |
+
"--threads=8",
|
| 63 |
+
"-Xptxas=-v",
|
| 64 |
+
"-diag-suppress=174", # suppress the specific warning
|
| 65 |
+
# "-Xcompiler", "-include,cassert", # fix error occurs when compiling for SM90+ with newer CUDA toolkits RTX 40 系列是 SM89可以安全移除该选项
|
| 66 |
+
]
|
| 67 |
+
|
| 68 |
+
ABI = 1 if torch._C._GLIBCXX_USE_CXX11_ABI else 0
|
| 69 |
+
CXX_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
|
| 70 |
+
NVCC_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
|
| 71 |
+
|
| 72 |
+
if CUDA_HOME is None:
|
| 73 |
+
raise RuntimeError(
|
| 74 |
+
"Cannot find CUDA_HOME. CUDA must be available to build the package.")
|
| 75 |
+
|
| 76 |
+
def get_nvcc_cuda_version(cuda_dir: str) -> Version:
|
| 77 |
+
"""Get the CUDA version from nvcc.
|
| 78 |
+
|
| 79 |
+
Adapted from https://github.com/NVIDIA/apex/blob/8b7a1ff183741dd8f9b87e7bafd04cfde99cea28/setup.py
|
| 80 |
+
"""
|
| 81 |
+
nvcc_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"],
|
| 82 |
+
universal_newlines=True)
|
| 83 |
+
output = nvcc_output.split()
|
| 84 |
+
release_idx = output.index("release") + 1
|
| 85 |
+
nvcc_cuda_version = parse(output[release_idx].split(",")[0])
|
| 86 |
+
return nvcc_cuda_version
|
| 87 |
+
|
| 88 |
+
def get_torch_arch_list() -> Set[str]:
|
| 89 |
+
# TORCH_CUDA_ARCH_LIST can have one or more architectures,
|
| 90 |
+
# e.g. "8.0" or "7.5,8.0,8.6+PTX". Here, the "8.6+PTX" option asks the
|
| 91 |
+
# compiler to additionally include PTX code that can be runtime-compiled
|
| 92 |
+
# and executed on the 8.6 or newer architectures. While the PTX code will
|
| 93 |
+
# not give the best performance on the newer architectures, it provides
|
| 94 |
+
# forward compatibility.
|
| 95 |
+
env_arch_list = os.environ.get("TORCH_CUDA_ARCH_LIST", None)
|
| 96 |
+
if env_arch_list is None:
|
| 97 |
+
return set()
|
| 98 |
+
|
| 99 |
+
# List are separated by ; or space.
|
| 100 |
+
torch_arch_list = set(env_arch_list.replace(" ", ";").split(";"))
|
| 101 |
+
if not torch_arch_list:
|
| 102 |
+
return set()
|
| 103 |
+
|
| 104 |
+
# Filter out the invalid architectures and print a warning.
|
| 105 |
+
valid_archs = SUPPORTED_ARCHS.union({s + "+PTX" for s in SUPPORTED_ARCHS})
|
| 106 |
+
arch_list = torch_arch_list.intersection(valid_archs)
|
| 107 |
+
# If none of the specified architectures are valid, raise an error.
|
| 108 |
+
if not arch_list:
|
| 109 |
+
raise RuntimeError(
|
| 110 |
+
"None of the CUDA architectures in `TORCH_CUDA_ARCH_LIST` env "
|
| 111 |
+
f"variable ({env_arch_list}) is supported. "
|
| 112 |
+
f"Supported CUDA architectures are: {valid_archs}.")
|
| 113 |
+
invalid_arch_list = torch_arch_list - valid_archs
|
| 114 |
+
if invalid_arch_list:
|
| 115 |
+
warnings.warn(
|
| 116 |
+
f"Unsupported CUDA architectures ({invalid_arch_list}) are "
|
| 117 |
+
"excluded from the `TORCH_CUDA_ARCH_LIST` env variable "
|
| 118 |
+
f"({env_arch_list}). Supported CUDA architectures are: "
|
| 119 |
+
f"{valid_archs}.")
|
| 120 |
+
return arch_list
|
| 121 |
+
|
| 122 |
+
# First, check the TORCH_CUDA_ARCH_LIST environment variable.
|
| 123 |
+
compute_capabilities = get_torch_arch_list()
|
| 124 |
+
if not compute_capabilities:
|
| 125 |
+
# If TORCH_CUDA_ARCH_LIST is not defined or empty, target all available
|
| 126 |
+
# GPUs on the current machine.
|
| 127 |
+
device_count = torch.cuda.device_count()
|
| 128 |
+
for i in range(device_count):
|
| 129 |
+
major, minor = torch.cuda.get_device_capability(i)
|
| 130 |
+
if major < 8:
|
| 131 |
+
raise RuntimeError(
|
| 132 |
+
"GPUs with compute capability below 8.0 are not supported.")
|
| 133 |
+
compute_capabilities.add(f"{major}.{minor}")
|
| 134 |
+
|
| 135 |
+
nvcc_cuda_version = get_nvcc_cuda_version(CUDA_HOME)
|
| 136 |
+
if not compute_capabilities:
|
| 137 |
+
raise RuntimeError("No GPUs found. Please specify the target GPU architectures or build on a machine with GPUs.")
|
| 138 |
+
|
| 139 |
+
# Validate the NVCC CUDA version.
|
| 140 |
+
if nvcc_cuda_version < Version("12.0"):
|
| 141 |
+
raise RuntimeError("CUDA 12.0 or higher is required to build the package.")
|
| 142 |
+
if nvcc_cuda_version < Version("12.4"):
|
| 143 |
+
if any(cc.startswith("8.9") for cc in compute_capabilities):
|
| 144 |
+
raise RuntimeError(
|
| 145 |
+
"CUDA 12.4 or higher is required for compute capability 8.9.")
|
| 146 |
+
if any(cc.startswith("9.0") for cc in compute_capabilities):
|
| 147 |
+
raise RuntimeError(
|
| 148 |
+
"CUDA 12.4 or higher is required for compute capability 9.0.")
|
| 149 |
+
if nvcc_cuda_version < Version("12.8"):
|
| 150 |
+
warnings.warn("CUDA 12.8 or higher is required for Sage2++")
|
| 151 |
+
SAGE2PP_ENABLED = False
|
| 152 |
+
|
| 153 |
+
# Add target compute capabilities to NVCC flags.
|
| 154 |
+
for capability in compute_capabilities:
|
| 155 |
+
num = capability.replace(".", "")
|
| 156 |
+
if num == '90':
|
| 157 |
+
num = '90a'
|
| 158 |
+
HAS_SM90 = True
|
| 159 |
+
CXX_FLAGS += ["-DHAS_SM90"]
|
| 160 |
+
if num == '80' or num == '86' or num == '87':
|
| 161 |
+
SAGE2PP_ENABLED = False
|
| 162 |
+
|
| 163 |
+
NVCC_FLAGS += ["-gencode", f"arch=compute_{num},code=sm_{num}"]
|
| 164 |
+
if capability.endswith("+PTX"):
|
| 165 |
+
NVCC_FLAGS += ["-gencode", f"arch=compute_{num},code=compute_{num}"]
|
| 166 |
+
|
| 167 |
+
if SAGE2PP_ENABLED:
|
| 168 |
+
CXX_FLAGS += ["-DSAGE2PP_ENABLED"]
|
| 169 |
+
|
| 170 |
+
ext_modules = []
|
| 171 |
+
|
| 172 |
+
run_instantiations("csrc/qattn/instantiations_sm80")
|
| 173 |
+
run_instantiations("csrc/qattn/instantiations_sm89")
|
| 174 |
+
run_instantiations("csrc/qattn/instantiations_sm90")
|
| 175 |
+
|
| 176 |
+
sources = [
|
| 177 |
+
"csrc/qattn/pybind.cpp",
|
| 178 |
+
"csrc/qattn/qk_int_sv_f16_cuda_sm80.cu",
|
| 179 |
+
"csrc/qattn/qk_int_sv_f8_cuda_sm89.cu",
|
| 180 |
+
] + get_instantiations("csrc/qattn/instantiations_sm80") + get_instantiations("csrc/qattn/instantiations_sm89")
|
| 181 |
+
|
| 182 |
+
if HAS_SM90:
|
| 183 |
+
sources += ["csrc/qattn/qk_int_sv_f8_cuda_sm90.cu", ]
|
| 184 |
+
sources += get_instantiations("csrc/qattn/instantiations_sm90")
|
| 185 |
+
|
| 186 |
+
qattn_extension = CUDAExtension(
|
| 187 |
+
name="spas_sage_attn._qattn",
|
| 188 |
+
sources=sources,
|
| 189 |
+
extra_compile_args={
|
| 190 |
+
"cxx": CXX_FLAGS,
|
| 191 |
+
"nvcc": NVCC_FLAGS,
|
| 192 |
+
},
|
| 193 |
+
extra_link_args=['-lcuda'],
|
| 194 |
+
)
|
| 195 |
+
ext_modules.append(qattn_extension)
|
| 196 |
+
|
| 197 |
+
fused_extension = CUDAExtension(
|
| 198 |
+
name="spas_sage_attn._fused",
|
| 199 |
+
sources=["csrc/fused/pybind.cpp", "csrc/fused/fused.cu"],
|
| 200 |
+
extra_compile_args={
|
| 201 |
+
"cxx": CXX_FLAGS,
|
| 202 |
+
"nvcc": NVCC_FLAGS,
|
| 203 |
+
},
|
| 204 |
+
)
|
| 205 |
+
ext_modules.append(fused_extension)
|
| 206 |
+
|
| 207 |
+
setup(
|
| 208 |
+
name='spas_sage_attn',
|
| 209 |
+
version='0.1.0',
|
| 210 |
+
author='Jintao Zhang, Chendong Xiang, Haofeng Huang',
|
| 211 |
+
author_email='jt-zhang6@gmail.com',
|
| 212 |
+
packages=find_packages(),
|
| 213 |
+
description='Accurate and efficient Sparse SageAttention.',
|
| 214 |
+
long_description=open('README.md', encoding='utf-8').read(),
|
| 215 |
+
long_description_content_type='text/markdown',
|
| 216 |
+
url='https://github.com/thu-ml/SpargeAttn',
|
| 217 |
+
license='BSD 3-Clause License',
|
| 218 |
+
python_requires='>=3.9',
|
| 219 |
+
classifiers=[
|
| 220 |
+
'Development Status :: 3 - Alpha',
|
| 221 |
+
'Intended Audience :: Developers',
|
| 222 |
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
| 223 |
+
'License :: OSI Approved :: BSD License',
|
| 224 |
+
'Programming Language :: Python :: 3',
|
| 225 |
+
'Programming Language :: Python :: 3.9',
|
| 226 |
+
'Programming Language :: Python :: 3.10',
|
| 227 |
+
'Programming Language :: Python :: 3.11',
|
| 228 |
+
'Operating System :: OS Independent',
|
| 229 |
+
],
|
| 230 |
+
ext_modules=ext_modules,
|
| 231 |
+
cmdclass={"build_ext": BuildExtension},
|
| 232 |
+
)
|
wheel/python3.12/torch2.8.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:111662b1c06509c57bc3677ebcd877cc63a7055094046c811964f101299e4da2
|
| 3 |
+
size 10037220
|
wheel/python3.12/torch2.9.0/SageAttention/sageattention-2.2.0-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9096be647f7dc146a0c662115063b5e75b93dbfaf1c2a680f801acf92b95679
|
| 3 |
+
size 15616303
|
wheel/python3.12/torch2.9.0/SpargeAttn/setup.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Copyright (c) 2025 by SpargeAttn team.
|
| 3 |
+
|
| 4 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
you may not use this file except in compliance with the License.
|
| 6 |
+
You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
See the License for the specific language governing permissions and
|
| 14 |
+
limitations under the License.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
import subprocess
|
| 20 |
+
from packaging.version import parse, Version
|
| 21 |
+
from typing import List, Set
|
| 22 |
+
import warnings
|
| 23 |
+
|
| 24 |
+
from setuptools import setup, find_packages
|
| 25 |
+
import torch
|
| 26 |
+
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME
|
| 27 |
+
|
| 28 |
+
HAS_SM90 = False
|
| 29 |
+
SAGE2PP_ENABLED = True
|
| 30 |
+
|
| 31 |
+
def run_instantiations(src_dir: str):
|
| 32 |
+
base_path = Path(src_dir)
|
| 33 |
+
py_files = [
|
| 34 |
+
path for path in base_path.rglob('*.py')
|
| 35 |
+
if path.is_file()
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
for py_file in py_files:
|
| 39 |
+
print(f"Running: {py_file}")
|
| 40 |
+
os.system(f"python {py_file}")
|
| 41 |
+
|
| 42 |
+
def get_instantiations(src_dir: str):
|
| 43 |
+
# get all .cu files under src_dir
|
| 44 |
+
base_path = Path(src_dir)
|
| 45 |
+
return [
|
| 46 |
+
os.path.join(src_dir, str(path.relative_to(base_path)))
|
| 47 |
+
for path in base_path.rglob('*')
|
| 48 |
+
if path.is_file() and path.suffix == ".cu"
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# Supported NVIDIA GPU architectures.
|
| 52 |
+
SUPPORTED_ARCHS = {"8.0", "8.6", "8.7", "8.9", "9.0"}
|
| 53 |
+
|
| 54 |
+
# Compiler flags.
|
| 55 |
+
CXX_FLAGS = ["-g", "-O3", "-fopenmp", "-lgomp", "-std=c++17", "-DENABLE_BF16"]
|
| 56 |
+
NVCC_FLAGS = [
|
| 57 |
+
"-O3",
|
| 58 |
+
"-std=c++17",
|
| 59 |
+
"-U__CUDA_NO_HALF_OPERATORS__",
|
| 60 |
+
"-U__CUDA_NO_HALF_CONVERSIONS__",
|
| 61 |
+
"--use_fast_math",
|
| 62 |
+
"--threads=8",
|
| 63 |
+
"-Xptxas=-v",
|
| 64 |
+
"-diag-suppress=174", # suppress the specific warning
|
| 65 |
+
# "-Xcompiler", "-include,cassert", # fix error occurs when compiling for SM90+ with newer CUDA toolkits RTX 40 系列是 SM89可以安全移除该选项
|
| 66 |
+
]
|
| 67 |
+
|
| 68 |
+
ABI = 1 if torch._C._GLIBCXX_USE_CXX11_ABI else 0
|
| 69 |
+
CXX_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
|
| 70 |
+
NVCC_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
|
| 71 |
+
|
| 72 |
+
if CUDA_HOME is None:
|
| 73 |
+
raise RuntimeError(
|
| 74 |
+
"Cannot find CUDA_HOME. CUDA must be available to build the package.")
|
| 75 |
+
|
| 76 |
+
def get_nvcc_cuda_version(cuda_dir: str) -> Version:
|
| 77 |
+
"""Get the CUDA version from nvcc.
|
| 78 |
+
|
| 79 |
+
Adapted from https://github.com/NVIDIA/apex/blob/8b7a1ff183741dd8f9b87e7bafd04cfde99cea28/setup.py
|
| 80 |
+
"""
|
| 81 |
+
nvcc_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"],
|
| 82 |
+
universal_newlines=True)
|
| 83 |
+
output = nvcc_output.split()
|
| 84 |
+
release_idx = output.index("release") + 1
|
| 85 |
+
nvcc_cuda_version = parse(output[release_idx].split(",")[0])
|
| 86 |
+
return nvcc_cuda_version
|
| 87 |
+
|
| 88 |
+
def get_torch_arch_list() -> Set[str]:
|
| 89 |
+
# TORCH_CUDA_ARCH_LIST can have one or more architectures,
|
| 90 |
+
# e.g. "8.0" or "7.5,8.0,8.6+PTX". Here, the "8.6+PTX" option asks the
|
| 91 |
+
# compiler to additionally include PTX code that can be runtime-compiled
|
| 92 |
+
# and executed on the 8.6 or newer architectures. While the PTX code will
|
| 93 |
+
# not give the best performance on the newer architectures, it provides
|
| 94 |
+
# forward compatibility.
|
| 95 |
+
env_arch_list = os.environ.get("TORCH_CUDA_ARCH_LIST", None)
|
| 96 |
+
if env_arch_list is None:
|
| 97 |
+
return set()
|
| 98 |
+
|
| 99 |
+
# List are separated by ; or space.
|
| 100 |
+
torch_arch_list = set(env_arch_list.replace(" ", ";").split(";"))
|
| 101 |
+
if not torch_arch_list:
|
| 102 |
+
return set()
|
| 103 |
+
|
| 104 |
+
# Filter out the invalid architectures and print a warning.
|
| 105 |
+
valid_archs = SUPPORTED_ARCHS.union({s + "+PTX" for s in SUPPORTED_ARCHS})
|
| 106 |
+
arch_list = torch_arch_list.intersection(valid_archs)
|
| 107 |
+
# If none of the specified architectures are valid, raise an error.
|
| 108 |
+
if not arch_list:
|
| 109 |
+
raise RuntimeError(
|
| 110 |
+
"None of the CUDA architectures in `TORCH_CUDA_ARCH_LIST` env "
|
| 111 |
+
f"variable ({env_arch_list}) is supported. "
|
| 112 |
+
f"Supported CUDA architectures are: {valid_archs}.")
|
| 113 |
+
invalid_arch_list = torch_arch_list - valid_archs
|
| 114 |
+
if invalid_arch_list:
|
| 115 |
+
warnings.warn(
|
| 116 |
+
f"Unsupported CUDA architectures ({invalid_arch_list}) are "
|
| 117 |
+
"excluded from the `TORCH_CUDA_ARCH_LIST` env variable "
|
| 118 |
+
f"({env_arch_list}). Supported CUDA architectures are: "
|
| 119 |
+
f"{valid_archs}.")
|
| 120 |
+
return arch_list
|
| 121 |
+
|
| 122 |
+
# First, check the TORCH_CUDA_ARCH_LIST environment variable.
|
| 123 |
+
compute_capabilities = get_torch_arch_list()
|
| 124 |
+
if not compute_capabilities:
|
| 125 |
+
# If TORCH_CUDA_ARCH_LIST is not defined or empty, target all available
|
| 126 |
+
# GPUs on the current machine.
|
| 127 |
+
device_count = torch.cuda.device_count()
|
| 128 |
+
for i in range(device_count):
|
| 129 |
+
major, minor = torch.cuda.get_device_capability(i)
|
| 130 |
+
if major < 8:
|
| 131 |
+
raise RuntimeError(
|
| 132 |
+
"GPUs with compute capability below 8.0 are not supported.")
|
| 133 |
+
compute_capabilities.add(f"{major}.{minor}")
|
| 134 |
+
|
| 135 |
+
nvcc_cuda_version = get_nvcc_cuda_version(CUDA_HOME)
|
| 136 |
+
if not compute_capabilities:
|
| 137 |
+
raise RuntimeError("No GPUs found. Please specify the target GPU architectures or build on a machine with GPUs.")
|
| 138 |
+
|
| 139 |
+
# Validate the NVCC CUDA version.
|
| 140 |
+
if nvcc_cuda_version < Version("12.0"):
|
| 141 |
+
raise RuntimeError("CUDA 12.0 or higher is required to build the package.")
|
| 142 |
+
if nvcc_cuda_version < Version("12.4"):
|
| 143 |
+
if any(cc.startswith("8.9") for cc in compute_capabilities):
|
| 144 |
+
raise RuntimeError(
|
| 145 |
+
"CUDA 12.4 or higher is required for compute capability 8.9.")
|
| 146 |
+
if any(cc.startswith("9.0") for cc in compute_capabilities):
|
| 147 |
+
raise RuntimeError(
|
| 148 |
+
"CUDA 12.4 or higher is required for compute capability 9.0.")
|
| 149 |
+
if nvcc_cuda_version < Version("12.8"):
|
| 150 |
+
warnings.warn("CUDA 12.8 or higher is required for Sage2++")
|
| 151 |
+
SAGE2PP_ENABLED = False
|
| 152 |
+
|
| 153 |
+
# Add target compute capabilities to NVCC flags.
|
| 154 |
+
for capability in compute_capabilities:
|
| 155 |
+
num = capability.replace(".", "")
|
| 156 |
+
if num == '90':
|
| 157 |
+
num = '90a'
|
| 158 |
+
HAS_SM90 = True
|
| 159 |
+
CXX_FLAGS += ["-DHAS_SM90"]
|
| 160 |
+
if num == '80' or num == '86' or num == '87':
|
| 161 |
+
SAGE2PP_ENABLED = False
|
| 162 |
+
|
| 163 |
+
NVCC_FLAGS += ["-gencode", f"arch=compute_{num},code=sm_{num}"]
|
| 164 |
+
if capability.endswith("+PTX"):
|
| 165 |
+
NVCC_FLAGS += ["-gencode", f"arch=compute_{num},code=compute_{num}"]
|
| 166 |
+
|
| 167 |
+
if SAGE2PP_ENABLED:
|
| 168 |
+
CXX_FLAGS += ["-DSAGE2PP_ENABLED"]
|
| 169 |
+
|
| 170 |
+
ext_modules = []
|
| 171 |
+
|
| 172 |
+
run_instantiations("csrc/qattn/instantiations_sm80")
|
| 173 |
+
run_instantiations("csrc/qattn/instantiations_sm89")
|
| 174 |
+
run_instantiations("csrc/qattn/instantiations_sm90")
|
| 175 |
+
|
| 176 |
+
sources = [
|
| 177 |
+
"csrc/qattn/pybind.cpp",
|
| 178 |
+
"csrc/qattn/qk_int_sv_f16_cuda_sm80.cu",
|
| 179 |
+
"csrc/qattn/qk_int_sv_f8_cuda_sm89.cu",
|
| 180 |
+
] + get_instantiations("csrc/qattn/instantiations_sm80") + get_instantiations("csrc/qattn/instantiations_sm89")
|
| 181 |
+
|
| 182 |
+
if HAS_SM90:
|
| 183 |
+
sources += ["csrc/qattn/qk_int_sv_f8_cuda_sm90.cu", ]
|
| 184 |
+
sources += get_instantiations("csrc/qattn/instantiations_sm90")
|
| 185 |
+
|
| 186 |
+
qattn_extension = CUDAExtension(
|
| 187 |
+
name="spas_sage_attn._qattn",
|
| 188 |
+
sources=sources,
|
| 189 |
+
extra_compile_args={
|
| 190 |
+
"cxx": CXX_FLAGS,
|
| 191 |
+
"nvcc": NVCC_FLAGS,
|
| 192 |
+
},
|
| 193 |
+
extra_link_args=['-lcuda'],
|
| 194 |
+
)
|
| 195 |
+
ext_modules.append(qattn_extension)
|
| 196 |
+
|
| 197 |
+
fused_extension = CUDAExtension(
|
| 198 |
+
name="spas_sage_attn._fused",
|
| 199 |
+
sources=["csrc/fused/pybind.cpp", "csrc/fused/fused.cu"],
|
| 200 |
+
extra_compile_args={
|
| 201 |
+
"cxx": CXX_FLAGS,
|
| 202 |
+
"nvcc": NVCC_FLAGS,
|
| 203 |
+
},
|
| 204 |
+
)
|
| 205 |
+
ext_modules.append(fused_extension)
|
| 206 |
+
|
| 207 |
+
setup(
|
| 208 |
+
name='spas_sage_attn',
|
| 209 |
+
version='0.1.0',
|
| 210 |
+
author='Jintao Zhang, Chendong Xiang, Haofeng Huang',
|
| 211 |
+
author_email='jt-zhang6@gmail.com',
|
| 212 |
+
packages=find_packages(),
|
| 213 |
+
description='Accurate and efficient Sparse SageAttention.',
|
| 214 |
+
long_description=open('README.md', encoding='utf-8').read(),
|
| 215 |
+
long_description_content_type='text/markdown',
|
| 216 |
+
url='https://github.com/thu-ml/SpargeAttn',
|
| 217 |
+
license='BSD 3-Clause License',
|
| 218 |
+
python_requires='>=3.9',
|
| 219 |
+
classifiers=[
|
| 220 |
+
'Development Status :: 3 - Alpha',
|
| 221 |
+
'Intended Audience :: Developers',
|
| 222 |
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
| 223 |
+
'License :: OSI Approved :: BSD License',
|
| 224 |
+
'Programming Language :: Python :: 3',
|
| 225 |
+
'Programming Language :: Python :: 3.9',
|
| 226 |
+
'Programming Language :: Python :: 3.10',
|
| 227 |
+
'Programming Language :: Python :: 3.11',
|
| 228 |
+
'Operating System :: OS Independent',
|
| 229 |
+
],
|
| 230 |
+
ext_modules=ext_modules,
|
| 231 |
+
cmdclass={"build_ext": BuildExtension},
|
| 232 |
+
)
|
wheel/python3.12/torch2.9.0/SpargeAttn/spas_sage_attn-0.1.0-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0cb2be8204cbe67a9b61f249d6e26986ddaeeb43512cce90aea5be7ad91db97f
|
| 3 |
+
size 10345136
|
wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.7.4-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10d88c0e49eb139a74bf0cc6ed71ca09d7bf82f6ff27a2cfb80b516a8afd7e9b
|
| 3 |
+
size 87973409
|
wheel/python3.12/torch2.9.0/flash-attention/flash_attn-2.8.2-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85cc068cbd1d0b2762833a61d261e7938c5c531744b058ffd6a1abb0c370c46d
|
| 3 |
+
size 56739530
|
wheel/python3.12/torch2.9.0/long-context-attention/yunchang-0.6.4-py3-none-any.whl
ADDED
|
Binary file (59.1 kB). View file
|
|
|
wheel/python3.12/torch2.9.0/nunchaku/nunchaku-1.3.0.dev20260304+cu13.0torch2.9-cp312-cp312-linux_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d27d235797f821b2674164833da09ce2f8ccd1dc1f373e5270716f8670b43bd4
|
| 3 |
+
size 47571075
|
wheel/python3.12/torch2.9.0/nunchaku/third_party/cutlass/include/cutlass/matrix.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
wheel/python3.12/torch2.9.0/xdit-comfyui-private/xdit_comfyui_private-0.0.1-py3-none-any.whl
ADDED
|
Binary file (35.2 kB). View file
|
|
|
wheel/python3.12/torch2.9.0/xdit-comfyui-private/先装ray和long-context-attention
ADDED
|
File without changes
|