Skip to content

Commit 47f77d3

Browse files
authored
Support Python 3.13 and Torch 2.12 dependency installs
1 parent 2814c41 commit 47f77d3

15 files changed

Lines changed: 1416 additions & 178 deletions

.github/workflows/gpu_compat.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: GPU compatibility
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
backend:
7+
description: "Installer backend to test"
8+
required: true
9+
default: "cu128"
10+
type: choice
11+
options:
12+
- cu128
13+
- cu130
14+
pytest_mark:
15+
description: "Pytest marker expression"
16+
required: true
17+
default: "not slow"
18+
run_pytest:
19+
description: "Run pytest after install and CUDA smoke"
20+
required: true
21+
default: true
22+
type: boolean
23+
24+
jobs:
25+
gpu-compat:
26+
if: github.repository_owner == 'deepmodeling'
27+
runs-on: [self-hosted, linux-x64, gpu]
28+
timeout-minutes: 180
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v6
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Add safe directory
36+
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
37+
38+
- name: Show GPU
39+
run: |
40+
nvidia-smi
41+
42+
- name: Install DeePTB GPU stack
43+
run: |
44+
bash install.sh "${{ inputs.backend }}" --extra pythtb --test
45+
46+
- name: CUDA and torch-scatter smoke
47+
run: |
48+
.venv/bin/python - <<'PY'
49+
import torch
50+
import torch_scatter
51+
from importlib import metadata
52+
53+
print("torch", torch.__version__, "cuda runtime", torch.version.cuda)
54+
print("torch-scatter", metadata.version("torch-scatter"))
55+
assert torch.cuda.is_available(), "CUDA is not available after GPU install"
56+
57+
x = torch.randn(16, device="cuda")
58+
index = torch.tensor(
59+
[0, 0, 1, 1, 2, 2, 3, 3, 0, 1, 2, 3, 0, 1, 2, 3],
60+
device="cuda",
61+
)
62+
out = torch_scatter.scatter_add(x, index)
63+
assert out.shape == (4,)
64+
print("scatter_add", out.shape, out.dtype, out.device)
65+
PY
66+
67+
- name: Run pytest
68+
if: inputs.run_pytest
69+
run: |
70+
.venv/bin/python -m pytest dptb/tests -m "${{ inputs.pytest_mark }}" -q

.github/workflows/unit_test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
output1: ${{ steps.s1.outputs.test }}
1717
output2: ${{ steps.s2.outputs.test }}
1818
if: github.repository_owner == 'deepmodeling'
19-
container: ghcr.io/deepmodeling/deeptb:latest
2019
steps:
2120
- name: Checkout
2221
id: s1

README.md

Lines changed: 72 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
DeePTB is an innovative Python package that uses deep learning to accelerate *ab initio* electronic structure simulations. It offers versatile, accurate, and efficient simulations for a wide range of materials and phenomena. Trained on small systems, DeePTB can predict electronic structures of large systems, handle structural perturbations, and integrate with molecular dynamics for finite temperature simulations, providing comprehensive insights into atomic and electronic behavior.
2323

2424
- **Key Features**
25-
DeePTB contains two main components:
25+
DeePTB contains two main components:
2626
1. **DeePTB-SK**: deep learning based local environment dependent Slater-Koster TB.
27-
- Customizable Slater-Koster parameterization with neural network corrections for .
27+
- Customizable Slater-Koster parameterization with neural network corrections for .
2828
- Flexible basis and exchange-correlation functional choices.
2929
- Handle systems with strong spin-orbit coupling (SOC) effects.
3030

@@ -42,7 +42,7 @@ For more details, see our papers:
4242
## 📚 Documentation
4343

