Skip to main content

Fast kernel for triangle self attetion.

Project description

Fused Triangle Self Attention kernel, written in triton. Basically flash attention, but for triangle self attention. Implementation heavily inspired by FlagAttention and the triton fused attention tutorial.

  • n^2 memory complexity (vs n^3 for pure pytorch).
  • Faster (~2x) backward pass than next fastest implementation I could find (DS4S evoformer kernel).
  • Faster (~4x) forward pass than next fastest implementation I could find (DS4S evoformer kernel).
  • As far as I can tell, faster than naieve implementation.

Plots

All done on a 3090 in bfloat16.

Forward

TSA forward runtime TSA forward memory

Backward TSA backward runtime TSA backward memory

Todos:

  • [] Try to train a model with it.
  • [] Can we perform and of dq/db/dkv transposed?
  • [] Rewrite autotuner

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

trifast-0.1.9.tar.gz (15.8 MB view details)

Uploaded Source

Built Distribution

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

trifast-0.1.9-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file trifast-0.1.9.tar.gz.

File metadata

  • Download URL: trifast-0.1.9.tar.gz
  • Upload date:
  • Size: 15.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.21

File hashes

Hashes for trifast-0.1.9.tar.gz
Algorithm Hash digest
SHA256 c15f5d20966369405244d3ecf206e2f9150d5d931688764423f3a9f2f07b8851
MD5 f7f5f040825d21f270a21d4ecb1bdc4b
BLAKE2b-256 9bae9c9fa9706dd6531af42b4a11baa888bc6e4a2e290e212341201369d1ba97

See more details on using hashes here.

File details

Details for the file trifast-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: trifast-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.21

File hashes

Hashes for trifast-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 67fca8761d0c413247bb9f335f9fdc60f6c2789a94bff649b590af7e3c53fd8a
MD5 9513aaa2d7f14a51913c10380e957f5e
BLAKE2b-256 323d43b19058f4d696502d1250caa5e0500de7c41d71d0362c4e39d8366cee0b

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