MWT

Model Introduction

MWT (Multiwavelet-based Operator Learning), proposed by Gaurav Gupta, Xiongye Xiao, and Paul Bogdan, is a multiwavelet operator-learning framework. It builds fixed decomposition and reconstruction filters from orthogonal polynomials and learns differential-equation solution operators in a multiscale space, enabling data-efficient physical-field prediction and generalization across resolutions.

This repository is an independent OneScience reproduction of the two-dimensional Navier–Stokes vorticity experiment described in the paper. On a periodic unit torus, the model combines the first 10 vorticity frames with spatial and temporal coordinates and predicts the remaining (T-10) frames in one shot. The experiment uses a regular 64 x 64 grid downsampled from 256 x 256 data.

Paper: Multiwavelet-based Operator Learning for Differential Equations

Model Description

MWT is a multiscale neural architecture for learning differential operators. Its pipeline is input lifting, multiwavelet decomposition, multiscale operator mapping, multiwavelet reconstruction, and vorticity projection. A linear layer first lifts the 13-dimensional input to (c k^2=36) features, where (c=4) and the Legendre multiwavelet order is (k=3). Fixed Legendre filter matrices from the paper and their two-dimensional Kronecker products recursively decompose both spatial dimensions.

At each scale, learnable (A), (B), and (C) operators transform detail and smooth coefficients. This implementation uses three-dimensional Fourier spectral and pointwise convolutions over ((x,y,t)). The coarsest scale is processed by the (\bar{T}) map and reconstructed to the original resolution with fixed filters.

For the two-dimensional Navier–Stokes experiment, four MWT blocks are stacked with BatchNorm3d and ReLU between blocks. A 36 -> 128 -> 1 output head maps reconstructed features to vorticity at each grid point and prediction time.

Intended Uses

Use case Description
Navier–Stokes vorticity prediction Predict the remaining vorticity trajectory from the first 10 two-dimensional frames.
Regular-grid operator learning Learn mappings between input and output functions on periodic regular grids.
Multiscale physical-field modeling Combine fixed multiwavelet decomposition with learnable within-scale operators.
Fast spatiotemporal inference Approximate a numerical solver for batched prediction within the training distribution and viscosity regime.

Usage

1. OneCode

Launch the OneCode AI-for-Science environment

2. Manual Setup

Hardware requirements

  • A GPU or DCU is recommended.
  • A CPU can run imports and small connectivity checks, but full training and inference will be slow.
  • DCU users should install DTK 25.04.2 or later, or the OneScience-recommended version for the cluster.

Download the model repository from Hugging Face

pip install -U huggingface_hub
hf download OneScience-Group/MWT --local-dir ./MWT
cd MWT

Install the runtime environment

DCU environment

# Activate DTK first.
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU environment

conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

Download the training dataset from Hugging Face

hf download OneScience-Group/fno --repo-type dataset --local-dir ./data

Set paths.data_root in config/config.yaml to the downloaded directory. The experiments use:

  • ns_V1e-3_N5000_T50.mat: (\nu=10^{-3}), 5,000 samples, and 50 frames.
  • ns_V1e-4_N10000_T30.mat: (\nu=10^{-4}), 10,000 samples; the experiment uses the first 30 frames.
  • NavierStokes_V1e-5_N1200_T20.mat: (\nu=10^{-5}), 1,200 samples, and 20 frames.

The main MAT variables are:

  • u: the Navier–Stokes vorticity trajectory, converted to [num_samples, 64, 64, T] after loading.
  • t: temporal coordinates, converted to [T].
  • a: the initial condition used by the numerical solver. The model uses the first 10 frames of u directly and does not load a as a separate input.

Train

config/config.yaml defines four MWT Navier–Stokes experiments. The default is ns_1e-3_t50; choose another with --experiment.

python scripts/train.py \
  --config config/config.yaml \
  --experiment ns_1e-3_t50 \
  --seed 0

Supported experiments:

  • ns_1e-3_t50: (\nu=10^{-3}), (T=50), nominally 1,000 training samples, 500 epochs.
  • ns_1e-4_t30_n1000: (\nu=10^{-4}), (T=30), nominally 1,000 training samples, 500 epochs.
  • ns_1e-4_t30_n10000: (\nu=10^{-4}), (T=30), nominally 10,000 training samples, 200 epochs.
  • ns_1e-5_t20: (\nu=10^{-5}), (T=20), nominally 1,000 training samples, 500 epochs.

Pretrained weights

weight/best_model.pt contains an MWT checkpoint trained on Navier–Stokes data and can be used directly for inference and numerical evaluation.

Inference

Run one-shot inference on the fixed 200-sample test set recorded by the checkpoint and report the mean relative L2 error in physical space:

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pt

For explicit device, batch-size, and output options:

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pt \
  --device auto \
  --batch-size 1 \
  --output-dir results

Outputs:

results/
├── inference_metrics.json
├── predictions.npy
├── targets.npy
└── sample_indices.npy

Evaluation and visualization

python scripts/result.py --config config/config.yaml --sample 0

Generated files:

results/
├── field_comparison.png
├── relative_l2_over_time.png
└── result_summary.json
  • field_comparison.png compares ground-truth vorticity, MWT prediction, and absolute error at the beginning, middle, and end of the forecast interval.
  • relative_l2_over_time.png plots spatial relative L2 over the full one-shot forecast interval.
  • result_summary.json records experiment settings, sample counts, array shapes, error metrics, paper-reference values, comparability notes, and visualization paths.

OneScience

Citation and License


中文说明

模型简介

