UNO

Model Overview

UNO (U-shaped Neural Operator) combines the multiscale encoder–decoder structure of U-Net with the spectral convolutions of a Fourier Neural Operator. It learns PDE solution operators across multiple spatial scales while preserving local flow-field details through skip connections.

This model package targets Navier–Stokes time-series prediction on two-dimensional regular grids. By default, it takes the first 10 time steps as input and predicts the subsequent 10 autoregressively.

Paper: U-NO: U-shaped Neural Operators
https://arxiv.org/abs/2204.11127

Repository Overview

This repository is a minimal, self-contained, runnable UNO model package maintained by OneScience for ModelScope downloads, automated OneCode execution, and rapid local validation.

Supported capabilities:

  • Train a two-dimensional UNO model from a YAML configuration
  • Perform multistep autoregressive prediction of Navier–Stokes flow fields
  • Compute relative L2 errors and save predicted tensors and visualizations
  • Override the sample count, temporal window, spatial downsampling, and model size from the command line
  • Run on a CPU, GPU, or DCU

Unsupported capabilities:

  • Pretrained weights are not bundled
  • The approximately 394 MiB raw Navier–Stokes data file is not bundled
  • The standalone model includes only the two-dimensional UNO implementation required by this example; the general-purpose OneScience 1D and 3D components are not included

Use Cases

Use Case Description
Flow-field time-series prediction Autoregressively predict future Navier–Stokes states from historical vorticity fields
Neural operator training Evaluate the combination of Fourier spectral convolutions and a U-shaped multiscale architecture
CFD surrogate modeling Learn mappings from historical to future fields on regular grids
Pipeline validation Validate training and inference with a small sample set and a single epoch

File Structure

