High-performance sigmoid attention kernels using Triton
Project description
Triton Sigmoid Attention
Fused sigmoid attention kernels for NVIDIA GPUs built with Triton.
Overview
Two implementations:
- Dense - Same-length sequences (fastest)
- Padded - Variable-length with padding masks
Features torch.compile support and causal masking. Requires Ampere architecture or newer.
Installation
pip install triton-sigmoid
Development install from source
git clone https://github.com/MSDLLCpapers/triton-sigmoid.git
cd triton-sigmoid
uv sync --extra dev
source .venv/bin/activate
Quick Start
Dense Attention (Same-Length Sequences)
import torch
from triton_sigmoid import sigmoid_attention
batch, seq_len, n_heads, head_dim = 2, 1024, 8, 64
q = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
k = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
v = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
output = sigmoid_attention(q, k, v, is_causal=False)
output_causal = sigmoid_attention(q, k, v, is_causal=True)
Padded Attention (Variable-Length Sequences)
import torch
from triton_sigmoid import sigmoid_attention_padded
batch, seq_len, n_heads, head_dim = 2, 1024, 8, 64
q = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
k = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
v = torch.randn(batch, seq_len, n_heads, head_dim, device='cuda', dtype=torch.float16)
seq_lens_k = torch.tensor([800, 950], device='cuda', dtype=torch.int32)
seq_lens_q = torch.tensor([800, 950], device='cuda', dtype=torch.int32)
output = sigmoid_attention_padded(q, k, v, seq_lens_k=seq_lens_k, seq_lens_q=seq_lens_q)
compiled_fn = torch.compile(sigmoid_attention_padded)
output = compiled_fn(q, k, v, seq_lens_k=seq_lens_k, seq_lens_q=seq_lens_q, is_causal=True)
Performance
See benchmarks/README.md for details.
Documentation
- API Reference - Detailed function signatures and parameters
- Algorithm Details - Implementation details and sigmoid variants
- Benchmarking Guide - Performance benchmarks and how to run them
- Testing Guide - Running tests and test structure
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Citation
If you use this work in your research, please cite our paper:
@misc{sadashivaiah2026bettermodelsfastertraining,
title={Better Models, Faster Training: Sigmoid Attention for single-cell Foundation Models},
author={Vijay Sadashivaiah and Georgios Dasoulas and Judith Mueller and Soumya Ghosh},
year={2026},
eprint={2604.27124},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2604.27124},
}
Acknowledgments
- Built with Triton
- Inspired by Flash Attention
Project details
Release history Release notifications | RSS feed
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 triton_sigmoid-0.1.2.tar.gz.
File metadata
- Download URL: triton_sigmoid-0.1.2.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67ad4b8b42b5970a20a056ac99666c28b8207928e8afaec404921248987769d9
|
|
| MD5 |
bb30997fc4fa18a86b2132f02b29e22d
|
|
| BLAKE2b-256 |
5d7788b7b2077039e347c81b4b32e436c5ad752eaaddecf3b7e9d2a44772ca93
|
Provenance
The following attestation bundles were made for triton_sigmoid-0.1.2.tar.gz:
Publisher:
publish.yml on MSDLLCpapers/triton-sigmoid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triton_sigmoid-0.1.2.tar.gz -
Subject digest:
67ad4b8b42b5970a20a056ac99666c28b8207928e8afaec404921248987769d9 - Sigstore transparency entry: 1524556341
- Sigstore integration time:
-
Permalink:
MSDLLCpapers/triton-sigmoid@9ea924eff22941b26a5d28fbfc4aa0e0621ff509 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MSDLLCpapers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9ea924eff22941b26a5d28fbfc4aa0e0621ff509 -
Trigger Event:
release
-
Statement type:
File details
Details for the file triton_sigmoid-0.1.2-py3-none-any.whl.
File metadata
- Download URL: triton_sigmoid-0.1.2-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
137dd0b32e55d9062c7650645ce28161e3a371c8fe390fd1577fb854663630dc
|
|
| MD5 |
32424c2e51ce9e65814c7a0f2dc8504e
|
|
| BLAKE2b-256 |
d168ba726cceb9964d03822fbac0049e09be10155d7c75db3f05b6e90e829708
|
Provenance
The following attestation bundles were made for triton_sigmoid-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on MSDLLCpapers/triton-sigmoid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triton_sigmoid-0.1.2-py3-none-any.whl -
Subject digest:
137dd0b32e55d9062c7650645ce28161e3a371c8fe390fd1577fb854663630dc - Sigstore transparency entry: 1524556349
- Sigstore integration time:
-
Permalink:
MSDLLCpapers/triton-sigmoid@9ea924eff22941b26a5d28fbfc4aa0e0621ff509 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/MSDLLCpapers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9ea924eff22941b26a5d28fbfc4aa0e0621ff509 -
Trigger Event:
release
-
Statement type: