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.4.tar.gz (163.8 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.4-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simpler_flash-1.3.4.tar.gz
  • Upload date:
  • Size: 163.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"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.4.tar.gz
Algorithm Hash digest
SHA256 eac1297dba76ed06bc9d198040ce6bc7c32005961bffa1a474817e205eb81224
MD5 9af48cb815e0e532faf3295bb004e94f
BLAKE2b-256 670918f2f2f5962dde2ff6e9fd83311f7b412f15dba643a404ea87e97abcb536

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simpler_flash-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 63.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ca89942ece85a1c327b800873ea0da49d1196cc34ccf15b3c2f74e15881a0a4e
MD5 c0d61cc2a48b1feb099b4cd399f199e1
BLAKE2b-256 f10b8a1dd296a7661818ce4ef98abf549662291271b60d4e794d67f0b717f9db

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