Skip to main content

Deep Cross Attention

Implementation of the proposed DeepCrossAttention by Mike Heddes while at Google research, in Pytorch

My analysis is although I still prefer Hyper Connections, they have an important idea here that I have been trying concurrently. Mainly the queries, keys, values can be routed from different layers of the past. The reason this is cool is because it generalizes the recent value residual learning improvement. It may (or may not) also address an issue for neural memories

Appreciation

  • Minh Hoang for spotting some issues with the GRN

Install

$ pip install deep-cross-attention

Usage

import torch
from deep_cross_attention import DCAGPT

gpt = DCAGPT(
    num_tokens = 256,
    dim = 512,
    depth = 6,
    heads = 8,
    dim_head = 64,
    past_layers_k = 2
)

ids = torch.randint(0, 256, (2, 4096))

logits = gpt(ids) # (2, 4096, 256)

Example

First

$ pip install .[examples]

Next

$ python train.py

Citations

@inproceedings{Heddes2025DeepCrossAttentionST,
    title   = {DeepCrossAttention: Supercharging Transformer Residual Connections},
    author  = {Mike Heddes and Adel Javanmard and Kyriakos Axiotis and Gang Fu and MohammadHossein Bateni and Vahab S. Mirrokni},
    year    = {2025},
    url     = {https://api.semanticscholar.org/CorpusID:276250576}
}

Metadata

Release files for deep-cross-attention 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deep-cross-attention 0.1.1
File Size Uploaded Provenance Actions
deep_cross_attention-0.1.1.tar.gz 6.7 kB Without provenance Details for deep_cross_attention-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deep-cross-attention 0.1.1
File Interpreter ABI Platform Actions
deep_cross_attention-0.1.1-py3-none-any.whl Python 3 none any Details for deep_cross_attention-0.1.1-py3-none-any.whl

Total release size: 14.0 kB

Release files / deep_cross_attention-0.1.1.tar.gz

Download URL deep_cross_attention-0.1.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
69b26a96168b28c7f59fce83c3d63d097f54df61cda623c789df169b3609cfb9
BLAKE2b-256 checksum
How to use checksums
fa38f01ac08faba268f6ae89699dbaa94b8c46fd0b43983001a63f7e00839dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / deep_cross_attention-0.1.1-py3-none-any.whl

Download URL deep_cross_attention-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74f9483a12ebe836386e69dc84a8b4abee8818defc246bb33ac920d13f05eb71
BLAKE2b-256 checksum
How to use checksums
9e7b32e9d5ba04915d10b2d8ac692047f350981fcd1cc9ca0cd63a1217beaebd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Security for deep-cross-attention 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page