Skip to content

Commit

Permalink
Add option of disabling cudnn version checking.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698889971
  • Loading branch information
Google-ML-Automation committed Nov 21, 2024
1 parent f3e7e68 commit 3a72a64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions jax/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ py_library_providing_imports_info(
":xla_bridge",
":xla_metadata",
"//jax/_src/lib",
"//third_party/py/absl/flags",
] + py_deps("numpy") + py_deps("scipy") + py_deps("opt_einsum") + py_deps("flatbuffers") + jax_extra_deps,
)

Expand Down
16 changes: 14 additions & 2 deletions jax/_src/cudnn/fused_attention_stablehlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json
import math

from absl import flags
import jax
from jax import core
from jax import dtypes
Expand All @@ -34,6 +35,15 @@

Array = jnp.ndarray

_DISABLE_CUDNN_VERSION_CHECK = flags.DEFINE_bool(
"disable_cudnn_version_check",
False,
"Whether to disable the cuDNN version check. It's safe to disable the check"
" if we don't actually need to run the cudnn kernel, e.g., for exporting"
" JaxModule to tensorflow. Without disabling the check, it requires running"
" the export on a machine with a100, which is unnecessary."
)


class AttentionLayout(enum.Enum):
BTNH = 0
Expand Down Expand Up @@ -1025,7 +1035,9 @@ def dot_product_attention(query: Array,
# check if cuDNN is installed
cudnn_version = check_cudnn_version()
# only support at least Ampere
if not check_compute_capability("8.0"):
if not _DISABLE_CUDNN_VERSION_CHECK.value and not check_compute_capability(
"8.0"
):
raise RuntimeError("Require at least Ampere arch to run")
layout = _normalize_layout(qkv_layout)
if has_padding(mask_type) and (q_seqlen is None or kv_seqlen is None):
Expand All @@ -1047,7 +1059,7 @@ def dot_product_attention(query: Array,

# combine bias and mask
if bias is None:
bias = mask
bias = mask
else:
if mask is not None:
# should be broadcast to same shape
Expand Down

0 comments on commit 3a72a64

Please sign in to comment.