Lookahead Keys Attention (wip)
Causal Attention with Lookahead Keys
Installation
pip install lookahead-keys-attention
Usage
import torch
from lookahead_keys_attention import Castle
# Initialize the Castle attention module
model = Castle(
dim=512, # input dimension
heads=8, # number of attention heads
dim_head=64, # dimension per head
use_triton=None # auto-detect CUDA for Triton optimization
)
# Example with CUDA sequence
batch_size = 2
seq_len = 128
dim = 512
# Move to CUDA if available
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = model.to(device)
# Input sequence
x = torch.randn(batch_size, seq_len, dim).to(device)
# Forward pass
output = model(x) # Shape: [batch_size, seq_len, dim]
# For inference with caching (single token generation)
cache = None
for i in range(seq_len):
token = x[:, i:i+1, :] # Single token
output, cache = model(token, cache=cache, return_next_cache=True)
Citations
@inproceedings{Song2025CausalAW,
title = {Causal Attention with Lookahead Keys},
author = {Zhuoqing Song and Peng Sun and Huizhuo Yuan and Quanquan Gu},
year = {2025},
url = {https://api.semanticscholar.org/CorpusID:281218151}
}
Metadata
Release files for lookahead-keys-attention 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lookahead_keys_attention-0.1.2.tar.gz | 36.7 MB | Without provenance | Details for lookahead_keys_attention-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lookahead_keys_attention-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for lookahead_keys_attention-0.1.2-py3-none-any.whl |
Total release size: 36.7 MB
Release files / lookahead_keys_attention-0.1.2.tar.gz
| Download URL | lookahead_keys_attention-0.1.2.tar.gz |
|---|---|
| Size | 36.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f2a7eb08b906a591bcca3558688807b05a94acd917adf559002af8244fefe07
|
|
BLAKE2b-256 checksum How to use checksums |
b762c96fcfc25c573af6b9c55de0f45b2da45ad355b6b81db2c87f8794c7f2df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / lookahead_keys_attention-0.1.2-py3-none-any.whl
| Download URL | lookahead_keys_attention-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de099f026661604b3dd8ab5988d9f174581cf0da36071b1fda1944056bc75f55
|
|
BLAKE2b-256 checksum How to use checksums |
42dbfeb033da48a7e077f108099b62dc13b411a2b33b9c88e83bc5aa8ba43079
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Security for lookahead-keys-attention 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.