Views
No views yet
Synthyra/ESMFold2-Fast packages the biohub/ESMFold2-Fast checkpoint with
the FastPLMs runtime for Hugging Face Transformers. It accepts raw amino-acid
sequences or typed molecular-complex specifications; low-level forward accepts
prepared feature tensors.trust_remote_code=True. See Technical details for each registered class and
whether its weights come from the checkpoint.1python -m pip install -r \
2 "https://huggingface.co/Synthyra/ESMFold2-Fast/resolve/main/requirements.txt"trust_remote_code=True.1from transformers import AutoModel
2
3model_id = "Synthyra/ESMFold2-Fast"
4model = AutoModel.from_pretrained(
5 model_id,
6 trust_remote_code=True,
7 attn_implementation="sdpa",
8).eval()model_id with the manifest-built
dist/hub/ESMFold2-Fast path. Pass local_files_only=True.sdpa.eager, sdpa, flex_attention. Requesting an
unavailable backend raises instead of silently changing implementation.output_attentions=True can use the documented one-call eager fallback to
materialize attention tensors. The configured backend does not change.classifier. Sequence labels have shape (b,).
Residue labels have shape (b, l) and use -100 outside biological positions.
The folding trunk is skipped. The classifier uses the checkpoint's learned pLM
state mixture and projection, followed by one trainable transformer probe.1import torch
2from transformers import (
3 AutoModelForSequenceClassification,
4 AutoModelForTokenClassification,
5)
6
7model_id = "Synthyra/ESMFold2-Fast"
8sequence_model = AutoModelForSequenceClassification.from_pretrained(
9 model_id, num_labels=2, trust_remote_code=True
10).eval()
11token_model = AutoModelForTokenClassification.from_pretrained(
12 model_id, num_labels=3, trust_remote_code=True
13).eval()
14sequences = ["MSTNPKPQRKTKRNT", "MKTIIALSYIFCLVFA"]
15batch = sequence_model.prepare_classifier_inputs(sequences)
16biological = batch["attention_mask"].bool()
17
18sequence_labels = torch.zeros(len(sequences), dtype=torch.long)
19token_labels = torch.full_like(batch["input_ids"], -100)
20token_labels[biological] = 0
21
22with torch.inference_mode():
23 sequence_output = sequence_model(**batch, labels=sequence_labels)
24 token_output = token_model(**batch, labels=token_labels)
25print(sequence_output.logits.shape) # (b, 2)
26print(token_output.logits.shape) # (b, l, 3)python -m pip install "datasets>=4.8,<5" "peft>=0.19,<0.20"1from peft import LoraConfig, TaskType, get_peft_model
2
3peft_model = get_peft_model(
4 sequence_model,
5 LoraConfig(
6 task_type=TaskType.SEQ_CLS,
7 r=8,
8 lora_alpha=16,
9 target_modules="all-linear",
10 modules_to_save=["classifier"],
11 ),
12)classifier with the adapter.
All FastPLMs checkpoints follow the Transformers PreTrainedModel contract and
can use PEFT. The ESM2-specific shipped CLI is an example, not a
support boundary. Record the target modules, base revision, data identity, and
trainable parameter scope.ProteinInput.msa and low-level
MSA-derived features. Typed multichain and multimolecule inputs remain supported
when every protein chain uses msa=None. Use the full ESMFold2 checkpoint for
MSA-conditioned inference. This follows the official Biohub architecture
description in Appendix A.2.1.1result = model.fold_protein(
2 "MSTNPKPQRKTKRNT",
3 num_loops=1,
4 num_sampling_steps=200,
5 num_diffusion_samples=1,
6 seed=7,
7)
8pdb_text = model.result_to_pdb(result)
9cif_text = model.result_to_cif(result)
10print(result.ptm, result.plddt.mean().item())1types = model.input_types
2complex_input = types.StructurePredictionInput(
3 sequences=[
4 types.ProteinInput(id="A", sequence="MSTNPKPQRKTKRNT"),
5 types.ProteinInput(id="B", sequence="MKTIIALSYIFCLVFA"),
6 types.DNAInput(id="C", sequence="ATGC"),
7 types.LigandInput(id="L", smiles="O"),
8 ]
9)
10complex_result = model.fold(
11 complex_input,
12 num_loops=1,
13 num_sampling_steps=200,
14 seed=7,
15)
16print(complex_result.ptm, complex_result.plddt.mean().item())msa=None. The public schema recognizes PocketConditioning and
DistogramConditioning, but the pinned official forward consumes neither. Its
feature builder hard-codes a zero pocket feature and constructs distogram tensors
that the released model ignores. FastPLMs therefore rejects non-null pocket and
distogram conditioning instead of silently ignoring scientific inputs. Prepared
ref_pos values are component reference geometries created during featurization,
not target coordinates.
Predicted coordinates and confidence scores are outputs and do not establish
biochemical activity.H: (b, l, 81, 2560) -> Z: (b, l, 256). Retrieve Z through the public
embedding API:1representations = model.embed_dataset(
2 ["MSTNPKPQRKTKRNT", "MKTIIALSYIFCLVFA"],
3 batch_size=2,
4 full_embeddings=True,
5)
6print(representations[0].tensor.shape) # (sequence_length, 256)model.embed_dataset(..., full_embeddings=True) returns one (l, 256) residue
tensor per single-chain input. It rejects complexes, ligands, MSAs,
chain-separated inputs, cls, and parti in the embedding path.esmc_precision to auto, bf16, fp32, or fp8 when loading.
auto always resolves to BF16. Explicit FP8 is experimental, inference-only,
and strict:1model.reload_esmc(precision="fp8", device="cuda:0")
2print(model.esmc_precision_status)| Backend | Support | Measurement status |
|---|---|---|
sdpa | Recommended fidelity path | Pending release measurement |
eager | Supported | Pending release measurement |
flex_attention | Supported, numerically divergent | Pending release measurement |
ccd.pkl from
biohub/ESMFold2. The manifest pins its repository, revision, size, content
identity, and MIT terms. This is a trusted-deserialization boundary. FastPLMs
accepts only the pinned snapshot link inside the repository blob directory.
User-supplied asset and cache_dir symlinks are rejected. The loader verifies a
private temporary snapshot before deserialization, protecting against
path-replacement and in-place source-write races. Offline execution requires the
exact cached object and never downloads a replacement.1adapted = model.fold_protein_ttt(
2 "MSTNPKPQRKTKRNT",
3 num_loops=1,
4 num_sampling_steps=50,
5 seed=7,
6 ttt_config={"steps": 3, "batch_size": 1, "seed": 7},
7)
8print(adapted.ttt_metrics)save_pretrained adapter-persistence path.AutoConfig, AutoModel, AutoModelForSequenceClassification, AutoModelForTokenClassificationAutoConfig = FastPLMs extension, AutoModel = pretrained, AutoModelForSequenceClassification = base weights + untrained task head, AutoModelForTokenClassification = base weights + untrained task headeager, sdpa, flex_attentionauto, fp32, bf16, fp8 (experimental)fp32_parameters_autocastnot_applicablecore + structuretrueresolvedtruefalsemodels.toml. Built artifacts record exact source
identities and conversion details in source-record.json.Synthyra/ESMFold2-Fastsource-record.jsonbiohub/ESMFold2-Fastfastidentitybiohub-esm, biohub-transformers, protein-tttcheck, compliance, structure, feature, artifact, benchmark0compliance tier. Its evidence identifies the
checkpoint, backend, dtype, hardware, inputs, and reference revision.mit. The local artifact contains applicable source
licenses, notices, attribution, and conversion records. Review them before use.