Esmfold2 logo

Esmfold2

CommunityPopular
HughYau
esmfold2

Biohub ESMFold2 / ESMFold2-Fast all-atom co-folding (Candido et al. 2026, github.com/Biohub/esm). Single-sequence and MSA modes; protein, DNA, RNA, ligand (CCD/SMILES), modified residues. FoldBench Ab-Ag 50-55%, PPI 70-77% DockQ-pass. Also covers the ESMC-{300M,600M,6B} protein language models from the same release: masked-LM logits, hidden states, mutation scoring, contact prediction, and the SAE interpretability head. MIT-licensed weights on HuggingFace org `biohub`. Use this skill when: (1) Predicting complex structures with single-sequence input, (2) Validating designed binders with ESMFold2-Fast, (3) Running ESMFold2 with MSA input, (4) Getting ESMC embeddings or per-residue mutation scores, (5) Choosing kernel backend and sampling-step settings for paper-faithful throughput.

Overview

PublisherHughYau
RepositoryAcademicForge
Skill nameesmfold2
Stars
2.6K
Forks
152
Bundled files
2
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by HughYau on GitHub. Read the source before you install it.

Installation

Install the Esmfold2 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HughYau/AcademicForge.git /tmp/AcademicForge
mkdir -p .claude/skills
cp -r /tmp/AcademicForge/skills/claude-science/esmfold2 .claude/skills/esmfold2
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Esmfold2 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Esmfold2 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Esmfold2 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

ESMFold2 (Biohub)

All-atom diffusion co-folding from the Biohub ESM release (2026). ESMFold2 = 48 pair layers with MSA support; ESMFold2-Fast = 24 layers, single-sequence only, ~1.7x faster.

