本项目包含 FNO-3D (Fourier Neural Operator 3D) 模型在华为昇腾 NPU 平台的完整迁移适配方案。
新手用户请先阅读完整的迁移适配指导书:
该指导书包含:
其他参考文档:
FNO-3D-migration/
├── docs/ # 文档目录
│ ├── FNO-3D-昇腾迁移适配指导书.md # ⭐ 核心适配指导文档(从这里开始)
│ ├── FNO-3D-端到端迁移指导.md # 端到端验证流程
│ ├── FNO-3D-迁移验证报告.md # 验证结果报告
│ ├── FNO-3D-关键差异说明.md # GPU与NPU差异分析
│ └── migration_issues_analysis.md # 问题分析记录
├── ascend_train.py # NPU训练脚本
├── ascend_infer.py # NPU推理脚本
├── benchmark_performance.py # 性能评测脚本
├── eval_accuracy.py # 精度评估脚本
├── OperatorAdaptation/ # 算子适配方案
│ └── FFT替代方案.md # FFT算子NPU适配说明
├── train_config.yaml # 训练配置文件
├── requirements.txt # 依赖列表
└── data/ # 数据集目录
├── mini_car_cfd.pt # Mini数据集 (1.2MB)
└── nsforcing_train_128.pt # Navier-Stokes数据集 (7.3MB)# 安装依赖
pip install -r requirements.txt
# 检查NPU状态
python -c "import torch_npu; print(torch_npu.npu.is_available())"python ascend_train.py \
--epochs 50 \
--batch-size 1 \
--device-id 0 \
--modes 8 \
--width 20python ascend_infer.py \
--batch-size 1 \
--device-id 0 \
--checkpoint npu_trained_weights.pthpython benchmark_performance.py \
--batch-size 1 \
--n-warmup 5 \
--n-runs 20NPU不支持 torch.fft 的 complex64 操作,本项目采用 Conv3d 替代方案:
详细说明见:FFT替代方案
| 指标 | GPU基准 | NPU结果 | 状态 |
|---|---|---|---|
| 训练Loss下降 | - | 59% | ✅ PASS |
| 推理输出维度 | (1,64,64,40,1) | (1,64,64,40,1) | ✅ PASS |
| NaN/Inf检测 | 无 | 无 | ✅ PASS |
| Benchmark吞吐 | - | 173 samples/s | ✅ PASS |
| NPU加速比 | - | 119x | ✅ PASS |
本项目使用 Navier-Stokes 3D 流体仿真数据集:
Li, Z., et al. "Fourier Neural Operator for Parametric Partial Differential Equations." arXiv:2010.08895, 2020.
Apache-2.0