Native TorchLean FNO1D Burgers #
Read this after the basic CNN/MLP examples if you want the operator-learning path. The Python
scripts do the two jobs Lean should not own here: download and reshape the public
burgers_data_R10.mat file, then plot the prediction CSV. The model, loss, optimizer, and training
loop stay in TorchLean.
Why we use the real-split FNO path in this executable:
NN.FNO1D.modelis the mathematically clean complex-domain implementation.- The eager CUDA backend stores float32 buffers, not complex buffers.
- On CUDA this run uses the fused
spectralConv1dRfftautograd primitive, which represents Fourier weights by real/imaginary float32 buffers and executes the real FFT path through cuFFT. - On CPU it falls back to the dense DFT implementation. That is slower, but it is the useful reference path when someone wants to inspect the math without CUDA in the way.
The training task follows the standard FNO Burgers setup: learn the operator
u₀(x) ↦ u(x,T) on a fixed periodic grid. The default grid and row counts are modest enough for a
local run while still exercising the real operator-learning path. Larger runs can raise --steps,
export more rows, and bump the constants below.
References for the dataset/training convention:
- Li et al., “Fourier Neural Operator for Parametric Partial Differential Equations”, 2020/2021.
- MathWorks’ Burgers FNO example and the
burgers_data_R10.matpublic dataset. - SciML FNO tutorials using fields
afor initial conditions andufor final solutions.
CLI subcommand name used in terminal banners and errors.
Instances For
Spatial grid resolution used by the prepared Burgers .npy slices.
Instances For
Channel width inside the compact FNO block.
Instances For
Number of Fourier modes retained on each side of the real FFT spectrum.
Instances For
Number of spectral blocks. Kept small so the eager reference path remains usable.
Instances For
Default number of training rows expected from the preparation script.
Instances For
Default number of held-out rows expected from the preparation script.
Instances For
Shape-level FNO configuration shared by the constructor and sample loaders.
Instances For
Model input shape: one sampled initial condition on the fixed grid.
Instances For
Model output shape: one predicted terminal solution on the same grid.
Instances For
Directory where the preparation script writes Burgers tensors by default.
Instances For
Default training input tensor path.
Instances For
Default training target tensor path.
Instances For
Default held-out input tensor path.
Instances For
Default held-out target tensor path.
Instances For
Default CSV path for the prediction-vs-target plot script.
Instances For
Default JSON training-log path.
Instances For
User-facing hint printed when the prepared Burgers tensors are missing.
Instances For
FNO Burgers command-line options: training flags, data paths, and artifact paths.
Seeded optimizer/log flags come from ModelZoo, the Burgers tensor paths use
ModelZoo.PairedNpyEvalFlags, and the plot path uses ModelZoo.CsvArtifactFlags.
Instances For
Instances For
All required dataset files for this run.
Instances For
Parse the FNO Burgers command-line options.
Instances For
Effective CUDA-memory-watch cadence for this run.
Instances For
TrainLog note fields shared by the fused CUDA and portable dense execution paths.
Instances For
Instances For
Load one fixed-grid Burgers split as supervised TorchLean samples.
Instances For
Write one FNO prediction row to CSV for the companion plotting script.
Instances For
Persist the train/test MSE history with model/data metadata attached.
Instances For
Loaded train/test splits before evaluation prefixes and cycling streams are derived.
- train : TorchLean.Data.Dataset (TorchLean.SupervisedSample Float σ τ)
Training split as supervised samples.
Held-out split as supervised samples.
Instances For
Validate paths and load both Burgers splits.
Instances For
Deterministic evaluation prefixes and cycling stream derived from the loaded train/test sets.
- trainDatasetSamples : List (TorchLean.SupervisedSample Float σ τ)
- testDatasetSamples : List (TorchLean.SupervisedSample Float σ τ)
- trainSamples : List (Spec.Tensor Float σ × Spec.Tensor Float τ)
- testSamples : List (Spec.Tensor Float σ × Spec.Tensor Float τ)
- reportTrainDatasetSamples : List (TorchLean.SupervisedSample Float σ τ)
- reportTestDatasetSamples : List (TorchLean.SupervisedSample Float σ τ)
- reportTrainSamples : List (Spec.Tensor Float σ × Spec.Tensor Float τ)
- reportTestSamples : List (Spec.Tensor Float σ × Spec.Tensor Float τ)
- trainCycle : ℕ → TorchLean.SupervisedSample Float σ τ
Instances For
Convert loaded Burgers datasets into the common runtime/evaluation view used by both execution paths.
Both the fused CUDA path and the portable dense path:
- evaluate on fixed deterministic prefixes,
- train by cycling through the finite dataset with
seed + step, and - emit the same train/test MSE metric history.
Instances For
Push one train/test MSE point into the metric history and print the tagged report line.
Instances For
Fused CUDA parameter packet for the real-FFT FNO kernel.
Instances For
Mean MSE over a finite evaluation prefix using the fused CUDA FNO implementation.
Instances For
Append one fused-CUDA evaluation point to the metric history.
Instances For
Predict one Burgers terminal field through the fused CUDA spectral path.
Instances For
One fused CUDA Adam update on a single Burgers sample.
Instances For
Run the fused cuFFT/RFFT training path and emit the same artifacts as the dense path.