Skip to content

Commit

Permalink
fix SyntaxWarning (#548)
Browse files Browse the repository at this point in the history
Python 3.12 raises `SyntaxWarning` for invalid escape sequence like
`"\d"`.

This PR: Use raw strings for the regex and also add a capture group.

```pycon
Python 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 16:05:46) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import re
>>> cuda_arch_flags = '-gencode=arch=compute_90,code=compute_90'

>>> int(re.search("compute_\d+", cuda_arch_flags).group()[-2:])
<stdin>:1: SyntaxWarning: invalid escape sequence '\d'
90

>>> int(re.search(r"compute_(\d+)", cuda_arch_flags).group(1))
90
```
  • Loading branch information
abcdabcd987 authored Oct 22, 2024
1 parent b2a9e16 commit 47583b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/flashinfer/jit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def info(self, msg):
def check_cuda_arch():
# cuda arch check for fp8 at the moment.
for cuda_arch_flags in torch_cpp_ext._get_cuda_arch_flags():
arch = int(re.search("compute_\d+", cuda_arch_flags).group()[-2:])
arch = int(re.search(r"compute_(\d+)", cuda_arch_flags).group(1))
if arch < 75:
raise RuntimeError("FlashInfer requires sm75+")

Expand Down

0 comments on commit 47583b3

Please # to comment.