Skip to main content

ReViT

Public code for ICML Spotlighy paper ReViT: Rotational-equivariant Vision Transformers for Neural PDE Solvers.

Installation

1. Create a Conda Environment

ReViT requires Python ≥ 3.10. Create and activate a dedicated conda environment before installing:

# Option A: from the provided environment.yml
conda env create -f environment.yml
conda activate revit

# Option B: manually
conda create -n revit python=3.10 -y
conda activate revit

Note — System Python will not work. Running pip install outside a virtual/conda environment on modern Debian/Ubuntu systems will fail with error: externally-managed-environment (see PEP 668). Always install inside a conda env or python -m venv.

2. Install the Package

Install from source (recommended):

git clone https://github.com/Howw-Way/ReViT.git
cd ReViT
pip install -e ".[all]"

Install from PyPI (once published):

pip install revit-pde              # core only
pip install revit-pde[datasets]    # + h5py, the-well
pip install revit-pde[train]       # + TensorBoard
pip install revit-pde[all]         # everything

Note: PyTorch must be installed with the correct CUDA version for your GPU. If the default pip install torch doesn't match your driver, install it first:

pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121

HPC Clusters

The setup script handles PyTorch CUDA selection automatically:

# Installs PyTorch (cu121) + ReViT into your active env
bash scripts/setup_env.sh

# CPU-only or different CUDA:
TORCH_CUDA=cpu bash scripts/setup_env.sh
TORCH_CUDA=cu124 bash scripts/setup_env.sh

# See all options:
bash scripts/setup_env.sh --help

Quick Use

import torch
from revit import ReViT2DConfig, build_revit_2d

model = build_revit_2d(
    ReViT2DConfig(
        img_size=64,
        patch_size=4,
        depth=[1],
        embed_dim=48,
        num_heads=4,
    )
)
x = torch.randn(2, 2, 64, 64)
y = model(x)
print(y.shape)

The public API exposes:

  • build_revit_2d: hierarchical 2D ReViT PDE model
  • build_revit_3d: hierarchical 3D ReViT PDE model
  • build_revit_classifier: ReViT image classifier for rotated image benchmarks
  • revit.datasets: APEBench, MHD_64/The Well, and P3D/TCF data adapters

Supported Models

Model Params (approx.) Use case
EqPDETiny ~1M 2D PDE, fast experiments
EqPDESmall ~5M 2D PDE, paper results
EqPDEBase ~15M 2D PDE, larger experiments
EqPDELarge ~50M 2D PDE, scaling study
EqPDE3DTiny ~1M 3D PDE (MHD_64, TCF)
EqPDE3DSmall ~5M 3D PDE, paper results
EqPDE3DBase ~15M 3D PDE, larger experiments
EqPDE3DLarge ~50M 3D PDE, scaling study
EqViT varies Image classification (rotMNIST, PCam)

Datasets

All datasets are hosted on Hugging Face: huggingface.co/datasets/thuerey-group/ReViT

Dataset Task Grid Channels Size
KF2D 2D Kolmogorov Flow 160² 2 (velocity) ~3.3 GB
MHD_64 3D Magnetohydrodynamics 64³ 7 (ρ + v + B) ~24.5 GB
P3D 3D Periodic Channel Flow 96³ 4 (v + p) ~6.3 GB

Download

# Install the downloader dependency
pip install huggingface_hub

# Download all datasets
python scripts/download_dataset.py

# Download specific dataset(s)
python scripts/download_dataset.py --dataset MHD_64 P3D

# Skip rotated test data (smaller download)
python scripts/download_dataset.py --no-rotated

# Custom output directory
python scripts/download_dataset.py --output_dir /path/to/Dataset

# Verify existing download
python scripts/download_dataset.py --verify

Or download directly via the Python API:

from huggingface_hub import snapshot_download
snapshot_download(repo_id="thuerey-group/ReViT", repo_type="dataset", local_dir="./Dataset")

Dataset Layout

Set REVIT_DATASET_ROOT to the directory containing dataset folders:

export REVIT_DATASET_ROOT=/path/to/Dataset
# or create a symlink:
ln -s /path/to/Dataset ./Dataset

Expected directory structure:

Dataset/
├── apebench-scraped/data/          # KF2D / TD2D
│   ├── *_train_V.npy
│   ├── *_test_V.npy
│   └── *_test_V_{angle}.npy        # rotated test data
├── Well/MHD_64/                    # MHD_64
│   ├── data/train/*.hdf5
│   ├── data/valid/*.hdf5
│   ├── data/valid/rotated/*.npy    # rotated validation data
│   └── stats.yaml
├── P3D/cropped/                    # P3D / TCF
│   ├── sim0_data_{train,test}.h5
│   └── rotated/sim0_data_test_rot_*.h5
└── ADV_2D/                         # Advection (coming soon)
    └── adv_*_{vector,scalar}_uniform_grid.pkl

The legacy environment variable EQUIVAR_DATASET_ROOT is still accepted for backward compatibility.

Training Entry Point

The rollout trainer supports all ReViT models and the valid benchmark cases:

# 2D tasks (default decoder: local_query)
python scripts/Train_rollout.py --task KF2D --model_type EqPDETiny --epochs 100
python scripts/Train_rollout.py --task TD2D --model_type EqPDESmall --epochs 100
python scripts/Train_rollout.py --task ADV_2D --model_type EqPDETiny --epochs 100

# 3D tasks (default decoder: trilinear)
python scripts/Train_rollout.py --task MHD_64 --model_type EqPDE3DTiny --epochs 100
python scripts/Train_rollout.py --task P3D --model_type EqPDE3DSmall --epochs 100

Testing

pip install revit-pde[dev]
python -m pytest tests/ -v

Publishing to PyPI

For maintainers — one-time setup and release workflow:

# 1. Install build tools
pip install build twine

# 2. Build source distribution + wheel
python -m build

# 3. (Optional) Test on TestPyPI first
twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ revit-pde

# 4. Upload to PyPI
twine upload dist/*

You'll need a PyPI account and an API token. Store the token in ~/.pypirc:

[pypi]
username = __token__
password = pypi-AgEI...  # your API token

After uploading, pip install revit-pde will work for everyone.

Citation

If you use this code, please cite the ReViT paper. See Revit.pdf for details.

Metadata

Release files for revit-pde 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revit-pde 0.1.0
File Size Uploaded Provenance Actions
revit_pde-0.1.0.tar.gz 248.0 kB Without provenance Details for revit_pde-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for revit-pde 0.1.0
File Interpreter ABI Platform Actions
revit_pde-0.1.0-py3-none-any.whl Python 3 none any Details for revit_pde-0.1.0-py3-none-any.whl

Total release size: 520.7 kB

Release files / revit_pde-0.1.0.tar.gz

Download URL revit_pde-0.1.0.tar.gz
Size 248.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b0c2a26c4985dd4a3c87ebbd2574a42aeeb18ee93fa033d1b723f204eb46267a
BLAKE2b-256 checksum
How to use checksums
d0226602c6c2d5b86e2c1ecf0381e03e135baa4607cb0947e3288138ffa17cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / revit_pde-0.1.0-py3-none-any.whl

Download URL revit_pde-0.1.0-py3-none-any.whl
Size 272.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09c0d46f746d1024023c0c1581ca16807c3bf52996ebf14c3d8f54f5870b610b
BLAKE2b-256 checksum
How to use checksums
14627a7f340f2e913a6f26b1962367414161274b90f15bbc0a9718245ba884d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for revit-pde 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page