/alphagenome:alphagenome-finetuningfrom alphagenome
Fine-tune AlphaGenome-PyTorch on custom genomic data: linear probe, LoRA, Locon, or full. Uses BigWig tracks, adapters, and multi-GPU parallelism.
Ships in alphagenome. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fine-tuning reuses the pretrained trunk as a sequence-representation extractor and trains new heads (plus optionally adapters) on your tracks. The workflow is always: load trunk → choose transfer mode → add heads for your tracks → train.
agt finetune is the supported entry point; it covers every mode below and takes CLI
flags or a YAML config (--config, CLI overrides YAML). Run agt finetune --help for
the authoritative flag list.
agt finetune≡python scripts/finetune.py. They are the same code path with the same flags;agt finetune --mode lora ...andpython scripts/finetune.py --mode lora ...are interchangeable. Preferagt— it ships with the installed package, whereasscripts/only exists in a repo clone. The script remains as a thin shim, so older commands and configs keep working.
--mode, default lora)| Mode | Trains | Use when |
|---|---|---|
linear-probe | heads only, trunk frozen | fastest; strong baseline; start here to sanity-check the data |
lora | heads + LoRA on attention projections | recommended default for most tasks |
locon | heads + Locon on Conv1d layers | the convolutional tower needs adapting (e.g. new assay statistics) |
lora+locon | both adapter families | attention and conv tower need adapting |
full | all parameters | large target dataset, willing to pay compute + risk of forgetting |
encoder-only | encoder path only | specialised; see docs |
Escalate only if the cheaper mode underfits: linear-probe → lora → lora+locon / full.
agt finetune --mode lora \
--genome hg38.fa \
--modality atac --bigwig data/*.bw \
--train-bed train.bed --val-bed val.bed \
--pretrained-weights model.pth
Inputs: a genome FASTA, one or more BigWig signal tracks, train/val BED interval
files, and the pretrained checkpoint. No flag is strictly required at the argparse
level because any of them may come from --config; missing inputs fail at runtime
(e.g. --bigwig is required (or provide modalities in --config)).
Requires the finetuning extra: pip install 'alphagenome-pytorch[finetuning]'.
--modality)rna_seq, atac, dnase, procap, cage support 1bp and 128bp.
chip_tf, chip_histone are 128bp only.
Repeat --modality/--bigwig in pairs for multi-modality training.
--resolutions defaults to 1 (1bp only) — set --resolutions 128 for
chip_tf/chip_histone, which have no 1bp output.
LoRA: --lora-rank 8, --lora-alpha 16, --lora-targets q_proj,v_proj.
Locon: --locon-rank 4, --locon-alpha 1, --locon-targets empty by default —
you must set it when Locon is enabled, e.g. down_blocks.5 (last conv block) or
down_blocks.4,down_blocks.5 (last two).
Training: --epochs 10, --batch-size 1, --lr 1e-4, --weight-decay 0.1,
--warmup-steps 500, --lr-schedule cosine, --sequence-length 131072,
--output-dir finetuning_output.
What a run writes. Output goes to <output-dir>/<run-name>, defaulting to
finetuning_output/<timestamp>. A default run produces best_model.pth (on val
improvement), checkpoint_epoch{N}.pth (every epoch — --save-every defaults to
1), plus config.json, training_log.csv, epoch_log.csv. --save-delta is
off by default, so a default run yields nothing shareable — agt adapters export needs a delta and rejects best_model.pth. No transfer_config.json is
written; the config is embedded in each checkpoint.
--no-full-checkpoint (deltas only, requires --save-delta) and
--no-save-checkpoints (no weights at all, logs only) sound alike but differ:
the first picks a format, the second turns saving off.
Loading: one file or two? Full checkpoints and full exports are
self-contained (agt predict --checkpoint X). Delta checkpoints, exported
deltas and adapter bundles hold only the difference from a base model and need
it too (agt predict --model base.pth --checkpoint X). agt info <file> reports
which you have; in Python, describe_checkpoint(path) returns .kind and
.requires_base_weights. Full reference:
https://alphagenome-pytorch.readthedocs.io/en/latest/finetuning/checkpoints.html
Delta checkpoints (adapters + heads only, ~5–10MB vs ~1GB):
--save-delta [--no-full-checkpoint]
Works with every mode except full (which trains all parameters).
Saving or exporting an adapter (--save-delta, export_delta_weights, or
agt adapters export for a shareable bundle) works only from delta
weights/checkpoints — merged adapters or a full-model fine-tune have no adapter
weights to extract.
Multi-GPU — DDP, or sequence parallelism to split one long sequence across GPUs.
torchrun needs a module or script target, so use -m:
torchrun --nproc_per_node=2 -m alphagenome_pytorch.cli finetune \
--sequence-parallel --overlap-highres 1024 ...
There is no --overlap-lowres flag; the low-res overlap is computed as
overlap_highres // 128.
Memory pressure: --gradient-checkpointing, --gradient-accumulation-steps,
--batch-size 1, --dtype/--no-amp.
Tracking: --wandb (--wandb-project, default alphagenome-finetune).
Gene-level RNA-seq — two independent features, both off by default:
# Cross-track gene LFC loss over gene bodies (paper weight: 0.1)
--gene-loss-weight 0.1 --gene-cross-track-weight 5.0 \
--gtf gencode.v46.annotation.gtf --track-strands '+-'
# Exon-based gene-expression correlations, reported each validation epoch
--gene-expr-eval --gene-expr-annotation gencode.v46.parquet --track-strands '+-'
The loss aggregates over gene bodies (exons + introns) and needs --gtf,
rna_seq in --modality, and --track-strands. Leaving --gene-loss-weight at
0.0 keeps loss values bit-identical to a run without it.
The eval metric aggregates over annotated exons (log mean coverage,
strand-matched, genes with ≥50% of exons in-window) and emits
rna_seq_gene_log_expr_pearson_{across_genes,across_genes_norm,across_tracks_norm}
plus rna_seq_gene_log_expr_n_genes. It needs an annotation that actually
contains exon rows, so a gene-only --gtf is not enough on its own.
Both --gtf and --gene-expr-annotation accept parquet or GTF/GFF. Convert
once (python scripts/convert_gtf_to_parquet.py --input x.gtf --output x.parquet) and point --gtf at the parquet: it loads in seconds instead of
minutes on every run's startup path, and since the converter keeps every
feature, that single file drives both the gene-body masks and the exon metric.
Preparing BigWig data (agt preprocess) — optional prep before training:
# Normalize signal depth across tracks to a common total (e.g. 100M)
agt preprocess scale-bigwig --input *.bw --output scaled/ --target 100M
# (add --dry-run to just print the scale factor)
# Convert BigWigs to a memory-mapped format for faster training I/O
agt preprocess bigwig-to-mmap --input *.bw --output mmap/ --chromosomes chr1 chr2
Training reads .bw directly, so this is only for depth normalization or I/O speed.
from alphagenome_pytorch import (
AlphaGenome, TransferConfig, load_trunk, prepare_for_transfer,
)
model = AlphaGenome()
model = load_trunk(model, "model.pth") # trunk only, excludes heads
model = prepare_for_transfer(model, TransferConfig(
mode="lora",
new_heads={"atac": {"modality": "atac", "num_tracks": 1}},
lora_rank=8,
))
Re-exported from alphagenome_pytorch.extensions.finetuning: TransferConfig,
MODALITY_CONFIGS, LoRA, Locon, IA3, train_epoch, validate,
save_checkpoint, export_delta_weights, and datasets (ATACDataset,
RNASeqDataset, MultimodalDataset, CachedGenome).
Don't guess flags or API shapes — these are authoritative and current:
If working inside a clone of the repo, the same pages are docs/finetuning/*.rst.
agt finetune --help is the ground truth for flags.
To run predictions with a pretrained or finetuned model instead, see the
alphagenome-predictions skill. To score variants, see agt score --help.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 skills in this plugin
npx claudepluginhub genomicsxai/alphagenome-pytorch --plugin alphagenomeOther plugins' skills for the same job