yushuang88 commited on
Commit
6765f4c
·
verified ·
1 Parent(s): 0c634be

Update README and model configuration

Browse files
Files changed (1) hide show
  1. README.md +146 -0
README.md ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: pytorch
6
+ tags:
7
+ - OneScience
8
+ - fluid-dynamics
9
+ - functional-attention
10
+ - neural-operator
11
+ - operator-learning
12
+ datasets:
13
+ - OneScience-Group/airfrans
14
+ ---
15
+
16
+ <p align="center">
17
+ <strong><span style="font-size: 30px;">Functional Attention</span></strong>
18
+ </p>
19
+
20
+ # Model Introduction
21
+
22
+ Functional Attention is a resolution-independent operator-learning framework developed by researchers affiliated with the Technical University of Munich. It predicts continuous functions such as PDE solutions, aerodynamic fields, and three-dimensional point-cloud segmentation outputs.
23
+
24
+ Paper: [Functional Attention: From Pairwise Affinities to Functional Correspondences](https://arxiv.org/abs/2605.31559)
25
+
26
+ # Model Description
27
+
28
+ Functional Attention uses adaptive basis functions and functional mappings. This package trains and evaluates the model on AirfRANS aerodynamic data for PDE solving, 3D segmentation, and regression across discretizations and resolutions.
29
+
30
+ # Intended Uses
31
+
32
+ | Use case | Description |
33
+ | --- | --- |
34
+ | 2D airfoil-flow surrogate | Predict pointwise velocity, pressure, and turbulent-viscosity fields on unstructured AirfRANS meshes. |
35
+ | Reynolds OOD evaluation | Use `reynolds_train -> reynolds_test` to measure out-of-distribution generalization across Reynolds numbers. |
36
+ | CFD surrogate acceleration | Approximate RANS simulations for fast field prediction and design screening. |
37
+ | Hugging Face/OneCode execution | Download the standalone model package, install its dependencies, and run the scripts directly. |
38
+
39
+ # Usage
40
+
41
+ ## 1. OneCode
42
+
43
+ [Launch the OneCode AI-for-Science environment](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
44
+
45
+ ## 2. Manual Setup
46
+
47
+ **Hardware requirements**
48
+
49
+ - A GPU, DCU, or HCU is recommended for full training.
50
+ - A CPU can be used for import checks and very small connectivity tests.
51
+ - DCU users should install DTK 25.04.2 or later, or the OneScience-recommended version for the cluster.
52
+
53
+ ### Download the model repository from Hugging Face
54
+
55
+ ```bash
56
+ pip install -U huggingface_hub
57
+ hf download OneScience-Group/Functional_Attention --local-dir ./Functional_Attention
58
+ cd Functional_Attention
59
+ ```
60
+
61
+ ### Install the runtime environment
62
+
63
+ **DCU environment**
64
+
65
+ ```bash
66
+ # Activate DTK first.
67
+ conda create -n onescience311 python=3.11 -y
68
+ conda activate onescience311
69
+ pip install onescience[cfd] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
70
+ ```
71
+
72
+ **GPU environment**
73
+
74
+ ```bash
75
+ conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
76
+ conda activate onescience311
77
+ pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
78
+ ```
79
+
80
+ ### Download the training dataset from Hugging Face
81
+
82
+ ```bash
83
+ hf download OneScience-Group/airfrans --repo-type dataset --local-dir ./data
84
+ ```
85
+
86
+ Verify that the data path in `config/config.yaml` points to the downloaded dataset. The original data is also available from:
87
+
88
+ ```text
89
+ https://data.isir.upmc.fr/extrality/NeurIPS_2022/Dataset.zip
90
+ ```
91
+
92
+ ### Train
93
+
94
+ The default command runs the Reynolds OOD experiment:
95
+
96
+ ```bash
97
+ python scripts/train.py \
98
+ --config config/config.yaml \
99
+ --task reynolds
100
+ ```
101
+
102
+ The checkpoint with the best validation `Lv + Ls` is saved to `weight/best_model.pth`. It contains the model, optimizer, learning-rate scheduler, training epoch, experiment configuration, and normalization statistics.
103
+
104
+ ### Inference
105
+
106
+ Run inference on three Reynolds OOD test cases:
107
+
108
+ ```bash
109
+ python scripts/inference.py \
110
+ --config config/config.yaml \
111
+ --checkpoint weight/best_model.pth \
112
+ --task reynolds \
113
+ --max-cases 3
114
+ ```
115
+
116
+ Reported metrics include relative L2 errors for four physical fields, surface-pressure relative L2, and explicitly labeled `pressure_only_*` lift and drag metrics.
117
+
118
+ ### Visualization
119
+
120
+ `result.py` reads the training history and inference `.npz` files and produces training curves plus ground-truth, prediction, and absolute-error fields:
121
+
122
+ ```bash
123
+ python scripts/result.py \
124
+ --config config/config.yaml \
125
+ --task reynolds
126
+ ```
127
+
128
+ Outputs are saved to:
129
+
130
+ ```text
131
+ results/figures/
132
+ results/visualization_manifest_reynolds.json
133
+ ```
134
+
135
+ # OneScience
136
+
137
+ | Platform | OneScience repository | OneSkills repository |
138
+ | --- | --- | --- |
139
+ | Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
140
+ | GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
141
+
142
+ # Citation and License
143
+
144
+ - Paper: [Functional Attention: From Pairwise Affinities to Functional Correspondences](https://arxiv.org/abs/2605.31559).
145
+ - Upstream code and weights: [xjffff/FUNCATTN](https://github.com/xjffff/FUNCATTN) and [JayXI/FuncAttn](https://huggingface.co/JayXI/FuncAttn).
146
+ - This repository uses the Hugging Face-compatible MIT identifier (`mit`). AirfRANS and other third-party resources retain their own licenses and terms.