Skip to content

Commit 4c3c852

Browse files
authored
Feat: Add sparse autoencoder demo notebook (#175)
* Add SAE notebook and improve documentation * nit: fix readme spacing
1 parent 29cae0f commit 4c3c852

File tree

3 files changed

+198336
-25
lines changed

3 files changed

+198336
-25
lines changed

README.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ We describe Evo 2 in the preprint:
1313
- [Requirements](#requirements)
1414
- [Installation](#installation)
1515
- [Docker](#docker)
16-
- [Checkpoints](#checkpoints)
1716
- [Usage](#usage)
17+
- [Checkpoints](#checkpoints)
1818
- [Forward](#forward)
1919
- [Embeddings](#embeddings)
2020
- [Generation](#generation)
21-
- [Notebooks](#notebooks)
22-
- [Nvidia NIM](#nvidia-nim)
21+
- [Notebooks](#notebooks)
22+
- [Nvidia NIM](#nvidia-nim)
2323
- [Dataset](#dataset)
2424
- [Training and Finetuning](#training-and-finetuning)
2525
- [Citation](#citation)
@@ -41,13 +41,15 @@ Evo 2 is built on the Vortex inference repo, see the [Vortex github](https://git
4141

4242
**System requirements**
4343
- [OS] Linux (official) or WSL2 (limited support)
44-
- [GPU] Requires Compute Capability 8.9+ (Ada/Hopper/Blackwell) due to FP8 being required
44+
- [GPU] Requires Compute Capability 8.9+ (Ada/Hopper) for FP8 support
4545
- [Software]
46-
- CUDA: 12.1+ (12.8+ for Blackwell) with compatible NVIDIA drivers
46+
- CUDA: 12.1+ with compatible NVIDIA drivers
4747
- cuDNN: 9.3+
4848
- Compiler: GCC 9+ or Clang 10+ with C++17 support
4949
- Python 3.12 required
50-
50+
51+
**FP8 requirements:** The 40B and 1B models require FP8 for numerical accuracy, and low accuracy has been reported on Blackwell hardware or without FP8. The 7B models can run without FP8 by modifying the config. Always validate model outputs after configuration changes or on different hardware by using the tests.
52+
5153
Check respective githubs for more details about [Transformer Engine](https://github.com/NVIDIA/TransformerEngine) and [Flash Attention](https://github.com/Dao-AILab/flash-attention/tree/main) and how to install them.
5254
We recommend using conda to easily install Transformer Engine. Here is an example of how to install the prerequisites:
5355
```bash
@@ -78,6 +80,11 @@ To verify that the installation was correct:
7880
python -m evo2.test.test_evo2_generation --model_name evo2_7b
7981
```
8082

83+
For the 40b model:
84+
```
85+
python -m evo2.test.test_evo2_generation --model_name evo2_40b
86+
```
87+
8188
### Docker
8289

8390
Evo 2 can be run using Docker (shown below), Singularity, or Apptainer.
@@ -94,24 +101,20 @@ Once inside the container:
94101
python -m evo2.test.test_evo2_generation --model_name evo2_7b
95102
```
96103

97-
## Checkpoints
104+
## Usage
105+
106+
### Checkpoints
98107

99108
We provide the following model checkpoints, hosted on [HuggingFace](https://huggingface.co/arcinstitute):
100109
| Checkpoint Name | Description |
101110
|----------------------------------------|-------------|
102-
| `evo2_40b` | A model pretrained with 1 million context obtained through context extension of `evo2_40b_base`.|
103-
| `evo2_7b` | A model pretrained with 1 million context obtained through context extension of `evo2_7b_base`.|
104-
| `evo2_40b_base` | A model pretrained with 8192 context length.|
105-
| `evo2_7b_base` | A model pretrained with 8192 context length.|
106-
| `evo2_1b_base` | A smaller model pretrained with 8192 context length.|
111+
| `evo2_7b` | 7B parameter model with 1M context |
112+
| `evo2_40b` | 40B parameter model with 1M context (requires multiple GPUs) |
113+
| `evo2_7b_base` | 7B parameter model with 8K context |
114+
| `evo2_40b_base` | 40B parameter model with 8K context |
115+
| `evo2_1b_base` | Smaller 1B parameter model with 8K context |
107116

108-
To use Evo 2 40B, you will need multiple GPUs. Vortex automatically handles device placement, splitting the model across available cuda devices.
109-
110-
Note that the 7B checkpoints can be run without FP8, thus avoiding the compute capability requirement. This can be done by modifying the configs to turn off FP8 and is not officially supported as there are numerical differences.
111-
112-
## Usage
113-
114-
Below are simple examples of how to download Evo 2 and use it locally in Python.
117+
**Note:** The 40B model requires multiple GPUs. Vortex automatically handles device placement, splitting the model across available CUDA devices.
115118

116119
### Forward
117120

@@ -173,19 +176,28 @@ output = evo2_model.generate(prompt_seqs=["ACGT"], n_tokens=400, temperature=1.0
173176
print(output.sequences[0])
174177
```
175178

176-
### Notebooks
179+
## Notebooks
177180

178181
We provide example notebooks.
179182

180-
The [BRCA1 notebook](https://github.com/ArcInstitute/evo2/blob/main/notebooks/brca1/brca1_zero_shot_vep.ipynb) shows zero-shot *BRCA1* variant effect prediction. This example includes a walkthrough of:
183+
The [BRCA1 scoring notebook](https://github.com/ArcInstitute/evo2/blob/main/notebooks/brca1/brca1_zero_shot_vep.ipynb) shows zero-shot *BRCA1* variant effect prediction. This example includes a walkthrough of:
181184
- Performing zero-shot *BRCA1* variant effect predictions using Evo 2
182185
- Reference vs alternative allele normalization
183186

184187
The [generation notebook](https://github.com/ArcInstitute/evo2/blob/main/notebooks/generation/generation_notebook.ipynb) shows DNA sequence completion with Evo 2. This example shows:
185188
- DNA prompt based generation and 'DNA autocompletion'
186189
- How to get and prompt using phylogenetic species tags for generation
187190

188-
### Nvidia NIM
191+
The [exon classifier notebook](https://github.com/ArcInstitute/evo2/blob/main/notebooks/exon_classifier/exon_classifier.ipynb) demonstrates exon classification using Evo 2 embeddings. This example shows:
192+
- Running the Evo 2 based exon classifier
193+
- Performance metrics and visualization
194+
195+
The [sparse autoencoder (SAE) notebook](https://github.com/ArcInstitute/evo2/blob/main/notebooks/sparse_autoencoder/sparse_autoencoder.ipynb) explores interpretable features learned by Evo 2. This example includes:
196+
- Running and visualizing Evo 2 SAE features
197+
- Demonstrating SAE features on a part of the *E. coli* genome
198+
199+
200+
## Nvidia NIM
189201

190202
Evo 2 is available on [Nvidia NIM](https://catalog.ngc.nvidia.com/containers?filters=&orderBy=scoreDESC&query=evo2&page=&pageSize=) and [hosted API](https://build.nvidia.com/arc/evo2-40b).
191203

@@ -227,13 +239,13 @@ else:
227239

228240
### Very long sequences
229241

230-
You can use [Savanna](https://github.com/Zymrael/savanna) or [Nvidia BioNemo](https://github.com/NVIDIA/bionemo-framework) for embedding long sequences. Vortex can currently compute over very long sequences via teacher prompting, however please note that forward pass on long sequences may currently be slow.
242+
You can use [Savanna](https://github.com/Zymrael/savanna) or [Nvidia BioNemo](https://github.com/NVIDIA/bionemo-framework) for embedding long sequences. Vortex can currently compute over very long sequences via teacher prompting, however please note that forward pass on long sequences may currently be slow.
231243

232-
### Dataset
244+
## Dataset
233245

234246
The OpenGenome2 dataset used for pretraining Evo2 is available on [HuggingFace ](https://huggingface.co/datasets/arcinstitute/opengenome2). Data is available either as raw fastas or as JSONL files which include preprocessing and data augmentation.
235247

236-
### Training and Finetuning
248+
## Training and Finetuning
237249

238250
Evo 2 was trained using [Savanna](https://github.com/Zymrael/savanna), an open source framework for training alternative architectures.
239251

0 commit comments

Comments
 (0)