Skip to content

Commit 031042c

Browse files
committed
Add documentation for Huawei NPU supports
1 parent 86ebe15 commit 031042c

6 files changed

Lines changed: 360 additions & 57 deletions

File tree

1

Whitespace-only changes.

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
DNALLM-Suite is a comprehensive, open-source toolkit designed for fine-tuning and inference with DNA Language Models. It provides a unified interface for working with various DNA sequence models, supporting tasks ranging from basic sequence classification to advanced in-silico mutagenesis analysis. With built-in Model Context Protocol (MCP) support, DNALLM-Suite enables seamless communication with traditional large language models, allowing for enhanced integration and interoperability in AI-powered DNA analysis workflows.
1212

13-
## 📦 Installation
13+
## 📦 Quick Installation
1414

1515
```bash
1616
pip install dnallm
@@ -48,6 +48,23 @@ DNALLM-Suite supports a wide range of DNA language models including:
4848
- **ModelScope**: Alternative model source with additional models
4949
- **Custom Models**: Support for locally trained or custom architectures
5050

51+
## 🖥️ Supported Platforms
52+
53+
DNALLM-Suite has been tested on a wide range of platforms and devices:
54+
55+
### Platforms:
56+
- **Linux**
57+
- **Windows**
58+
- **MacOS**
59+
60+
### Device:
61+
- **CPU**
62+
- **Nvidia GPU (CUDA)**
63+
- **AMD GPU (ROCm)**
64+
- **Apple Silicon (MPS)**
65+
- **Huawei Ascend NPU (CANN)**
66+
- **Intel Arc GPU (XPU)**
67+
5168
## 🛠️ Installation
5269

5370
### Prerequisites

docs/getting_started/installation.md

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ For development and testing without GPU acceleration:
150150

151151
```bash
152152
# Create environment
153-
conda create -n dnallm-cpu python=3.12 -y
153+
conda create -n dnallm-cpu python=3.12 uv -y
154154
conda activate dnallm-cpu
155155

156156
# Install all dependencies and CPU version
@@ -169,7 +169,7 @@ For GPU-accelerated training and inference:
169169
nvidia-smi
170170

171171
# Create environment (using CUDA 12.4 as example)
172-
conda create -n dnallm-gpu python=3.12 -y
172+
conda create -n dnallm-gpu python=3.12 uv -y
173173
conda activate dnallm-gpu
174174

175175
# Install all dependencies and CUDA 12.4 support
@@ -179,7 +179,61 @@ uv pip install -e '.[all,cuda124]'
179179
python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}')"
180180
```
181181

182-
### Scenario 3: Using Mamba Model Architecture
182+
### Scenario 3: Using Huawei Ascend NPU for Training and Inference
183+
184+
For Huawei Ascend NPU accelerated training and inference, users should first check their device and environment, then install the appropriate dependencies.
185+
186+
If Huawei Ascend driver is not installed in the machine, first check the device and install the corresponding drivers.
187+
188+
For NPU driver, please refer to: https://www.hiascend.com/hardware/firmware-drivers/community
189+
190+
For Ascend Extension for PyTorch (CANN driver), please refer to: https://www.hiascend.com/zh/cann/download
191+
192+
For example, if you have a `Ascend 910B NPU with AArch64 architecture`, install drivers like this:
193+
194+
```bash
195+
# Install NPU driver
196+
wget -c "https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Ascend%20HDK/Ascend%20HDK%2025.5.2/Ascend-hdk-910b-npu-driver_25.5.2_linux-aarch64.run"
197+
bash ./Ascend-hdk-910b-npu-driver_25.5.2_linux-aarch64.run --install
198+
# Install CANN Toolkit
199+
wget https://ascend-cann-open.obs.cn-north-4.myhuaweicloud.com/CANN/CANN%209.0.0/Ascend-cann_9.0.0_linux-aarch64.run
200+
bash ./Ascend-cann_9.0.0_linux-aarch64.run --install
201+
# Install CANN Kernel/Ops
202+
wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%209.0.0/Ascend-cann-910b-ops_9.0.0_linux-aarch64.run
203+
bash ./Ascend-cann-910b-ops_9.0.0_linux-aarch64.run --install
204+
205+
# Check the drivers
206+
source /usr/local/Ascend/cann/set_env.sh
207+
python3 -c "import acl;print(acl.get_soc_name())"
208+
npu-smi info
209+
```
210+
211+
if you want to auto-activate the driver environment, add the `set_env.sh` to system environment.
212+
```bash
213+
echo "source /usr/local/Ascend/cann/set_env.sh" >> ~/.bashrc
214+
```
215+
216+
To use the NPU accelerating in torch, a specific version of `torch_npu` package is also required. Please refer to [this page](https://gitcode.com/Ascend/pytorch) to check the dependency map.
217+
218+
For example, CANN 9.0.0 support Pytorch version from 2.7.1 to 2.10.0, also the Python version need to >=3.9.
219+
220+
```bash
221+
# Create environment (using CANN 9.0.0 as example)
222+
conda create -n dnallm-npu python=3.11 uv -y
223+
conda activate dnallm-npu
224+
225+
# Install dependencies of NPU support
226+
uv pip install torch torch_npu==2.9.0
227+
228+
# Verify installation
229+
python -c "import torch; import torch_npu; print(f'PyTorch: {torch.__version__}'); print(f'NPU available: {torch.npu.is_available()}')"
230+
```
231+
232+
During training or inference, Huawei Ascend NPU accelerate is supported for most of the DNA models (models supported by Huggingface Transformers library).
233+
234+
For other non-transformer models or CUDA-dependent models, Huawei provides a specific framework for efficient model training and inference, named [MindSpeed](https://gitcode.com/Ascend/MindSpeed-LLM/). Detailed supported model list is shown [here](https://gitcode.com/Ascend/MindSpeed-LLM/blob/master/docs/zh/pytorch/models/supported_models.md).
235+
236+
### Scenario 4: Using Mamba Model Architecture
183237

184238
For models with Mamba architecture (Plant DNAMamba, Caduceus, Jamba-DNA):
185239

@@ -198,7 +252,7 @@ uv pip install -e '.[cuda124,mamba]' --no-cache-dir --no-build-isolation
198252
python -c "from mambapy import Mamba; print('Mamba installed successfully!')"
199253
```
200254

