keras-team/keras · error · ImportError

Flash attention is not supported in your current JAX…

Error message

Flash attention is not supported in your current JAX version. Please update it by following the official guide: https://jax.readthedocs.io/en/latest/installation.html

What it means

Error "Flash attention is not supported in your current JAX version. Please update it by following the official guide: https://jax.readthedocs.io/en/latest/installation.html" thrown in keras-team/keras.

Solutions

  1. Upgrade JAX to a version that ships jax._src.cudnn.fused_attention_stablehlo (recent releases), following https://jax.readthedocs.io/en/latest/installation.html.
  2. If you cannot upgrade, disable the flash-attention path (e.g. avoid the fused/cuDNN attention flags) so dot_product_attention falls back to the standard implementation.
  3. Verify CUDA/cuDNN versions are compatible with the newer JAX build after upgrading.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at keras/src/backend/jax/nn.py:1472 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/a1d41983fa3f913e. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/jax/nn.py:1472

    return psnr


def _can_use_flash_attention(query, key, value, bias, raise_error=False):
    """Verify the availability of flash attention."""
    try:
        from jax._src.cudnn.fused_attention_stablehlo import _normalize_layout
        from jax._src.cudnn.fused_attention_stablehlo import (
            check_compute_capability,
        )
        from jax._src.cudnn.fused_attention_stablehlo import check_cudnn_version
        from jax._src.cudnn.fused_attention_stablehlo import (
            check_is_flash_attention,
        )
        from jax._src.cudnn.fused_attention_stablehlo import check_layout
        from jax.nn import dot_product_attention as dot_product_attention
    except ImportError:
        if raise_error:
            raise ImportError(
                "Flash attention is not supported in your current JAX version. "
                "Please update it by following the official guide: "
                "https://jax.readthedocs.io/en/latest/installation.html"
            )
        return False

    if jax.devices()[0].platform == "tpu":
        return True
    try:
        # Check if cuDNN is installed and raise RuntimeError if cuDNN is not
        # detected
        cudnn_version = check_cudnn_version()
        # Only support at least Ampere
        if not check_compute_capability("8.0"):
            raise RuntimeError("Require at least Ampere arch to run")

        # Inspect inputs of `check_layout`
        check_layout_params = list(

View on GitHub (pinned to 7a34a03db6)