Skip to content

Commit ecf70ba

Browse files
Update core. No CHOLMOD deps
1 parent 3a7fe10 commit ecf70ba

4 files changed

Lines changed: 151 additions & 152 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if(NOT EXISTS "${LIBACTIONET_DIR}/include/libactionet.hpp")
6969
endif()
7070

7171
# Build libactionet static library
72-
# This configures BLAS, LAPACK, CHOLMOD, OpenMP, and Armadillo
72+
# This configures BLAS, LAPACK, OpenMP, and Armadillo
7373
add_subdirectory("${LIBACTIONET_DIR}")
7474

7575
# ==============================================================================
@@ -107,7 +107,7 @@ target_include_directories(_core PRIVATE
107107

108108
# Link against libactionet
109109
# This provides access to all libactionet functions and transitively links
110-
# BLAS, LAPACK, CHOLMOD, and OpenMP (if available)
110+
# BLAS, LAPACK, and OpenMP (if available)
111111
target_link_libraries(_core PRIVATE actionet)
112112

113113
# ==============================================================================

README.md

Lines changed: 121 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ brew install cmake openblas lapack
2929
**Linux (Debian/Ubuntu):**
3030
```bash
3131
sudo apt-get update
32-
sudo apt-get install build-essential cmake libopenblas-dev liblapack-dev libsuitesparse-dev
32+
sudo apt-get install build-essential cmake libopenblas-dev liblapack-dev
3333
```
3434

3535
**Conda (rootless / HPC):**
3636
```bash
37-
conda install -c conda-forge cmake openblas lapack suitesparse
37+
conda install -c conda-forge cmake openblas lapack
3838
```
3939

40-
libactionet now searches for CHOLMOD/SuiteSparse in conda prefixes (e.g. `CONDA_PREFIX`) in addition to system paths.
41-
4240
### Install from source
4341

4442
```bash
@@ -56,6 +54,123 @@ pip install -e .
5654
pip install .
5755
```
5856

57+
### Building with Intel MKL (Recommended for Best Performance)
58+
59+
Intel MKL provides highly optimized BLAS/LAPACK implementations and can significantly improve performance, especially for large matrix operations. ACTIONet will automatically detect and use MKL if available.
60+
61+
#### Option 1: Using Conda (Easiest)
62+
63+
```bash
64+
# Create a new environment with MKL
65+
conda create -n actionet-mkl python=3.12
66+
conda activate actionet-mkl
67+
68+
# Install Intel MKL and build dependencies
69+
conda install -c conda-forge cmake compilers numpy scipy mkl mkl-include
70+
71+
# Clone and build ACTIONet
72+
git clone https://github.com/KellisLab/actionet-python.git
73+
cd actionet-python
74+
git submodule update --init --recursive
75+
76+
# Build with MKL (automatically detected)
77+
pip install -e .
78+
```
79+
80+
#### Option 2: Using Intel oneAPI (Most Optimized)
81+
82+
For maximum performance, use Intel's oneAPI toolkit with the Intel C++ compiler:
83+
84+
```bash
85+
# Download and install Intel oneAPI Base Toolkit
86+
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html
87+
88+
# Source the Intel environment
89+
source /opt/intel/oneapi/setvars.sh
90+
91+
# Set environment variables for Intel MKL and compiler
92+
export CC=icx
93+
export CXX=icpx
94+
export MKLROOT=/opt/intel/oneapi/mkl/latest
95+
96+
# Clone and build
97+
git clone https://github.com/KellisLab/actionet-python.git
98+
cd actionet-python
99+
git submodule update --init --recursive
100+
101+
# Build with Intel compiler and MKL
102+
pip install -e .
103+
```
104+
105+
#### Option 3: System MKL (Linux)
106+
107+
```bash
108+
# Install Intel MKL from package manager (Ubuntu/Debian)
109+
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
110+
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
111+
sudo apt update
112+
sudo apt install intel-oneapi-mkl intel-oneapi-mkl-devel
113+
114+
# Source MKL environment
115+
source /opt/intel/oneapi/mkl/latest/env/vars.sh
116+
117+
# Build ACTIONet
118+
cd actionet-python
119+
pip install -e .
120+
```
121+
122+
#### Verifying MKL Usage
123+
124+
After installation, verify that MKL is being used:
125+
126+
```python
127+
import numpy as np
128+
print(np.__config__.show()) # Should show MKL in BLAS/LAPACK info
129+
```
130+
131+
#### Performance Tuning with MKL
132+
133+
For optimal performance, set these environment variables:
134+
135+
```bash
136+
# Use all available cores
137+
export MKL_NUM_THREADS=$(nproc)
138+
139+
# For GNU OpenMP runtime (conda default)
140+
export MKL_THREADING_LAYER=GNU
141+
export OMP_NUM_THREADS=$(nproc)
142+
143+
# For Intel OpenMP runtime (Intel compiler)
144+
export MKL_THREADING_LAYER=INTEL
145+
export OMP_NUM_THREADS=$(nproc)
146+
147+
# Disable MKL's internal threading (if using external parallelization)
148+
export MKL_NUM_THREADS=1
149+
```
150+
151+
#### Expected Performance Improvements
152+
153+
With Intel MKL, you should see:
154+
- **2-4x faster** matrix operations (SVD, matrix multiplication)
155+
- **Especially beneficial** for large datasets (>100K cells)
156+
- **Better multi-threading** efficiency
157+
- **Lower memory usage** for some operations
158+
159+
#### Troubleshooting MKL Builds
160+
161+
**MKL not detected:**
162+
- Ensure `MKLROOT` environment variable is set
163+
- Verify `mkl-include` is installed (conda) or headers are in `/opt/intel/oneapi/mkl/latest/include`
164+
165+
**Mixed OpenMP runtime warnings:**
166+
- Set `MKL_THREADING_LAYER=GNU` for conda environments
167+
- Set `MKL_THREADING_LAYER=INTEL` for Intel oneAPI builds
168+
- Or disable OpenMP: `pip install . -C cmake.define.LIBACTIONET_OPENMP_RUNTIME=OFF`
169+
170+
**Link errors with Intel compiler:**
171+
- Ensure `setvars.sh` is sourced before building
172+
- Try: `export LDFLAGS="-L${MKLROOT}/lib/intel64"`
173+
59174
## Quick Start
60175

61176
```python
@@ -89,7 +204,7 @@ sc.pl.embedding(adata, basis='X_umap', color='assigned_archetype')
89204
```python
90205
an.reduce_kernel(adata, n_components=50, layer=None, key_added='action')
91206
```
92-
Compute reduced kernel matrix using SVD. **Automatically selects the optimal SVD algorithm** based on matrix properties (sparse vs dense, size, sparsity) with negligible overhead (~1-2 microseconds). See [AUTOMATIC_SELECTION.md](AUTOMATIC_SELECTION.md) for details.
207+
Compute reduced kernel matrix using SVD. **Automatically selects the optimal SVD algorithm** based on matrix properties (sparse vs dense, size, sparsity) with negligible overhead (~1-2 microseconds).
93208

94209
Available algorithms:
95210
- **IRLB** (default for sparse): Implicitly Restarted Lanczos Bidiagonalization
@@ -264,8 +379,8 @@ pip install . -v
264379

265380
**Linux:**
266381
- Targets manylinux2014 (glibc ≥ 2.17)
267-
- Requires `libcholmod` from SuiteSparse
268382
- OpenMP runtime defaults to `AUTO` (compiler-selected); override with `-C cmake.define.LIBACTIONET_OPENMP_RUNTIME=GNU|INTEL|LLVM|OFF`
383+
- **For best performance**, consider building with Intel MKL (see installation section above)
269384

270385
### Troubleshooting
271386

tests/test_fast.ipynb

Lines changed: 27 additions & 143 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)