sbol-torch
A PyTorch library for synthetic biology and biodesign automation.
Installed as sbol-torch, imported as sboltorch (commonly import sboltorch as st).
sbol-torch pulls designs from a running sbol-db instance (or local SBOL/FASTA files), normalizes them into a single record type, and trains transformer models against them. The input modality, tokenizer, and training objective are all set in configuration, so trying a new combination never means forking the pipeline.
Capabilities
| Axis | Options |
|---|---|
| Data sources | sbol-db REST API, local SBOL/FASTA files, or a synthetic generator; loaded in-memory or streamed from sharded Parquet for corpora larger than RAM |
| Tokenizers | pretrained HuggingFace (hf), overlapping k-mer, or IUPAC character (encode + decode) |
| Modalities | sequence, structure_aware (feature boundaries), graph (PyG composition transformer) |
| Objectives | supervised / frozen heads, mlm and causal pretraining (from-scratch or continued) |
| Architectures | from-scratch or pretrained; absolute or RoPE positions (gpt_neox/llama/modernbert), SDPA/FlashAttention, configurable context length |
| Generation | autoregressive sampling (temperature / top-k / top-p) and design completion from a causal backbone (sboltorch generate) |
| Engine | raw-PyTorch loop, epoch- or step-budgeted; AMP (fp16/bf16), gradient accumulation/clipping, gradient checkpointing, torch.compile; resumable checkpoints; early stopping; LR schedule |
| Scaling | token packing, multi-GPU DDP (data-parallel) via torchrun |
| Tracking | per-epoch metrics.jsonl, optional Weights & Biases (scalars, config, lineage, model artifact) |
| Reproducibility | one validated config per run, seeded / hash splits, content-fingerprinted sharded Parquet cache, resumable runs |
Install
pip install sbol-torch
For development:
uv venv
uv pip install -e '.[dev]'
Quickstart
A run is fully specified by one YAML config. From the command line:
# Materialize a corpus to the local Parquet cache (offline, reproducible).
sboltorch ingest examples/configs/finetune_expression.yaml
# Train. Resolved config, per-epoch metrics.jsonl, and best.pt land in output_dir.
sboltorch train examples/configs/finetune_expression.yaml
# Resume an interrupted run from its rolling checkpoint (needs checkpoint_every_n_steps).
sboltorch train examples/configs/pretrain_mlm.yaml --resume runs/pretrain_mlm/last.pt
# Generate from a trained causal backbone — point model.backbone at the run's
# backbone/ (with from_scratch: false), then complete a design from a prompt.
sboltorch generate my_causal_run.yaml --prompt ATGCGT --max-new-tokens 200 --temperature 0.8
Train multi-GPU with torchrun and train.distributed.strategy: ddp:
torchrun --nproc_per_node=<gpus> -m sboltorch.cli train examples/configs/pretrain_causal_long.yaml
Or from Python:
import sboltorch as st
config = st.RunConfig.from_yaml("examples/configs/train_graph.yaml")
metrics = st.run_training(config)
Example configs
| Config | What it does |
|---|---|
finetune_expression.yaml |
Frozen DNABERT-2 backbone feeding a regression head. |
pretrain_mlm.yaml |
From-scratch masked-LM pretraining; writes a reusable backbone. |
finetune_structure_aware.yaml |
Sequence + feature-boundary markers. |
train_graph.yaml |
Graph transformer over the composition graph. |
pretrain_causal_long.yaml |
Long-context causal pretraining: RoPE decoder, SDPA, streamed + packed corpus. |
Experiment tracking
The two synthetic-data configs (train_graph.yaml
and finetune_structure_aware.yaml)
ship with Weights & Biases enabled. Set WANDB_API_KEY
in a .env at the repo root and run both:
python examples/run_wandb_examples.py
Each run logs per-step loss and learning rate, per-epoch train/val metrics, the resolved config, the corpus fingerprint and split sizes as lineage, and the best checkpoint as a model artifact.
| Graph transformer | Structure-aware sequence |
|---|---|
Documentation
| Doc | Contents |
|---|---|
| architecture.md | How the system is built — record type, plug points, engine, data flow. |
| capabilities.md | Modalities, objectives, tokenizers, metrics. |
| configuration.md | Complete RunConfig reference. |
| data.md | Data sources, the sbol-db client, materialization, fixtures. |
| backbones.md | Choosing/loading backbones and environment constraints. |
| extending.md | Adding a tokenizer, encoder, task, callback, or data source. |
Release history is in CHANGELOG.md.
Develop
uv run pytest
pre-commit run --all-files
Metadata
Release files for sbol-torch 0.1.1
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 |
|---|---|---|---|---|
| sbol_torch-0.1.1.tar.gz | 553.2 kB | Without provenance | Details for sbol_torch-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sbol_torch-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for sbol_torch-0.1.1-py3-none-any.whl |
Total release size: 625.3 kB
Release files / sbol_torch-0.1.1.tar.gz
| Download URL | sbol_torch-0.1.1.tar.gz |
|---|---|
| Size | 553.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eccbbb27205a67118af67b86d33cf5bbbb6731fb5329463757282857618893f5
|
|
BLAKE2b-256 checksum How to use checksums |
ab1b2de1e43fff33254f5f9f16bfa4368005a240da568dabfdce6331173e23bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.7
|
Release files / sbol_torch-0.1.1-py3-none-any.whl
| Download URL | sbol_torch-0.1.1-py3-none-any.whl |
|---|---|
| Size | 72.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fcc116a5bea002b97d4104fd9a037886fc6cbf99460318e7e7e230e3c27969e
|
|
BLAKE2b-256 checksum How to use checksums |
36c104111efc979315173ec2237dfe46f4f8c80977e0eb43b507fe1a7d618541
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.7
|
Security for sbol-torch 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.