Skip to main content

dew-flash-attn

FlashAttention for JAX, built for Dew. It packages Dao-AILab's CUDA kernels as libraries with no Python ABI that register XLA FFI targets with JAX: FlashAttention-2 through flash_attn_jax's port, and FlashAttention-3, Hopper's kernels, through flash-attn3-jax's torch-free port, all BSD-3.

There is one wheel for each CUDA major of your jax, for Linux x86_64 and aarch64 and any Python from 3.11:

pip install dew-flash-attn-cu12   # jax with jax-cuda12-plugin
pip install dew-flash-attn-cu13   # jax with jax-cuda13-plugin

The wheel ships no CUDA runtime: it needs a CUDA build of JAX of the same major in the same environment (jax[cuda12] or jax[cuda13]), whose libcudart it loads.

With it installed, Dew's attention_impl="auto" runs FlashAttention on an A100 (sm80), an Ada GPU (sm89) and an H100 (sm90) for calls without a mask, bias, softcap or attention sinks, sliding windows included, with heads up to 256 wide (Dew takes calls with sinks elsewhere: this backward's rows whose sink holds most of the softmax lose its cancellation). attention_impl="flash" asks for it on any sm8x, sm90 or sm120 GPU.

FlashAttention-2 is compiled for sm80, which every compute capability 8.x runs, and for sm120, Blackwell's workstation and consumer parts (the RTX PRO 6000 and the RTX 50 series). FlashAttention-3 is compiled for sm90a (H100, H200), for bf16 and fp16 heads of 64, 128, 192 and 256 (a narrower head is padded up to the next), with variable lengths and sliding windows and without split keys, paged caches, softcap or fp8. The same two functions run whichever the GPU has.

Called directly:

from dew_flash_attn import flash_mha

out = flash_mha(query, key, value, is_causal=True)  # [B, S, H, D], bf16 or fp16

Key heads may divide the query's (grouped-query attention). The backward pass is the kernel's own.

A sliding window and attention sinks, one learned logit a query head in each row's softmax denominator with no value (gpt-oss, MiMo-V2), go to either function:

out = flash_mha(query, key, value, is_causal=True, window_size=(127, 0), sinks=sinks)  # sinks [H]

window_size (left, right) keeps the left keys before each query and the right after it, -1 bounding neither side. The sinks scale the kernel's output by each row's share of the softmax, sigmoid(lse - sink), and take their gradient from the kernel's own backward.

Packed sequences, [T, H, D] with int32 offsets cu_seqlens [N + 1] from 0 to T, attend each within itself:

from dew_flash_attn import flash_mha_varlen

out = flash_mha_varlen(query, key, value, cu_seqlens, max_seqlen, is_causal=True)

Keys packed by offsets of their own, key_cu_seqlens [N + 1] over the keys' [T_k, H_k, D] with at most key_max_seqlen a sequence, pair sequence i's queries with sequence i's keys alone: cross-attention between packed documents, such as a head's slots reading their own document's tokens.

out = flash_mha_varlen(query, key, value, cu_seqlens, max_seqlen,
                       key_cu_seqlens=key_cu_seqlens, key_max_seqlen=key_max_seqlen)

The packed backward launches its CTAs over the batch's blocks, not over N times max_seqlen's: patches/ changes both ports' backward kernels so that a sequence's blocks start at cu_seqlens[i] / block + i and a CTA finds its sequence by a binary search, so a batch of many empty or short sequences costs what its tokens do. The patches apply to the pinned checkouts (build.sh) and are written to go upstream.

Metadata

Release files for dew-flash-attn-cu12 0.3.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for dew-flash-attn-cu12 0.3.12
File Interpreter ABI Platform Actions
dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_x86_64.whl
dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_aarch64.whl

Total release size: 152.0 MB

Release files / dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_x86_64.whl

Download URL dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_x86_64.whl
Size 76.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6cff3691f7cec36d58215bb2663843d3a1719bc1e3bb963a5979852fed604932
BLAKE2b-256 checksum
How to use checksums
da962e6b1326b3980d13bbdc5b52c92d391f93d4267a1467c3e8fb0a49261e2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_aarch64.whl

Download URL dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_aarch64.whl
Size 75.8 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
e695e6d460f01bc80ee789e5a9d63a20cf68d70b70399bcf0e46f927e10fa8a1
BLAKE2b-256 checksum
How to use checksums
a0b41c2be5dbb74a601a6dcf9a3a445ad72a68195d41b4c9bf5648bc1e484e2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for dew-flash-attn-cu12 0.3.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dew_flash_attn_cu12-0.3.12-py3-none-manylinux_2_28_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page