TorchLean API

NN.Backend.NativeCUDA

Native CUDA Backend Capsules #

Capsule metadata for TorchLean's native CUDA runtime provider.

These capsules describe kernels that currently live under csrc/cuda/** and are exposed to Lean through NN.Runtime.Autograd.Engine.Cuda.*. The C/CUDA source still owns the implementation; this module gives the planner a typed, inspectable contract layer for those implementation choices.

def NN.Backend.NativeCUDA.nativeCapsule (name : String) (op : BackendOp) (valueSummary vjpSummary : String) (vjpMode : VJPMode := VJPMode.backendVJP) :

Build a checked native-CUDA capsule with explicit FFI, value, VJP, and layout contracts.

Instances For

    Build the standard native-CUDA capsule for a pointwise operation.

    Instances For

      Build a native-CUDA reduction capsule with implementation-selected parallel reduction order.

      Instances For

        Native CUDA kernel with an accumulation whose tree/order is selected by the implementation.

        This covers matrix products, affine layers, convolutions, losses, and average pooling. CUDA may use parallel trees, fused multiply-add, cuBLAS/cuDNN algorithms, or architecture-specific schedules; the capsule therefore records the reduction as implementation-defined instead of pretending it is the reference left fold.

        Instances For

          Build the standard native-CUDA capsule for a shape or layout transformation.

          Instances For

            Build a native-CUDA forward-only capsule with no registered reverse derivative.

            Instances For

              Build a native-CUDA capsule for channel-first convolution or pooling.

              Instances For

                Native window selection whose traversal and tie winner are chosen by the CUDA implementation.

                Instances For

                  Native CUDA batched/matrix multiplication, backed by CUDA/cuBLAS paths.

                  Instances For

                    Native CUDA ReLU activation.

                    Instances For

                      Native CUDA GELU activation.

                      Instances For

                        Native-CUDA pointwise addition.

                        Instances For

                          Native-CUDA pointwise subtraction.

                          Instances For

                            Native-CUDA pointwise multiplication.

                            Instances For

                              Native-CUDA scalar multiplication.

                              Instances For

                                Native-CUDA pointwise absolute value.

                                Instances For

                                  Native-CUDA pointwise square root.

                                  Instances For

                                    Native-CUDA pointwise interval clamp.

                                    Instances For

                                      Native-CUDA pointwise maximum.

                                      Instances For

                                        Native-CUDA pointwise minimum.

                                        Instances For

                                          Native-CUDA pointwise sigmoid.

                                          Instances For

                                            Native-CUDA pointwise hyperbolic tangent.

                                            Instances For

                                              Native-CUDA pointwise softplus.

                                              Instances For

                                                Native-CUDA pointwise exponential.

                                                Instances For

                                                  Native CUDA sine, with angles measured in radians.

                                                  Instances For

                                                    Native CUDA cosine, with angles measured in radians.

                                                    Instances For

                                                      Native-CUDA pointwise natural logarithm.

                                                      Instances For

                                                        Native-CUDA pointwise reciprocal.

                                                        Instances For

                                                          Native-CUDA guarded logarithm used by numerically defensive programs.

                                                          Instances For

                                                            Native-CUDA log-softmax reduction and normalization.

                                                            Instances For

                                                              Native CUDA row/axis softmax kernels.

                                                              Instances For

                                                                Native CUDA hard-masked row softmax.

                                                                Instances For

                                                                  Native-CUDA sum reduction.

                                                                  Instances For

                                                                    Native-CUDA arithmetic-mean reduction.

                                                                    Instances For

                                                                      Native-CUDA shape-preserving reshape view.

                                                                      Instances For

                                                                        Native-CUDA axis permutation.

                                                                        Instances For

                                                                          Native-CUDA tensor broadcasting.

                                                                          Instances For

                                                                            Native-CUDA tensor concatenation.

                                                                            Instances For

                                                                              Native-CUDA contiguous tensor slice.

                                                                              Instances For

                                                                                Native-CUDA indexed gather.

                                                                                Instances For

                                                                                  Native-CUDA indexed scatter-add.

                                                                                  Instances For

                                                                                    Native-CUDA seeded uniform-random tensor generation.

                                                                                    Instances For

                                                                                      Native-CUDA seeded Bernoulli-mask generation.

                                                                                      Instances For

                                                                                        Native CUDA layer normalization.

                                                                                        Instances For

                                                                                          Native CUDA batch normalization.

                                                                                          Instances For

                                                                                            Native CUDA generic channel-first convolution.

                                                                                            Instances For

                                                                                              Native CUDA generic channel-first transpose convolution.

                                                                                              Instances For

                                                                                                Native CUDA max pooling.

                                                                                                Instances For

                                                                                                  Native CUDA smooth max pooling.

                                                                                                  Instances For

                                                                                                    Native CUDA average pooling.

                                                                                                    Instances For

                                                                                                      Native CUDA linear layer.

                                                                                                      Instances For

                                                                                                        Native CUDA mean-squared-error loss.

                                                                                                        Instances For

                                                                                                          Native CUDA FFT/FNO kernels.

                                                                                                          Instances For

                                                                                                            Native CUDA selective scan kernels.

                                                                                                            Instances For

                                                                                                              Native CUDA capsules, excluding attention which has a dedicated semantic split.

                                                                                                              Instances For