Skip to main content

Run ARC Institute's Evo 2 DNA language model on Apple Silicon (Metal GPU)

Project description

evo2-metal

Run ARC Institute's Evo 2 DNA language model on Apple Silicon (Metal GPU) — no CUDA required.

Evo 2 is a 7B–40B parameter genomic foundation model trained on 9.3 trillion DNA tokens. This package makes the 7B models fully usable on a Mac with M-series chips.

How it works

Evo 2 depends on flash-attn, which requires NVIDIA CUDA and does not run on Mac. This package provides:

  • A FlashAttention v2 kernel written in Metal Shading Language (Apple's GPU compute API), dispatched via PyObjC.
  • A set of monkey-patches applied before importing evo2 that redirect all CUDA-dependent calls to CPU/Metal equivalents — without modifying the original Evo 2 source code.
import evo2_metal   ←  patches flash_attn, vortex, and evo2.scoring
from evo2 import Evo2

Installation

Requires: macOS with Apple Silicon (M1/M2/M3/M4/M5), Python 3.11 or 3.12.

# 1. Create a Python 3.12 environment (evo2 requires <3.13)
conda create -n evo2-mac python=3.12
conda activate evo2-mac

# 2. Install PyTorch (CPU build for Mac)
pip install torch --index-url https://download.pytorch.org/whl/cpu

# 3. Install evo2-metal (PyPI)
pip install evo2-metal

# Alternative: install directly from GitHub
# pip install git+https://github.com/lemonardo1/evo2-metal.git

Usage

Sequence scoring

import evo2_metal          # must be first
from evo2 import Evo2

model = Evo2('evo2_7b_base')

scores = model.score_sequences([
    "ATGAAAGCAATTTTCGTACTGAAAGGTTCAGGT",   # wildtype
    "ATGAAAGCAATTTTCGTACTGAAAGGTTCAGGA",   # variant
])
print(scores)  # [np.float32(-1.27), np.float32(-1.43)]

DNA sequence generation

import evo2_metal
from evo2 import Evo2

model = Evo2('evo2_7b_base')

output = model.generate(
    prompt_seqs=["ATGAAAGCAATTTTCGTACTGAAAGGTTCAGGT"],
    n_tokens=200,
    temperature=1.0,
    top_k=4,
)
print(output.sequences[0])

Supported models

Model Parameters Context Supported
evo2_7b_base 7B 8K
evo2_7b 7B 1M
evo2_7b_262k 7B 262K
evo2_7b_microviridae 7B 8K
evo2_1b_base 1B 8K ❌ (requires FP8/Transformer Engine)
evo2_40b / evo2_20b 40B / 20B 1M ❌ (requires multi-GPU)

Patches applied

Patch Reason
torch.cuda.device → no-op for cpu StripedHyena.__init__ calls torch.cuda.device("cpu")
torch.cuda.memory_allocated → returns 0 Called in generation loop for logging
flash_attn_2_cuda → mocked Not available on Mac
FlashSelfAttention.forward → Metal backend assert qkv.is_cuda fails on CPU
FlashCrossAttention.forward → Metal backend Same
local_flash_attn_with_kvcache → PyTorch SDPA KV-cache path during token generation
vortex.generation.generatedevice='cpu' Default was 'cuda:0'
evo2.scoring.prepare_batchdevice='cpu' Default was 'cuda:0'

Verified on

  • Apple M5 Max, macOS 15 (Sequoia)
  • Python 3.12, PyTorch 2.11, evo2 0.5.3

License

Apache 2.0 — see LICENSE.

Evo 2 model weights are released under their own license by ARC Institute. See the Evo 2 repository for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evo2_metal-0.1.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evo2_metal-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file evo2_metal-0.1.0.tar.gz.

File metadata

  • Download URL: evo2_metal-0.1.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for evo2_metal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a6a54f23466400dd5b122c6374d2288cfd1a61616ce805034e34e1c3d1e7c52
MD5 b3509214559f0e65edc61b8c9e7a09c8
BLAKE2b-256 fc63888a85ed1a61a7dec785363e43de155a3638599918e03575bfa0fe179555

See more details on using hashes here.

File details

Details for the file evo2_metal-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: evo2_metal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for evo2_metal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a329882b31efca523ef7fd59502f76da0f4817e1ecd70f27a7c7ef40d1f527f
MD5 d4a6681262eff65ce89759173c43ec6a
BLAKE2b-256 56947fcab44dbefb714739ae4b4ee9077d5149ad367e03467053e4a1d1dfa04a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page