Path Purpose Notes
README.md Project documentation English
conf/config.yaml Data, model, training, and output configuration Paths are resolved relative to the model package root
model/uno.py Standalone two-dimensional UNO model Does not depend on onescience.modules
scripts/common.py Shared configuration, device, metric, and autoregressive utilities Used by both training and inference
scripts/train.py Training and validation script Saves the checkpoint with the best relative L2 error
scripts/inference.py Inference, evaluation, and visualization script Loads weight/*.pt
data/ Navier–Stokes data directory Stores the benchmark .mat file
weight/ Model weight directory Checkpoints are written automatically during training
result/ Inference result directory Created automatically on first inference

Usage

1. OneCode

Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience:

Launch OneCode for one-click AI4S programming

2. Manual Setup

Hardware Requirements

  • A GPU or DCU is recommended for full training.
  • A CPU can be used for pipeline validation with a reduced model and dataset, but full training will be slow.
  • DCU users must install DTK and a PyTorch environment compatible with the target cluster.

Download the Model Package

hf download OneScience-Group/UNO --local-dir ./UNO
cd UNO

Set Up the Runtime Environment

DCU Environment

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

GPU Environment

# Activate Conda first
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
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

3. Quick Start

Prepare the Data

Download the following file from the Transolver PDE-Solving-StandardBenchmark:

NavierStokes_V1e-5_N1200_T20.mat

Place the file in data/:

data/
  NavierStokes_V1e-5_N1200_T20.mat

Data downloads and documentation:

The OneScience community also provides the training data. Download it with the following command and verify that the data path in conf/config.yaml is configured correctly:

hf download --repo-type dataset OneScience-Group/cfd_benchmark  data/ns/NavierStokes_V1e-5_N1200_T20.mat  --local-dir ./data

Training

python scripts/train.py

The default checkpoint is saved to weight/uno_navier_stokes.pt. The training script is controlled entirely by conf/config.yaml and does not accept command-line configuration arguments.

Model Weights

This repository provides weights trained on the standard Navier–Stokes dataset in the weight/ directory.

Inference, Evaluation, and Visualization

python scripts/inference.py

The script loads weight/uno_navier_stokes.pt by default and generates the following files under result/:

result/
  prediction_sample.pt
  prediction_sample.png

The inference script is likewise controlled entirely by conf/config.yaml and does not accept command-line configuration arguments. The weight path is determined jointly by training.weight_dir and training.checkpoint_name; the output directory and number of saved samples are controlled by inference.result_dir and inference.num_samples, respectively.

Configuration

conf/config.yaml contains five sections:

  • common: device and random seed
  • datapipe: data file, sample splits, temporal windows, downsampling, and DataLoader settings
  • model: hidden channels, Fourier modes, normalization, and spatial padding
  • training: optimizer, learning-rate schedule, early stopping, and weight directory
  • inference: inference result directory and number of saved samples

The model automatically updates in_dim from t_in * out_dim in the configuration, so the model input dimension does not need to be synchronized manually when the history window changes.

Data Format

The .mat file must contain a variable named u with the following standard shape:

[1200, 64, 64, 20]
Dimension Meaning
1200 Number of independent flow-field samples
64, 64 Height and width of the two-dimensional regular grid
20 Number of consecutive time steps

The data pipeline produces:

  • pos: [H*W, 2], normalized two-dimensional coordinates
  • x: [H*W, t_in*out_dim], historical states
  • y: [H*W, t_out*out_dim], future states

Official OneScience Resources

Citations and License

  • Rahman, M. A., Ross, Z. E., and Azizzadenesheli, K. U-NO: U-shaped Neural Operators. arXiv:2204.11127, 2022.
  • Li, Z. et al. Fourier Neural Operator for Parametric Partial Differential Equations. arXiv:2010.08895, 2020.
  • This model package is released under the Apache-2.0 license and retains attribution to the original paper and data sources.

中文说明

模型概述

UNO(U-shaped Neural Operator)结合 U-Net 的多尺度编码器–解码器结构和傅里叶神经算子(Fourier Neural Operator)的谱卷积。它跨多个空间尺度学习 PDE 解算子,同时通过跳跃连接保留局地流场细节。

此模型包用于二维规则网格上的 Navier–Stokes 时间序列预测。默认以前 10 个时间步作为输入,自回归预测后续 10 步。

论文《U-NO:U 形神经算子》
https://arxiv.org/abs/2204.11127

仓库概述

本仓库是 OneScience 维护的最小、自包含且可运行的 UNO 模型包,用于 ModelScope 下载、OneCode 自动化运行及本地快速验证。

支持的功能

  • 从 YAML 配置训练二维 UNO 模型
  • 对 Navier–Stokes 流场进行多步自回归预测
  • 计算相对 L2 误差并保存预测张量和可视化结果
  • 从命令行覆盖样本数、时间窗口、空间降采样和模型规模
  • 在 CPU、GPU 或 DCU 上运行

未支持的功能

  • 未附带预训练权重
  • 未附带约 394 MiB 的 Navier–Stokes 原始数据文件
  • 独立模型仅包含本示例所需的二维 UNO 实现,不包含 OneScience 通用的 1D 和 3D 组件

使用场景

使用场景 说明
流场时间序列预测 根据历史涡度场自回归预测未来 Navier–Stokes 状态
神经算子训练 评估傅里叶谱卷积与 U 形多尺度架构结合的效果
计算流体力学(computational fluid dynamics (CFD))代理模型(surrogate model)建模 学习规则网格上从历史场到未来场的映射
流程验证 使用小样本集和单轮训练验证训练及推理(inference)

文件结构

路径 用途 说明
README.md 项目文档 英文
conf/config.yaml 数据、模型、训练和输出配置 路径相对于模型包根目录解析
model/uno.py 独立二维 UNO 模型 不依赖 onescience.modules
scripts/common.py 共享的配置、设备、指标和自回归辅助工具 训练和推理均使用
scripts/train.py 训练和验证脚本 保存相对 L2 误差最优的模型权重(检查点)(checkpoint)
scripts/inference.py 推理、评估及可视化脚本 加载 weight/*.pt
data/ Navier–Stokes 数据目录 存放基准 .mat 文件
weight/ 模型权重目录 训练中自动写入模型权重(检查点)
result/ 推理结果目录 首次推理时自动创建

使用方法

1. OneCode

通过 OneCode 在线环境体验智能一键式 AI 科学计算(AI4S)编程。

启动 OneCode 体验一键 AI4S 编程

2. 手动配置

硬件要求

  • 完整训练建议使用 GPU 或 DCU。
  • 可使用 CPU 和缩减后的模型及数据集验证流程,完整训练速度较慢。
  • DCU 用户必须安装与目标集群兼容的 DTK 和 PyTorch 环境。

下载模型包

hf download OneScience-Group/UNO --local-dir ./UNO
cd UNO

配置运行环境

DCU 环境

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

GPU 环境

# Activate Conda first
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
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

3. 快速开始

准备数据

从 Transolver 的 PDE-Solving-StandardBenchmark 下载以下文件。

NavierStokes_V1e-5_N1200_T20.mat

将文件放入 data/。

data/
  NavierStokes_V1e-5_N1200_T20.mat

数据下载和文档

OneScience 社区也提供训练数据。使用以下命令下载,并确认 conf/config.yaml 中的数据路径配置正确。

hf download --repo-type dataset OneScience-Group/cfd_benchmark  data/ns/NavierStokes_V1e-5_N1200_T20.mat  --local-dir ./data

训练

python scripts/train.py

默认模型权重(检查点)保存至 weight/uno_navier_stokes.pt。训练脚本完全由 conf/config.yaml 控制,不接受命令行配置参数。

模型权重

本仓库在 weight/ 目录中提供在标准 Navier–Stokes 数据集上训练得到的权重。

推理、评估与可视化

python scripts/inference.py

脚本默认加载 weight/uno_navier_stokes.pt,并在 result/ 下生成以下文件。

result/
  prediction_sample.pt
  prediction_sample.png

推理脚本同样完全由 conf/config.yaml 控制,不接受命令行配置参数。权重路径由 training.weight_dir 和 training.checkpoint_name 共同决定,输出目录和保存的样本数分别由 inference.result_dir 和 inference.num_samples 控制。

配置

conf/config.yaml 包含五个部分。

  • common 为设备和随机种子
  • datapipe 为数据文件、样本划分、时间窗口、降采样和 DataLoader 设置
  • model 为隐藏通道、傅里叶模态、归一化及空间填充
  • training 为优化器、学习率调度、提前停止及权重目录
  • inference 为推理结果目录和保存的样本数

模型自动更新 in_dim,其值来自配置中的 t_in * out_dim,因此在历史窗口变化时无需手动同步模型输入维数。

数据格式

.mat 文件必须包含名为 u 的变量,其标准形状如下。

[1200, 64, 64, 20]
维度 含义
1200 独立流场样本数
64, 64 二维规则网格的高度和宽度
20 连续时间步数

数据流水线生成以下内容。

  • pos 为 [H*W, 2],代表归一化二维坐标
  • x 为 [H*W, t_in*out_dim],代表历史状态
  • y 为 [H*W, t_out*out_dim],代表未来状态

OneScience 官方资源

引用与许可证

  • Rahman, M. A., Ross, Z. E., and Azizzadenesheli, K. U-NO: U-shaped Neural Operators. arXiv:2204.11127, 2022.
  • Li, Z. et al. Fourier Neural Operator for Parametric Partial Differential Equations. arXiv:2010.08895, 2020.
  • 此模型包按照 Apache-2.0 许可证发布,并保留原始论文和数据来源的署名。
Downloads last month
13
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Papers for OneScience-Group/UNO