MWT(Multiwavelet-based Operator Learning)由 Gaurav Gupta、Xiongye Xiao 和 Paul Bogdan 提出,是一种多小波算子学习框架。该框架基于正交多项式构造固定的分解和重构滤波器,在多尺度空间学习微分方程的解算子,实现高数据效率的物理场预测及跨分辨率泛化。

本仓库是 OneScience 对论文中二维 Navier–Stokes 涡度实验的独立复现。在周期单位环面上,模型将前 10 帧涡度与时空坐标结合,一次性预测剩余的 (T-10) 帧。实验使用规则 64 x 64 网格,由 256 x 256 数据降采样得到。

论文基于多小波的微分方程算子学习

模型描述

MWT 是学习微分算子的多尺度神经架构。处理流程依次为输入升维、多小波分解、多尺度算子映射、多小波重构和涡度投影。线性层首先将 13 维输入升维为 (c k^2=36) 个特征,其中 (c=4),Legendre 多小波阶数为 (k=3)。论文中的固定 Legendre 滤波矩阵及其二维 Kronecker 积递归分解两个空间维度。

在每个尺度上,可学习算子 (A)、(B) 和 (C) 变换细节系数与平滑系数。该实现对 ((x,y,t)) 使用三维傅里叶谱卷积和逐点卷积。最粗尺度由 (\bar{T}) 映射处理,并通过固定滤波器重构为原分辨率。

在二维 Navier–Stokes 实验中,堆叠四个 MWT 块,块之间采用 BatchNorm3d 和 ReLU。36 -> 128 -> 1 输出头将重构特征映射为各网格点和预测时刻的涡度。

预期用途

使用场景 说明
Navier–Stokes 涡度预测 根据前 10 帧二维涡度预测剩余涡度轨迹。
规则网格算子学习 学习周期规则网格上输入与输出函数之间的映射。
多尺度物理场建模 将固定多小波分解与尺度内可学习算子结合。
快速时空推理(inference) 在训练分布和黏性范围内近似数值求解器,进行批量预测。

使用方法

1. OneCode

启动 OneCode AI 科学计算环境

2. 手动配置

硬件要求

  • 建议使用 GPU 或 DCU。
  • CPU 可用于导入和小规模连通性检查,完整训练和推理会较慢。
  • DCU 用户应安装 DTK 25.04.2 或更高版本,或使用 OneScience 为所在集群推荐的版本。

从 Hugging Face 下载模型仓库

pip install -U huggingface_hub
hf download OneScience-Group/MWT --local-dir ./MWT
cd MWT

安装运行环境

DCU 环境

# Activate DTK first.
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU 环境

conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

从 Hugging Face 下载训练数据集

hf download OneScience-Group/fno --repo-type dataset --local-dir ./data

将 paths.data_root(位于 config/config.yaml 中)设为下载目录。实验使用以下数据集。

  • ns_V1e-3_N5000_T50.mat 为 (\nu=10^{-3}),含 5,000 个样本,每个样本 50 帧。
  • ns_V1e-4_N10000_T30.mat 为 (\nu=10^{-4}),含 10,000 个样本。实验使用前 30 帧。
  • NavierStokes_V1e-5_N1200_T20.mat 为 (\nu=10^{-5}),含 1,200 个样本,每个样本 20 帧。

主要 MAT 变量如下。

  • u 为 Navier–Stokes 涡度轨迹,加载后转换为 [num_samples, 64, 64, T]。
  • t 为时间坐标,转换为 [T]。
  • a 为数值求解器使用的初始条件。模型直接使用 u 的前 10 帧,无需将 a 作为单独输入加载。

训练

config/config.yaml 定义四个 MWT Navier–Stokes 实验。默认为 ns_1e-3_t50,可使用 --experiment 选择其他实验。

python scripts/train.py \
  --config config/config.yaml \
  --experiment ns_1e-3_t50 \
  --seed 0

支持以下实验。

  • ns_1e-3_t50 为 (\nu=10^{-3})、(T=50),标称 1,000 个训练样本,训练 500 轮。
  • ns_1e-4_t30_n1000 为 (\nu=10^{-4})、(T=30),标称 1,000 个训练样本,训练 500 轮。
  • ns_1e-4_t30_n10000 为 (\nu=10^{-4})、(T=30),标称 10,000 个训练样本,训练 200 轮。
  • ns_1e-5_t20 为 (\nu=10^{-5})、(T=20),标称 1,000 个训练样本,训练 500 轮。

预训练权重

weight/best_model.pt 包含在 Navier–Stokes 数据上训练得到的 MWT 模型权重(检查点)(checkpoint),可直接用于推理及数值评估。

推理

在模型权重(检查点)记录的固定 200 样本测试集上运行一次性推理,并报告物理空间中的平均相对 L2 误差。

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pt

如需显式指定设备、批大小和输出选项,可使用以下命令。

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pt \
  --device auto \
  --batch-size 1 \
  --output-dir results

输出

results/
├── inference_metrics.json
├── predictions.npy
├── targets.npy
└── sample_indices.npy

评估与可视化

python scripts/result.py --config config/config.yaml --sample 0

生成的文件

results/
├── field_comparison.png
├── relative_l2_over_time.png
└── result_summary.json
  • field_comparison.png 对比预测时段起始、中间和末尾的涡度真值、MWT 预测和绝对误差。
  • relative_l2_over_time.png 绘制整个一次性预测时段内的空间相对 L2。
  • result_summary.json 记录实验设置、样本数、数组形状、误差指标、论文参考数值、可比性说明和可视化路径。

OneScience

引用与许可证

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for OneScience-Group/MWT