201-
### Scenario 4: Complete Development Environment
255+
### Scenario 5: Complete Development Environment
202256

203257
For contributors and developers:
204258

@@ -220,7 +274,7 @@ print('CUDA:', torch.version.cuda if torch.cuda.is_available() else 'CPU')
220274
"
221275
```
222276

223-
### Scenario 5: Running MCP Server Only
277+
### Scenario 6: Running MCP Server Only
224278

225279
For MCP server deployment:
226280

docs/getting_started/quick_start.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ uv pip install -e '.[cuda124]'
9999
uv pip install -e '.[cuda121]'
100100
```
101101

102+
### Huawei NPU Support
103+
104+
For Huawei Ascend NPU acceleration, install the appropriate torch and extension version:
105+
106+
```bash
107+
# For venv users: activate virtual environment
108+
source .venv/bin/activate
109+
# For conda users: activate conda environment
110+
# conda activate dnallm
111+
112+
# Install specific torch and extension version according the CANN driver's version
113+
uv pip install torch torch_npu
114+
```
115+
116+
Detailed installation method see [installation.md](./installation.md##Installation-Scenarios)
117+
118+
102119
### Native Mamba Support
103120

104121
Native Mamba architecture runs significantly faster than transformer-compatible Mamba architecture, but native Mamba depends on Nvidia GPUs.

docs/index.md

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,26 @@ DNALLM-Suite supports a wide range of DNA language models including:
3636
- **ModelScope**: Alternative model source with additional models
3737
- **Custom Models**: Support for locally trained or custom architectures
3838

39+
## 🖥️ Supported Platforms
40+
41+
DNALLM-Suite has been tested on a wide range of platforms and devices:
42+
43+
### Platforms
44+
- [**Linux**] [**Windows**] [**MacOS**]
45+
46+
### Device
47+
- **CPU**
48+
- **Nvidia GPU (CUDA)**
49+
- **AMD GPU (ROCm)**
50+
- **Apple Silicon (MPS)**
51+
- **Huawei Ascend NPU (CANN)**
52+
- **Intel Arc GPU (XPU)**
53+
3954
## 🚀 Quick Start
4055

4156
DNALLM-Suite uses conda for environment management and uv for dependency management and packaging.
4257

4358
1. **Install dependencies (recommended: [uv](https://docs.astral.sh/uv/))**
44-
4559
```bash
4660
# Clone repository
4761
git clone https://github.com/zhangtaolab/DNALLM.git
@@ -69,6 +83,9 @@ uv pip install -e '.[all]'
6983
python -c "import dnallm; print('DNALLM installed successfully!')"
7084
```
7185

86+
For NPU support such as Huawei Ascend, see [installation](getting_started/installation.md#scenario-3-using-huawei-ascend-npu-for-training-and-inference) section.
87+
88+
7289
2. **Basic Model Loading and Inference**
7390
```python
7491
from dnallm import load_config, load_model_and_tokenizer, DNAInference
@@ -107,6 +124,8 @@ predictions = mutagenesis.evaluate(strategy="mean")
107124
# Visualize results
108125
plot = mutagenesis.plot(predictions, save_path="mutation_effects.pdf")
109126
```
127+
128+
4. **Model Fine-tuning**
110129
```python
111130
from dnallm.datahandling import DNADataset
112131
from dnallm.finetune import DNATrainer
@@ -125,7 +144,8 @@ trainer = DNATrainer(model=model, config=configs, datasets=dataset)
125144
# Start training
126145
trainer.train()
127146
```
128-
<!-- skip-verify: requires async event loop context -->
147+
148+
5. **MCP Server Deployment**
129149
```python
130150
# Start MCP server for real-time DNA sequence prediction
131151
from dnallm.mcp import DNALLMMCPServer
@@ -138,55 +158,55 @@ await server.initialize()
138158
server.start_server(host="0.0.0.0", port=8000, transport="streamable-http")
139159
```
140160

141-
6. **Launch Jupyter Lab, Marimo or Gradio App for interactive development:**
142-
143-
#### Interactive Demos (Marimo)
144-
```bash
145-
# Fine-tuning demo
146-
uv run --no-sync marimo run example/marimo/finetune/finetune_demo.py
147-
148-
# Inference demo
149-
uv run --no-sync marimo run example/marimo/inference/inference_demo.py
150-
151-
# Benchmark demo
152-
uv run --no-sync marimo run example/marimo/benchmark/benchmark_demo.py
153-
```
154-
155-
#### Jupyter Notebooks
156-
```bash
157-
# Launch Jupyter Lab
158-
uv run --no-sync jupyter lab
159-
160-
# Available notebooks:
161-
# - example/notebooks/finetune_binary/ - Binary classification fine-tuning
162-
# - example/notebooks/finetune_multi_labels/ - Multi-label classification
163-
# - example/notebooks/finetune_NER_task/ - Named Entity Recognition
164-
# - example/notebooks/inference/ - Model inference
165-
# - example/notebooks/in_silico_mutagenesis/ - Mutation analysis
166-
# - example/notebooks/inference_for_tRNA/ - tRNA-specific analysis
167-
# - example/notebooks/generation_evo_models/ - EVO model inference
168-
# - example/notebooks/lora_finetune_inference/ - LoRA fine-tuning
169-
# - example/notebooks/embedding_attention.ipynb - Embedding and attention analysis
170-
# - example/notebooks/finetune_custom_head/ - Custom classification head
171-
# - example/notebooks/finetune_generation/ - Sequence generation
172-
# - example/notebooks/generation/ - Sequence generation examples
173-
# - example/notebooks/generation_megaDNA/ - MegaDNA model inference
174-
# - example/notebooks/interpretation/ - Model interpretation
175-
# - example/notebooks/data_prepare/ - Data preparation examples
176-
# - example/notebooks/benchmark/ - Model evaluation and benchmarking
177-
```
178-
179-
#### Web-based UI (Gradio)
180-
```bash
181-
# Launch Gradio configuration generator app
182-
uv run --no-sync python ui/run_config_app.py
183-
184-
# Or run the model config generator directly
185-
uv run --no-sync python ui/model_config_generator_app.py
186-
187-
# For Generation, we also provide a app
188-
uv run --no-sync python ui/generation_task_app.py
189-
```
161+
6. **Launch Jupyter Lab, Marimo or Gradio App for interactive development**
162+
163+
(1) Interactive Demos (Marimo)
164+
```bash
165+
# Fine-tuning demo
166+
uv run --no-sync marimo run example/marimo/finetune/finetune_demo.py
167+
168+
# Inference demo
169+
uv run --no-sync marimo run example/marimo/inference/inference_demo.py
170+
171+
# Benchmark demo
172+
uv run --no-sync marimo run example/marimo/benchmark/benchmark_demo.py
173+
```
174+
175+
(2) Jupyter Notebooks
176+
```bash
177+
# Launch Jupyter Lab
178+
uv run --no-sync jupyter lab
179+
180+
# Available notebooks:
181+
# - example/notebooks/finetune_binary/ - Binary classification fine-tuning
182+
# - example/notebooks/finetune_multi_labels/ - Multi-label classification
183+
# - example/notebooks/finetune_NER_task/ - Named Entity Recognition
184+
# - example/notebooks/inference/ - Model inference
185+
# - example/notebooks/in_silico_mutagenesis/ - Mutation analysis
186+
# - example/notebooks/inference_for_tRNA/ - tRNA-specific analysis
187+
# - example/notebooks/generation_evo_models/ - EVO model inference
188+
# - example/notebooks/lora_finetune_inference/ - LoRA fine-tuning
189+
# - example/notebooks/embedding_attention.ipynb - Embedding and attention analysis
190+
# - example/notebooks/finetune_custom_head/ - Custom classification head
191+
# - example/notebooks/finetune_generation/ - Sequence generation
192+
# - example/notebooks/generation/ - Sequence generation examples
193+
# - example/notebooks/generation_megaDNA/ - MegaDNA model inference
194+
# - example/notebooks/interpretation/ - Model interpretation
195+
# - example/notebooks/data_prepare/ - Data preparation examples
196+
# - example/notebooks/benchmark/ - Model evaluation and benchmarking
197+
```
198+
199+
(3) Web-based UI (Gradio)
200+
```bash
201+
# Launch Gradio configuration generator app
202+
uv run --no-sync python ui/run_config_app.py
203+
204+
# Or run the model config generator directly
205+
uv run --no-sync python ui/model_config_generator_app.py
206+
207+
# For Generation, we also provide a app
208+
uv run --no-sync python ui/generation_task_app.py
209+
```
190210

191211
## 🎯 Supported Task Types
192212

0 commit comments

Comments
 (0)