Skip to main content

Kernels for higher order gradients of Flash Attention.

Project description

Flash Hog

Flash Hog Logo

This repo contains the code for Flash Higher-Order-Gradients, aka. Flash Hog. This kernel achieves around a 3.7x speedup over an XLA optimized kernel, with linear memory scaling instead of quadratic scaling.

Hog Speedup

Installation

TODO

Method

Flash Hog does 4 recomputation passes to avoid any atomics or saving any intermediary tensors of shape (N_Q, N_K). This shakes out to be thread-wise tiling across Q in 3 passes first, once to compute dd, then once for b, then once for both dQ' and ddO. Finally we do another pass tiled over K, producing dK' and dV'. The equations we implement are the following:

Equations

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

flash_hog-0.3.1.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

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

flash_hog-0.3.1-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file flash_hog-0.3.1.tar.gz.

File metadata

  • Download URL: flash_hog-0.3.1.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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":null}

File hashes

Hashes for flash_hog-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8f4caccb7f96433501bb7532b5fae8652eea051517f9d9eb1cd01325cb36875a
MD5 0b0f568ad1bb7f299fd2f8eb80a69260
BLAKE2b-256 89f49664ebdbb8ac51acc658438f15caebcf266f7b9db511143a7791793cd1f5

See more details on using hashes here.

File details

Details for the file flash_hog-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: flash_hog-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 48.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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":null}

File hashes

Hashes for flash_hog-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a82467a4098e6868030c7049e8feaa387553949319344f1a444d1cbe27a0d187
MD5 06195fbb288aa409aa0c18961bc677c3
BLAKE2b-256 8032fd59df3c970dd9b93677c29fc4d0823164f6643cb4b20938728db0ae66a5

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