An implementation of AlphaGenome in PyTorch.
Project description
AlphaGenome_PyTorch
Quick Start
From-Scratch
from alphagenome_pt import deepmind_model
model = deepmind_model()
Finetuned
Load the converted DeepMind state into a model. By default this downloads from Hugging Face cache if the state is not already local:
from alphagenome_pt import deepmind_model
model = deepmind_model(load_state=True)
Get Predictions/Embeddings
from alphagenome_pt import synthetic_batch
batch = synthetic_batch(model.metadata, batch_size=1, seq_len=model.max_seq_len)
predictions, embeddings = model(batch)
print(
embeddings.embeddings_1bp.shape,
embeddings.embeddings_128bp.shape,
embeddings.embeddings_pair.shape,
)
print(predictions.keys())
For finetuning with custom downstream heads, build custom metadata:
from alphagenome_pt import (
HeadName,
deepmind_model,
synthetic_batch,
synthetic_metadata,
)
metadata = synthetic_metadata(
heads=(HeadName.RNA_SEQ, HeadName.ATAC, HeadName.SPLICE_SITES_CLASSIFICATION),
num_organisms=2,
num_tracks=8,
)
# NOTE: can set heads=False to skip loading heads and/or organisms=False to skip loading organisms.
# They are prefix-loaded by default.
model = deepmind_model(
metadata=metadata.metadata,
load_state=True,
)
batch = synthetic_batch(metadata, batch_size=1, seq_len=8192)
loss, scalars, predictions = model.loss(batch)
loss.backward()
Metadata
Metadata defines organisms, output heads, track counts, masks, and track means. For examples and smoke tests, generate synthetic metadata:
from alphagenome_pt import HeadName, synthetic_metadata
metadata = synthetic_metadata(
heads=(HeadName.RNA_SEQ, HeadName.CONTACT_MAPS),
num_organisms=2,
num_tracks=8,
)
To use the converted official DeepMind metadata:
from alphagenome_pt import deepmind_metadata
metadata_dict = deepmind_metadata()
To download all converted metadata files and all checkpoint folds ahead of time:
alphagenome-pt-download --local-dir checkpoints
Docs
The docs directory contains information on environment setup, explanations of the data structure and model architecture, and example trainings. To train on your own data, it's strongly recommended to read the model.md and data.md markdown files in the */AlphaGenome_PyTorch/docs/guides directory so that you understand the structure of data batches and metadata.
Environment
See */AlphaGenome_PyTorch/docs/environment for instructions on how to set up a UV environment to run AlphaGenome_PyTorch.
Official JAX Checkpoint Conversion
Most users should download the converted PyTorch checkpoint files from Hugging Face:
alphagenome-pt-download --local-dir checkpoints
The package also includes optional JAX-to-PyTorch conversion tooling for recreating the PyTorch checkpoint from the official public JAX weights:
pip install "alphagenome-pt[jax2pt]"
python -m alphagenome_pt.jax2pt.convert_state
By default this converts every supported official checkpoint. To convert only one checkpoint, pass --fold all_folds, --fold fold_0, --fold fold_1, --fold fold_2, or --fold fold_3; outputs default to alphagenome_{fold_name}.pt.
The converter also requires the public alphagenome_research checkout used by the official loader:
git clone https://github.com/google-deepmind/alphagenome_research.git
pip install -e alphagenome_research
Guides
See */AlphaGenome_PyTorch/docs/guides for explanations on the AlphaGenome model and its data structure (very helpful for understanding examples).
Examples
See */AlphaGenome_PyTorch/docs/examples for examples of:
- Masked Language Modeling (MLM) training (
train_mlm.py) - Training on Downstream Tasks (RNA-Seq, CAGE, ATAC, Splice Sites Classification/Usage/Junction) (
train_downstream.py) - MLM Pretraining --> Training on Downstream Tasks (
train_downstream_from_pretrained.py)
Acknowledgements
This repository is a reimplementation of the AlphaGenome model in PyTorch, with an added option for Masked Language Modeling (MLM).
Within the alphagenome_pt directory, some components are direct ports of the released AlphaGenome code Link1 Link2 (licensed under Apache License 2.0), some are reimplementations based on pseudocode from the BioArXiV paper, and others are original additions (e.g., the MLM head). Attribution is made clear at the top of each file in the alphagenome_pt directory. The docs and tests directories are original work (with LLM coding assistance).
Developing this project used resources of the Oak Ridge Leadership Computing Facility, which is a DOE Office of Science User Facility supported under Contract DE-AC05-00OR22725.
Intended Audience
This intended audience of this repo is for those who might want to train the AlphaGenome architecture in PyTorch with maximal flexibility to hyperparameters and new organisms/contexts. You should be able to prepare a batch of tensor data and set up a train/val/test loop, but don't want the hassle of replicating the architecture.
Other Implementations
There is another AlphaGenome PyTorch implementation out here by Phillip Wang (a.k.a. LucidRains) which is quite good. The GitHub page is down as of March 2nd, 2026, but the PyPi package remains. The main advantages of that implementation (as of version 0.2.8) are in evaluation (loading the published weights and running variant scoring). The main advantage of this implementation is research training (an MLM head and track masks that can vary by batch in training). This implementation also has a .loss() function in the model to compute multi-resolution losses for you, and one head per task with dense weight tensor of shape [O, D, T] rather than separate weights tensors of shape [D, T] for each [organism x task], which is mathematically equivalent but more in-line with the original AlphaGenome implementation.
Reaching Out
Want a new feature or find a bug? Feel free to leave an issue on the GitHub repository.
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 alphagenome_pt-0.3.0.tar.gz.
File metadata
- Download URL: alphagenome_pt-0.3.0.tar.gz
- Upload date:
- Size: 62.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87e7a70b7c09a6bd2cbcec403faa6d21bfe6efcc12e47c47ce05312c1af04a3d
|
|
| MD5 |
6050ae6566d233e1bb141691c5b69c35
|
|
| BLAKE2b-256 |
6a79d8ed6e54a2e08057055ad47d17a36f7205f8740b67e9842f15bb88e5a4db
|
File details
Details for the file alphagenome_pt-0.3.0-py3-none-any.whl.
File metadata
- Download URL: alphagenome_pt-0.3.0-py3-none-any.whl
- Upload date:
- Size: 75.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50dd3e3c7453f8d0515d5fa0f07d8181c0c77e914a4e52a81afe8d90db322203
|
|
| MD5 |
0d303f82805eb023988acc6a0a4a4be4
|
|
| BLAKE2b-256 |
2a5989a5481c085bc06c89fdc8e59fd909a65bf641d69aa1932e08f462114088
|