Floyd Multi-Head Attention: a drop-in variant of PyTorch MHA with module and function APIs
Project description
floyd-net
Floyd Multi-Head Attention (F-MHA) is a drop-in variant of PyTorch's attention stack. It provides:
- Module API:
FloydMultiheadAttentionmirroringtorch.nn.MultiheadAttention - Functional API:
floyd_scaled_dot_product_attentionmirroringtorch.nn.functional.scaled_dot_product_attention
Install and manage with uv for a modern Python workflow.
Quick start
# Install with uv (recommended)
uv venv --python 3.10
source .venv/bin/activate
uv pip install -e .[dev]
import torch
from floyd_net import FloydMultiheadAttention
m = FloydMultiheadAttention(embed_dim=64, num_heads=8, batch_first=True)
x = torch.randn(2, 16, 64)
out, attn = m(x, x, x)
print(out.shape)
Functional API
import torch
import torch.nn.functional as F
from floyd_net import floyd_scaled_dot_product_attention
q = torch.randn(2, 8, 16, 64) # (B, H, L, D)
k = torch.randn(2, 8, 16, 64)
v = torch.randn(2, 8, 16, 64)
out = floyd_scaled_dot_product_attention(q, k, v)
print(out.shape)
Paper reproductions
See paper/ for dataset preparation, configs, and experiment templates to reproduce the results in the paper.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file floydnet-0.1.0.tar.gz.
File metadata
- Download URL: floydnet-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58475501ce434155d8785c34265cd8091155f37ab637ba0345c583e0bdca350f
|
|
| MD5 |
ad4baa2cd49292b4e26328b4780dd2f7
|
|
| BLAKE2b-256 |
abe9e388cd8924d22040325ebeffd369abc13ec4829334f80b18fd65d67c41ef
|
File details
Details for the file floydnet-0.1.0-py3-none-any.whl.
File metadata
- Download URL: floydnet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cef7f479a96f4e6cdfc28f6c2065a17e7ce872aac73e8659a8c8e0bcc2a166ef
|
|
| MD5 |
26b636af8147059f35d8ba489ef5e02c
|
|
| BLAKE2b-256 |
f80785a936af531834016da6675bc1d8407844f3bd8d525c7b90e27405b21fcc
|