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.5.tar.gz (3.0 MB 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.5-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simpler_flash-1.3.5.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.5.tar.gz
Algorithm Hash digest
SHA256 e7a13d12ac45ef3512b311b90c621f35a9a346ccb7db949bf28e1f92212ee005
MD5 7de07c6713b33ee7fa3359c2d7fcd642
BLAKE2b-256 3843c268df3f3ec529cb253211a82784fe468f638dbd533cb66532772cb484b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simpler_flash-1.3.5-py3-none-any.whl
  • Upload date:
  • Size: 63.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 18c4dbc64d45c4eff388b62592a3711ebe3bc93f0d6e590ceaab4a31d227e43b
MD5 b0fa4a464abbbb073e03ad5e8572bc9a
BLAKE2b-256 bdc72de661892a07664729edca89858dcd1037600cd0dcfa535fa2a647a0b7da

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