What this is
RhoFold+ (Shen et al., Nature Methods 2024) is a deep-learning model that turns an RNA sequence into a 3D structure. Its install instructions cover Linux and say macOS is not supported. rhofold-mac is a small runner that sets it up on an Apple Silicon Mac and runs it on the GPU through PyTorch's MPS (Metal) backend. To our knowledge it is the first public Mac-friendly RhoFold+ runner.
It is not a re-implementation. The setup script fetches the official code at a fixed commit and the official weights from the authors' Hugging Face repo, then applies a short patch. The structures are RhoFold+'s.
Requirements
| Need | Detail |
|---|---|
| Mac | Apple Silicon, M1 or newer. Tested on an M4 MacBook with 16 GB. |
| macOS | 12.3 or newer (for MPS). Tested on 15.5. |
| Python | 3.10+. With uv installed, setup fetches Python 3.12 itself. |
| Disk | About 3 GB: 0.5 GB weights, 1.5 GB Python packages |
| Memory | 8 GB is fine for short RNAs. Peak was 1.9 GB at 52 nt and 10.7 GB at 387 nt. |
Quick start
Three commands. You need an Apple Silicon Mac on macOS 12.3 or newer, git, about 3 GB of disk and, ideally, uv (setup then fetches the right Python itself).
git clone https://github.com/vasanthsreeram/rhofold-mac.git
cd rhofold-mac
./setup.sh # once: packages + 508 MB weights, ends with a self-check
./run.sh # folds the bundled 52-nt sample on the Apple GPU- Set up once.
setup.shmakes a virtual environment with pinned packages, clones RhoFold at commit6bdfbda, applies the patch, downloads the weights with a checksum check, then runs a self-check that should end in "All good". From a fresh clone with an empty package cache it took 25 s on my connection. - Fold the sample. With no arguments,
./run.shfoldsexamples/sample.fasta, a 52-nucleotide RNA (chain A of PDB entry 6TB7, from RhoFold's own examples). It uses the Apple GPU automatically and falls back to the CPU if the GPU is not available. - Open the result. Everything lands in
out/sample/. Dragunrelaxed_model.pdbonto the Mol* viewer in a browser, or open it in PyMOL or ChimeraX. Per-residue confidence (pLDDT) is in the B-factor column.
On my M4 MacBook the first run prints:
RhoFold+ | sample.fasta | 52 nt | single-sequence | device=mps | fast=True
Model load 1.2 s | prediction 2.2 s | mean pLDDT 0.544
Wrote out/sample/unrelaxed_model.pdb (+ ss.ct, results.npz, run_info.json)
View it: drag out/sample/unrelaxed_model.pdb onto https://molstar.org/viewer, or open it in PyMOL / ChimeraX.
Total wall time (Python start-up + model load + prediction): 8 sThat first run took 8 s in total while macOS loaded the Python libraries; later runs took 4 s. For your own RNA, put one sequence in a FASTA file and run ./run.sh my_rna.fasta; results go to out/my_rna/. Add --device cpu to skip the GPU, or --a3m msa.a3m if you already have a multiple sequence alignment.
If something fails, ./doctor.sh checks the Mac (Apple Silicon, not Rosetta), Python, PyTorch and the GPU, the RhoFold code, and the weights' checksum, and says how to fix each problem. Common mistakes like DNA letters (T instead of U) or a damaged download get a plain error message.
How it works
Three things make it run well on a Mac:
- The Apple GPU through MPS. RhoFold+ is plain PyTorch, so it can run on the GPU with
device="mps". The runner picks MPS when it is available and falls back to the CPU otherwise. On the sample, CPU and GPU give the same mean pLDDT. - Single-sequence mode. Upstream builds an alignment by searching RNAcentral and NCBI nt with BLAST and Infernal, which needs hundreds of gigabytes of databases. The runner skips that and uses the sequence on its own, as upstream's
--single_seq_preddoes. That is what keeps the sample to a few seconds. It is usually less accurate than using an alignment, so pass one with--a3mif you have it. - A patch that removes repeated work. RhoFold+ runs its network 10 times (recycles). The patch embeds the sequence once instead of every recycle, runs the refinement network only on the last recycle (earlier outputs are never read), and splits one large matrix multiply in the refinement network so that long RNAs fit in GPU memory. These are exact rewrites: mean pLDDT is the same with the patch on and off for every RNA in the table below.
--officialturns the patch off.
Not included: Amber relaxation, which needs OpenMM. The output is the unrelaxed model, the same file upstream writes before relaxing.
Speed and memory
- 1.5 s52-nt RNA, forward pass on an M4 GPU, patched
- 1.9×faster than the official code on the same RNA
- 83 s387-nt RNA, which the official code did not finish
| RNA | Length | Official, MPS | Patched, MPS | Peak memory |
|---|---|---|---|---|
| 3MEI A | 23 nt | 1.19 s | 0.87 s | 1.9 GB |
| 6TB7 A (the sample) | 52 nt | 2.87 s | 1.50 s | 1.9 GB |
| 4L81 A | 96 nt | 7.57 s | 3.54 s | 2.7 GB |
| 4P8Z | 188 nt | 29.0 s | 16.3 s | 7.0 GB |
| 7EZ0 | 387 nt | did not finish | 83.4 s | 10.7 GB |
Measured on one Apple M4 MacBook with 16 GB, PyTorch 2.14.1. These time the network only (10 recycles, single-sequence), median of 5 runs after a warm-up, so they are a little below the quick-start "prediction" time, which is one cold run. Peak memory is for the patched run. The raw JSON files and the benchmark script are in the repo's benchmarks/ folder.
MLX (experimental)
The repo also has an experimental MLX port of RhoFold+'s main trunk (the 12 E2Eformer blocks), for comparing numbers and speed against PyTorch. It reads the PyTorch weights at run time; there are no converted MLX weights, and it does not produce structures.
It is off by default: setup.sh and run.sh use PyTorch only, and MLX is installed only with ./setup.sh --with-mlx. It also does not work yet. Its built-in check compares its output with the official PyTorch trunk on the same input, and the relative error was 0.27–0.65 on the RNAs I tried, so the port has a bug. Use the PyTorch MPS runner for predictions.
Limits
- Single-sequence mode by default. Accuracy is usually lower than with an alignment, and the runner does not build one for you.
- No Amber relaxation step.
- All numbers come from one M4 MacBook with 16 GB. Other chips will differ, and long RNAs need a Mac with enough memory (10+ GB at about 390 nt).
- This runs the published model. It does not change or re-evaluate RhoFold+'s accuracy.
Credits and licence
RhoFold+ is by Tao Shen, Zhihang Hu, Siqi Sun and colleagues; cite their Nature Methods paper if you use it. The code is Apache 2.0 at ml4bio/RhoFold and the weights are at cuhkaih/rhofold; the runner downloads both from there and redistributes neither. rhofold-mac is Apache 2.0. I wrote the runner, the patch and the benchmarks. Not affiliated with the RhoFold+ authors.