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.
This executable uses real-split Fourier arithmetic because the Burgers data are real-valued. The portable path transforms each spatial axis with separate real and imaginary tensors. On CUDA, the command deliberately selects a specialized one-sided real-FFT model whose transforms run through cuFFT. The two paths share the typed field-to-field boundary and training task, but they do not share an identical spectral parameter layout.
The training task follows the standard FNO Burgers setup: learn the operator
$u_0(x)\mapsto 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
Spectral mode budget.
The portable full-DFT path uses this as the width of each end band. The fused real-FFT path uses it as the number of stored nonnegative-frequency bins.
Instances For
Number of spectral blocks used by the compact training run.
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
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.
The record keeps optimizer/log settings, reproducibility, tensor paths, and output artifacts as separate named concerns.
- training : TorchLean.CLI.Training.OptimizerOptions
Optimizer, step, batching, and logging controls.
- seed : ℕ
Seed used for initialization and training-row selection.
- data : Support.PairedNpyEvalFlags
Prepared train/test tensors and evaluation row counts.
- artifacts : Support.CsvArtifactFlags
Output path for the prediction diagnostic.
Instances For
Instances For
All required dataset files for this run.
Instances For
Effective CUDA-memory-watch cadence for this run.
Instances For
The Fourier neural operator this example trains, at the width, mode count and depth fixed by
modelConfig.
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
Two tracked curves, train and test MSE, with the colours the log viewer will use.
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.
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.
- sample : TorchLean.Sample.Supervised Float input output
Training sample used to initialize the runtime's compiled evaluation path.
Held-out sample used for the prediction CSV emitted by both execution paths.
- next : ℕ → TorchLean.Sample.Supervised Float input output
Instances For
Convert loaded Burgers datasets into the common runtime/evaluation view used by both execution paths.
Both execution paths:
- 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
Train/test MSE pair for the current fused CUDA parameters.
Instances For
Append one fused-CUDA evaluation point to the metric history.
Instances For
Run the fused cuFFT/RFFT training path and emit its training and prediction artifacts.
Instances For
Train and evaluate using the portable full-spectrum model.
The transforms have a dense per-axis fallback on CPU. The fused cuFFT path above uses a different one-sided parameter layout; both models can be trained on the same data with the same seed.
Instances For
Print the run's configuration: device, execution mode, model geometry, row counts and file paths.
Worth the space, because an FNO run that silently loaded the wrong split looks like a training problem rather than a data problem.
Instances For
Entry point; dispatches to the fused CUDA path when the device supports it and to runPortable
otherwise.