CUDA FNO1D (real RFFT fused path) #
This file provides a direct CUDA forward and VJP runner for a real-valued FNO1D model. Its
spectral convolution uses the same native tape primitive as nn.models.fnoRfft on CUDA.
The public constructor also offers a dense reference with identical one-sided weights.
This runner keeps its explicit buffer lifetime and Adam handling for the Burgers example.
Comparisons with the public constructor must load identical parameter tensors and use the same
ReLU blocks, loss, and update rule. The arbitrary-rank full-DFT model in Model.Fno has a different
spectral parameterization and is not an interchangeable checkpoint.
Trainable parameter plus Adam moment buffers.
All three tensors share shape. Values are serialized only when uploaded to CUDA; host Adam
updates consume downloaded gradients as tensors.
- shape : Spec.Shape
- value : TorchLean.Tensor Float self.shape
Current parameter values in row-major order.
- m : TorchLean.Tensor Float self.shape
Adam first-moment accumulator.
- v : TorchLean.Tensor Float self.shape
Adam second-moment accumulator.
Instances For
Number of CUDA buffer handles owned by a completed forward tape.
Instances For
Release every forward value and saved workspace owned by a completed tape.
The fused FNO wrapper rebuilds its tape for every sample. Explicit disposal is therefore part of the wrapper's ownership contract; waiting for external-object finalizers makes long training and evaluation runs retain one full tape per sample until a later runtime collection.
Instances For
Deterministic uniform sample in [lo, hi) for a scalar index.
Instances For
Initialize a trainable parameter and zero Adam moments.
Instances For
Initialize a bias-like parameter at zero with zero Adam moments.
Instances For
Initialize parameters for the fused FNO1D model:
- input lift:
W_in : (1,width),b_in : (width) - blocks:
(wRe,wIm) : (modes,width,width),wSkip : (width,width),bSkip : (width) - output proj:
W_out : (width,1),b_out : (1)
Instances For
Build a CUDA tape that computes prediction (and optionally MSE loss) for the fused real-RFFT FNO.
Inputs:
x : (grid)(interpreted as(grid,1)),- optional
target : (grid).
Every external CUDA buffer is checked against the corresponding logical shape and element count before an operation can consume it. Input and parameter buffers are checked before their leaf nodes are added; the optional target is checked by the MSE operation on the loss path.
Instances For
Build one fused-FNO tape from fresh CUDA uploads.
The uploads are effectful so repeated forwards over identical host arrays cannot share an external
buffer handle. This gives each returned Forward exclusive ownership of the buffers it disposes.
Instances For
Mean MSE over a nonempty indexed sample stream, releasing each tape after scalar download.
Instances For
Tensor Adam update with cached bias corrections and the fused path's scalar evaluation order.
Each multiplication/division retains its original ordering, including (1-beta2)*g*g and
lr*(m/biasCorr1)/(sqrt(v/biasCorr2)+eps). Equal shapes replace the former runtime length checks.
Instances For
Run reverse-mode on the fused-FNO tape and update every recorded parameter with Adam.
Gradients are computed on CUDA buffers and downloaded to host arrays before the update. A high-throughput optimizer kernel should live in a separate CUDA optimizer layer, not inside this model helper.
Instances For
Predict through the fused spectral path and release the temporary tape after downloading.
Instances For
Consume one fused training tape, returning updated parameters and cached Adam state.