4444
- **Online documentation**
45-
45+
4646
For a comprehensive guide and usage tutorials, visit [Documentation website](https://deeptb.readthedocs.io/en/latest/).
4747

4848
- **Contributing**
@@ -57,19 +57,20 @@ Installing **DeePTB** is straightforward with UV, a fast Python package manager.
5757

5858
- **Requirements**
5959
- Git
60-
- Python 3.9 to 3.12 (UV can auto-install if needed)
61-
- PyTorch 2.0.0 to 2.5.1 (auto-installed by UV)
60+
- Python 3.10 to 3.13
61+
- UV, the recommended installer frontend
62+
- For GPU installs: an NVIDIA driver compatible with the selected CUDA runtime
6263

6364
- **From Source** (Recommended)
64-
65+
6566
1. **Install UV** (if not already installed):
6667
```bash
6768
# On macOS and Linux
6869
curl -LsSf https://astral.sh/uv/install.sh | sh
69-
70+
7071
# Or using pip
7172
pip install uv
72-
73+
7374
# On Windows (PowerShell)
7475
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
7576
```
@@ -80,120 +81,111 @@ Installing **DeePTB** is straightforward with UV, a fast Python package manager.
8081
cd DeePTB
8182
```
8283

83-
3. **Install DeePTB with all dependencies**:
84-
85-
**CPU version (default)**:
84+
3. **Install DeePTB with tested dependencies**:
85+
86+
**Automatic CPU/GPU selection**:
8687
```bash
87-
uv sync
88-
# Or use the convenience script
8988
./install.sh
9089
```
91-
92-
**GPU version** (specify CUDA version via command line, no file editing needed):
90+
91+
**CPU-only install**:
9392
```bash
94-
# Check your CUDA version first
95-
nvidia-smi # Look for CUDA Version
96-
97-
# Install with your CUDA version (examples):
98-
uv sync --find-links https://data.pyg.org/whl/torch-2.5.0+cu118.html # CUDA 11.8
99-
uv sync --find-links https://data.pyg.org/whl/torch-2.5.0+cu121.html # CUDA 12.1
100-
uv sync --find-links https://data.pyg.org/whl/torch-2.5.0+cu124.html # CUDA 12.4
101-
102-
# Or use the convenience script
103-
./install.sh cu121 # for CUDA 12.1
93+
./install.sh cpu
10494
```
105-
95+
96+
**GPU install**:
97+
```bash
98+
nvidia-smi # check the driver-reported CUDA version
99+
./install.sh gpu # auto-detect CUDA backend
100+
101+
# Or force a tested CUDA wheel path:
102+
./install.sh cu128 # RTX 50 / CUDA 12.8 path tested with torch 2.10.0
103+
./install.sh cu130 # requires a driver new enough for CUDA 13.0 runtime
104+
```
105+
106106
This single command will:
107107
- Automatically create a virtual environment (`.venv`)
108-
- Install PyTorch (>=2.0.0, <=2.5.1) with the specified variant (CPU/GPU)
109-
- Install torch_scatter from PyTorch Geometric index
108+
- Install a tested PyTorch / PyG / `torch-scatter` binary-wheel combination
109+
- Refuse unsupported Python or CUDA/backend combinations instead of falling back to source builds
110110
- Install all other dependencies
111-
111+
112112
4. **Install optional dependencies** (if needed):
113113
```bash
114114
# For 3D Fermi surface plotting
115-
uv sync --extra 3Dfermi
116-
115+
./install.sh auto --extra 3Dfermi
116+
117117
# For TBtrans initialization
118-
uv sync --extra tbtrans_init
119-
118+
./install.sh auto --extra tbtrans_init
119+
120120
# For pybinding support
121-
uv sync --extra pybinding
122-
123-
# Install all optional dependencies
124-
uv sync --all-extras
121+
./install.sh auto --extra pybinding
125122
```
126123

127124
5. **Run DeePTB**:
128125
```bash
129-
# UV automatically activates the environment when using 'uv run'
130-
uv run dptb --help
131-
132-
# Or activate the environment manually
133126
source .venv/bin/activate # On Unix/macOS
134127
.venv\Scripts\activate # On Windows
135128
dptb --help
136129
```
137130

138-
- **GPU Support** (Optional)
139-
140-
GPU installation is now built into the main installation step above! Simply use:
131+
- **Developer Install**
132+
133+
`pyproject.toml` declares the broader source-compatible range
134+
(`Python >=3.10,<3.14`, `torch >=2.5.1,<=2.12.1`). Developers who already
135+
manage their own Torch/PyG environment can still use:
136+
141137
```bash
142-
# Check CUDA version
143-
nvidia-smi
144-
145-
# Install with command line (recommended - no file editing!)
146-
uv sync --find-links https://data.pyg.org/whl/torch-2.5.0+cu121.html
147-
148-
# Or use convenience script
149-
./install.sh cu121
138+
uv sync
150139
```
151-
152-
See step 3 above for all available CUDA versions.
140+
141+
For new machines, prefer `install.sh` because it selects a tested
142+
`torch-scatter` binary wheel for the requested CPU/GPU backend.
153143

154144
- **Easy Installation** (PyPI)
155-
145+
156146
> [!WARNING]
157-
> PyPI installation requires manual torch_scatter installation first, as torch_scatter is not available on PyPI.
158-
147+
> PyPI installation requires a compatible PyTorch and `torch-scatter` binary
148+
> wheel to be installed first. The source install path above is easier for new
149+
> machines.
150+
159151
**For CPU**:
160152
```bash
161-
# 1. Install torch_scatter first
162-
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.5.0+cpu.html
163-
153+
# 1. Install torch_scatter matching the tested CPU Torch version
154+
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.12.1+cpu.html
155+
164156
# 2. Install DeePTB
165157
pip install dptb
166158
```
167-
168-
**For GPU** (example with CUDA 12.1):
159+
160+
**For GPU** (example with CUDA 12.8 / RTX 50):
169161
```bash
170-
# 1. Install torch with CUDA support
171-
pip install torch --index-url https://download.pytorch.org/whl/cu121
172-
173-
# 2. Install torch_scatter matching your CUDA version
174-
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.5.0+cu121.html
175-
162+
# 1. Install torch with CUDA support.
163+
pip install torch==2.10.0 --index-url https://download.pytorch.org/whl/cu128
164+
165+
# 2. Install torch_scatter matching the Torch/CUDA pair.
166+
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.10.0+cu128.html
167+
176168
# 3. Install DeePTB
177169
pip install dptb
178170
```
179-
171+
180172
> [!TIP]
181173
> For easier installation with automatic GPU/CPU detection, use the **From Source** method above instead.
182174

183175
- **Julia Backend** (Optional - for High-Performance Pardiso Solver)
184-
176+
185177
> [!NOTE]
186178
> **Platform Support**: Pardiso backend currently supports **Linux only**.
187179
> - **macOS**: Not supported (Intel MKL limitations)
188180
> - **Windows**: Use WSL2 (Windows Subsystem for Linux)
189-
181+
190182
If you want to use the Pardiso backend for accelerated band structure calculations:
191-
183+
192184
**Automated Installation** (Recommended):
193185
```bash
194186
./install_julia.sh
195187
```
196-
188+
197189
**Manual Installation**:
198190
1. Install Julia:
199191
```bash
@@ -204,22 +196,22 @@ Installing **DeePTB** is straightforward with UV, a fast Python package manager.
204196
```bash
205197
julia install_julia_packages.jl
206198
```
207-
199+
208200
**Verify Installation**:
209201
```bash
210202
julia -e 'using Pardiso; println("Pardiso available: ", Pardiso.MKL_PARDISO_LOADED[])'
211203
```
212-
204+
213205
**Usage**:
214206
```bash
215207
dptb pdso band.json -i model.pth -stu structure.vasp -o ./output
216208
```
217-
209+
218210
For more details, see:
219211
- [Pardiso Backend README](dptb/postprocess/pardiso/README.md)
220212
- [Example Tutorial](examples/To_pardiso/README.md)
221213

222-
## Test code
214+
## Test code
223215

224216
To ensure the code is correctly installed, please run the unit tests first:
225217
```bash
@@ -234,7 +226,7 @@ The following references are required to be cited when using DeePTB. Specificall
234226
- **For DeePTB-SK:**
235227

236228
Q. Gu, Z. Zhouyin, S. K. Pandey, P. Zhang, L. Zhang, and W. E, Deep Learning Tight-Binding Approach for Large-Scale Electronic Simulations at Finite Temperatures with Ab Initio Accuracy, Nat Commun 15, 6772 (2024).
237-
229+
238230
- **For DeePTB-E3:**
239-
240-
Z. Zhouyin, Z. Gan, S. K. Pandey, L. Zhang, and Q. Gu, Learning Local Equivariant Representations for Quantum Operators, In The 13th International Conference on Learning Representations (ICLR) 2025.
231+
232+
Z. Zhouyin, Z. Gan, S. K. Pandey, L. Zhang, and Q. Gu, Learning Local Equivariant Representations for Quantum Operators, In The 13th International Conference on Learning Representations (ICLR) 2025.

0 commit comments

Comments
 (0)