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.8

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.8
File Interpreter ABI Platform Actions
dew_flash_attn_cu12-0.3.8-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.8-py3-none-manylinux_2_28_x86_64.whl
dew_flash_attn_cu12-0.3.8-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for dew_flash_attn_cu12-0.3.8-py3-none-manylinux_2_28_aarch64.whl

Total release size: 152.0 MB

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

Download URL dew_flash_attn_cu12-0.3.8-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
20a081b2e8f7728c72b8e90d5ed1a68831574ef9be8ed209f63cef07c02ecbcf
BLAKE2b-256 checksum
How to use checksums
056254ff2277bfbeeb9876be11c6faf7861854da8def1a347d49c4b2fd878847
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 6, 2026.

Transparency log

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

Download URL dew_flash_attn_cu12-0.3.8-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
bf70cdeb25b2b29ed5a348f3a03b291df5dd4cd625a651e3c4b829b2f2d59c06
BLAKE2b-256 checksum
How to use checksums
b0dccd199b33342d122c2defd3f0894d78c2fda92d8c54eaa15b2dfba1346f67
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 6, 2026.

Transparency log

Security for dew-flash-attn-cu12 0.3.8

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.8-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 6, 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