Skip to content

Commit d73fb52

Browse files
authored
Merge pull request #8 from NX-AI/1.0.5
1.0.5
2 parents d761de3 + c45f3cf commit d73fb52

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

flashrnn/autotune/constrint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from enum import Enum
5454
from functools import lru_cache, wraps
5555
from typing import Iterable, Optional, Sequence, Union
56+
from pathlib import Path
5657

5758
LOGGER = logging.getLogger(__name__)
5859

@@ -1931,7 +1932,7 @@ class ValueRefinement:
19311932

19321933

19331934
@cache_decorator(
1934-
os.getenv("CONSTRINT_CACHE_DIR", os.getenv("HOME") + "/.cache/constrint")
1935+
os.getenv("CONSTRINT_CACHE_DIR", str(Path.home() / ".cache" / "constrint"))
19351936
)
19361937
def solve_constrint(
19371938
constr: Constraint,

flashrnn/flashrnn/cuda_init.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,47 @@
44
import os
55
from typing import Sequence, Union
66
import logging
7+
import functools
8+
import subprocess
9+
import sys
10+
from packaging.version import Version
11+
import re
712

813
import time
914
import random
1015

1116
import torch
1217
from torch.utils.cpp_extension import load as _load
18+
from torch.utils.cpp_extension import _find_cuda_home
19+
1320

1421
# print("INCLUDE:", torch.utils.cpp_extension.include_paths(cuda=True))
1522
# print("C++ compat", torch.utils.cpp_extension.check_compiler_abi_compatibility("g++"))
1623
# print("C compat", torch.utils.cpp_extension.check_compiler_abi_compatibility("gcc"))
1724

1825
LOGGER = logging.getLogger(__name__)
26+
CUDA_HOME = _find_cuda_home()
27+
IS_WINDOWS = sys.platform == 'win32'
28+
IS_MACOS = sys.platform.startswith('darwin')
29+
SUBPROCESS_DECODE_ARGS = ('oem',) if IS_WINDOWS else ()
30+
31+
@functools.cache
32+
def get_cuda_version() -> Version | None:
33+
try:
34+
nvcc = os.path.join(CUDA_HOME, 'bin', 'nvcc.exe' if IS_WINDOWS else 'nvcc')
35+
cuda_version_str = subprocess.check_output([nvcc, '--version']).strip().decode(*SUBPROCESS_DECODE_ARGS)
36+
cuda_version = re.search(r'release (\d+[.]\d+)', cuda_version_str)
37+
38+
if cuda_version is None:
39+
return
40+
cuda_str_version = cuda_version.group(1)
41+
cuda_version = Version(cuda_str_version)
42+
return cuda_version
43+
except (RuntimeError, FileNotFoundError, subprocess.CalledProcessError) as e:
44+
# raise RuntimeError(
45+
# "Could not determine CUDA version."
46+
# ) from e
47+
return
1948

2049

2150
def defines_to_cflags(
@@ -124,6 +153,11 @@ def load(*, name, sources, extra_cflags=(), extra_cuda_cflags=(), **kwargs):
124153
*extra_cuda_cflags,
125154
],
126155
}
156+
157+
cuda_version = get_cuda_version()
158+
if cuda_version is not None and cuda_version >= Version("12.8"):
159+
myargs['extra_cuda_cflags'].append("-static-global-template-stub=false")
160+
127161
LOGGER.info("Kernel compilation arguments", myargs)
128162
myargs.update(**kwargs)
129163
# add random waiting time to minimize deadlocks because of badly managed multicompile of pytorch ext

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "flashrnn"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
authors = [
55
{ name="Korbinian Pöppel", email="[email protected]" },
66
{ name="Maximilian Beck", email="[email protected]" },
@@ -16,7 +16,7 @@ classifiers = [
1616
dependencies = [
1717
"torch",
1818
"einops",
19-
"triton",
19+
"triton; sys_platform == 'linux'",
2020
"ninja"
2121
]
2222

0 commit comments

Comments
 (0)