License: MIT (code github.com/Biohub/esm + weights HF biohub/*). Paper: "Language Modeling Materializes a World Model of Protein Biology" (2026).

Install

CUDA 12.x GPU (H100/A100-class); Python 3.12 only. Fresh venv; needs egress to HF Hub, GitHub, PyPI:

bash
pip install --no-cache-dir uv
uv venv --python 3.12 /work/venv && source /work/venv/bin/activate
uv pip install \
  "torch>=2.5,<2.8" einops "biotite>=1.0" rdkit msgpack-numpy biopython \
  scikit-learn brotli attrs pandas cloudpathlib httpx tenacity zstd pydssp \
  pygtrie accelerate huggingface_hub safetensors "numpy<3" networkx \
  sentencepiece tokenizers regex packaging filelock pyyaml typing_extensions \
  "transformers @ git+https://github.com/Biohub/transformers.git@3a8956fb4d4ea16b0ec8e71deef2c2909b6a5cbf"
uv pip install --no-deps "esm @ git+https://github.com/Biohub/esm.git@f652b471"
# OPTIONAL — only affects ESMC attention; trunk speedup comes from set_kernel_backend("fused")
uv pip install ninja packaging wheel setuptools
MAX_JOBS=8 uv pip install --no-deps --no-build-isolation "flash-attn<3"
# Do NOT install transformer-engine — RuntimeError (not ImportError) on import
# slips ESMC's guard and kills ESMFold2Model import.

The bundled esmfold2_gpu Modal env (remote-compute-modal skill) is the canonical, version-pinned recipe.

Gotchas:

  • Default kernel backend is None (reference PyTorch, ~12x slower than paper). Call model.set_kernel_backend('fused') after from_pretrained(). See section below.
  • Match torch CUDA build to your driver; the pin <2.8 targets CUDA 12.2.
  • Weights via Xet bridge ~300 MB/s: ESMFold2 1.36 GB, ESMFold2-Fast 0.76 GB. Set HF_HOME=/work/hf_cache.

Usage — local model

python
from esm.models.esmfold2 import (
    ESMFold2InputBuilder, StructurePredictionInput,
    ProteinInput, DNAInput, RNAInput, LigandInput, Modification,
)
from transformers.models.esmfold2.modeling_esmfold2 import ESMFold2Model

model = ESMFold2Model.from_pretrained("biohub/ESMFold2").cuda().eval()
# or "biohub/ESMFold2-Fast" (24 layers, no MSA, ~1.7x faster)
# or "biohub/ESMFold2-Experimental{,-Fast}{,-Cutoff2025}" (4 design-critic models)

spi = StructurePredictionInput(sequences=[
    ProteinInput(id="A", sequence=target_seq),
    ProteinInput(id="B", sequence=binder_seq),
    # DNAInput(id="C", sequence="ACGT", modifications=[Modification(position=5, ccd="C36")]),
    # RNAInput(id="D", sequence="ACGU"),
    # LigandInput(id="L", ccd=["SAH"]),  # or smiles="..."
])
# Homodimer: ProteinInput(id=["A","B"], sequence=seq)

results = ESMFold2InputBuilder().fold(
    model, spi,
    num_loops=10,             # paper FoldBench eval: 10; 20-loop variant: 20
    num_sampling_steps=68,    # paper eval: 68 (truncated EDM)
    num_diffusion_samples=5,  # paper eval: 5/seed
    seed=0,
)
# fold() returns list[Prediction], one per diffusion sample. Each carries
# .plddt [L], .ptm, .iptm, .pae [L,L], .pair_chains_iptm, .complex.to_mmcif().
# Rank by ipTM for complexes / mean pLDDT for monomers:
best = max(results, key=lambda r: float(r.iptm if r.iptm is not None
                                        else r.plddt.mean()))
open("pred.cif", "w").write(best.complex.to_mmcif())

Paper-faithful FoldBench settings: 10 loops, 68 sampling steps, 25 seeds x 5 diffusion samples; rank by ipTM (complexes) or pLDDT (monomers); MSA mode adds msa_depth=1024 with 10% column masking and ESMC dropout 0.3.

Model variants on HF biohub/

reposizepair layersMSAuse
ESMFold20.94 GB + ccd.pkl 0.42 GB48yesfull eval
ESMFold2-Fast0.76 GB24nofast single-seq
ESMFold2-Experimental{,-Fast}0.90 / 0.72 GB48 / 24design search (Alg 11)
ESMFold2-Experimental{,-Fast}-Cutoff20250.90 / 0.72 GBdesign search + critic
ESMFold2-Experimental-Fast-base{300M,600M,6B}-step{250k..1500k}15 critic ensemble

Throughput: set_kernel_backend("fused") is REQUIRED

Default is the slow path. ESMFold2Model.from_pretrained(...) loads with _kernel_backend=None (reference PyTorch) and chunk_size=64. You MUST call:

python
model = ESMFold2Model.from_pretrained("biohub/ESMFold2").cuda().eval()
model.set_kernel_backend("fused")   # vendored Triton TriMul/LN+SwiGLU/pair-bias kernels
model.set_chunk_size(None)           # optimal & OOM-safe L<=1024; use 256 above

"fused" gives ~1.5–6× trunk speedup over the reference backend, growing with L; end-to-end fold() is diffusion-bound at short L so fused breaks even around L≈300–400. Fused vs reference outputs are numerically consistent (pLDDT within noise). "fused" (Triton, bundled with the GPU torch wheel) is inference-only — auto-disables under backprop. Above ~L=1400 (chunk_size=128) it hits illegal memory access — fall back to set_kernel_backend(None) + set_chunk_size(64); validated through L=1024.

Do NOT use set_kernel_backend("cuequivariance"): the cuequivariance-torch==0.10.0 wheel lacks the compiled ops and silently falls back to the reference path. apply_torch_compile() is an alternative (NOT additive — call set_kernel_backend(None) first).

ESMFold2-Experimental* — design hook

Experimental variants expose res_type_soft for gradient-guided design — see references/design-hook.md. Do NOT use the fused backend with them (fp32/bf16 dtype crash; the reference path is correct).

Gotcha: cusolver SVD poison + structseq constructor

The Kabsch alignment in modeling_esmfold2_common.py calls torch.linalg.svd(H32, driver="gesvd") on batched 3x3 matrices. NaN/Inf inputs (degenerate diffusion samples) corrupt the cusolver workspace — all subsequent CUDA calls fail with "illegal memory access". Monkeypatch: redirect small batched SVDs to CPU:

python
_orig_svd = torch.linalg.svd
def _safe_svd(A, full_matrices=True, driver=None):
    if A.is_cuda and A.shape[-1] <= 4 and A.shape[-2] <= 4:
        Acpu = A.detach().float().cpu()
        if not torch.isfinite(Acpu).all():
            Acpu = torch.nan_to_num(Acpu, nan=0.0, posinf=1e6, neginf=-1e6)
        out = _orig_svd(Acpu, full_matrices=full_matrices)
        # torch.return_types.linalg_svd is a C structseq -> ctor takes ONE tuple.
        return type(out)(tuple(t.to(A.device, A.dtype) for t in out))
    return _orig_svd(A, full_matrices=full_matrices, driver=driver)
torch.linalg.svd = _safe_svd

Note type(out)(tuple(...)), not type(out)(*(...))torch.return_types.* are C structseqs whose constructor takes a single tuple argument.

With-MSA mode

ESMFold2 supports per-chain MSA input via ProteinInput(id, sequence, msa=MSA). The MSA object lives at esm.utils.msa.msa.MSA:

python
from esm.utils.msa.msa import MSA
# ProteinInput, StructurePredictionInput as imported above

msa_A = MSA.from_a3m("/path/chain_A.a3m", max_sequences=2048)
msa_B = MSA.from_a3m("/path/chain_B.a3m", max_sequences=2048)
inp = StructurePredictionInput(sequences=[
    ProteinInput(id="A", sequence=seq_A, msa=msa_A),
    ProteinInput(id="B", sequence=seq_B, msa=msa_B),
])

Gotchas:

  • MSA.from_a3m(remove_insertions=True) asserts equal row lengths after insertion removal. ColabFold a3m files often carry trailing null bytes and off-by-one rows vs the query — tr -d '\000' and force row 0 to the exact query sequence (or MSA.from_sequences on manually cleaned, query-length rows).
  • ESMFold2-Fast does NOT support MSA (single-seq only).
  • With-MSA mode improves AbAg interface pass-rate per the paper's evaluation.

Paper-matched inference configuration

The paper's FoldBench protocol (section A.2.11):

ParameterPaper defaultPaper "20lp"Notes
num_loops (folding-trunk recycles)1020+2pp on AbAg
num_sampling_steps (diffusion)6868EDM-tuned; do NOT use 200
seeds x diffusion samples25 x 525 x 5Fig S6/S7 oracle = best-of-125

Training data cutoff

ESMFold2 and ESMFold2-Fast both use a Sept 2021 PDB training cutoff (HF biohub/ESMFold2 README).

ESMC language model

ESMC is the Biohub successor to ESM-2; three sizes: 300M (30L), 600M (36L), 6B (80L, d=2560). HF path: AutoModelForMaskedLM.from_pretrained("biohub/ESMC-6B").

Mask token is <mask> (id 32) — use tok.mask_token. The native-SDK _ convention does NOT apply to the HF tokenizer: _ is not in the vocab and encodes to <unk>, silently corrupting mutation scores.

Full API, mutation scoring, SAE features, contact prediction: see references/esmc.md.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Esmfold2 AI skill do?

Biohub ESMFold2 / ESMFold2-Fast all-atom co-folding (Candido et al. 2026, github.com/Biohub/esm). Single-sequence and MSA modes; protein, DNA, RNA, ligand (CCD/SMILES), modified residues. FoldBench Ab-Ag 50-55%, PPI 70-77% DockQ-pass. Also covers the ESMC-{300M,600M,6B} protein language models from the same release: masked-LM logits, hidden states, mutation scoring, contact prediction, and the SAE interpretability head. MIT-licensed weights on HuggingFace org `biohub`. Use this skill when: (1) Predicting complex structures with single-sequence input, (2) Validating designed binders with ESM...

Why use Esmfold2 on TypingMind?

Because you install it once and use it with any model. Esmfold2 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Esmfold2 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HughYau/AcademicForge/tree/site-first/skills/claude-science/esmfold2. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Esmfold2?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Esmfold2?

As many as you like. As long as a model supports skills, you can use Esmfold2 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Esmfold2 AI skill free?

Yes. It is published on GitHub by HughYau under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