Skip to main content

a simpler version of flashattention

Project description

simpler_flash

[Tests][tests] [Documentation][documentation]

a full on suite of fast flash attention mechanisms, flashattention, flash-hyperattention, flash-softpick attention, flash-adasplash, flash criss-cross attention. just pip install it with conda or with uv, have a compatible gpu and it should work.

installs in 1 sec without anything complex.

Installation

You need to use Python 3.10+.

There are several alternative options to install simpler_flash:

  1. Install the latest release of simpler_flash from [PyPI][]:
pip install simpler_flash
  1. Install the latest development version:
pip install git+https://github.com/jkobject/simpler_flash.git@main

in some old GPUs, you might need to use a lower block dim, for now it just has to be updated in the source code directly e.g. setting MAX_BLOCK_SIZE=64 instead of 128. it will reduce your max head size to 64

Usage

from simpler_flash import FlashTransformer


self.transformer = FlashTransformer(
    d_model=1024,
    nhead=16,
    nlayers=12,
    dropout=0.1,
    use_flash_attn=True,
    num_heads_kv=4, # option to do Grouped Attention
    checkpointing=True, # option to use checkpointing
    prenorm=True, # option to use prenorm
    drop_path_rate=0.1, # option to use drop path
)

transformer_output = self.transformer(
    encoding,
    return_qkv=get_attention_layer, #option to get the q,k,v matrices (to extract attention scores for example)
    bias=bias if do_bias else None, # option to add attention bias
    bias_layer=list(range(self.nlayers - 1)), # option to add attention bias to specific layers

)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpler_flash-1.3.3.tar.gz (171.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpler_flash-1.3.3-py3-none-any.whl (62.6 kB view details)

Uploaded Python 3

File details

Details for the file simpler_flash-1.3.3.tar.gz.

File metadata

  • Download URL: simpler_flash-1.3.3.tar.gz
  • Upload date:
  • Size: 171.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for simpler_flash-1.3.3.tar.gz
Algorithm Hash digest
SHA256 5ef2e56c617b76c83d8b700ee854cb1cd24bb27f727966695a27babb5729407c
MD5 d9edbce67682b0942f8ef8313a41759e
BLAKE2b-256 d57d8fa6272fd1932b6a6d99a465af967a92a7a6c9faec0ab59ffc660eb21d07

See more details on using hashes here.

File details

Details for the file simpler_flash-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: simpler_flash-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 62.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for simpler_flash-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d4d6f90cfcfe1359716e76263174e7791f81b09f0cbe8e73ea0cf08c7a1eb74e
MD5 3056710742e280e7076a874076549d23
BLAKE2b-256 8e40c1141a071a1806e10a87012fe70dc6d5a50667898bce65e684f9d21027f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page