TorchLean API

NN.Runtime.Autograd.Engine.FastKernels

Matmul Reference and cuBLAS Routines #

Low-level matrix-multiplication routines used to compare the CPU reference implementation with the explicit FP32 and FP64 cuBLAS paths. User-facing execution selects kernels through the runtime device and backend profile; this module does not define a separate execution mode.

Precision selector for GPU-backed fast matmul over Lean Float tensors.

  • .fp32 routes through Cuda.Buffer and cuBLAS SGEMM, matching the precision used by the eager CUDA tensor-buffer path.
  • .fp64 routes through the host FloatArray DGEMM bridge and cuBLAS DGEMM, preserving Lean Float precision for matmul-only research paths.
Instances For

    Convert an (m×n) matrix tensor into an array-of-rows representation.

    This is purely a representation change to make runtime loops faster/easier to write.

    Instances For

      Fast (runtime-only) 2D matmul kernel.

      This is a tight-loop kernel (array-of-rows representation) intended to avoid the overhead of the spec-layer definitions when running eager autograd.

      Instances For

        Convert an FFI dimension to UInt32, failing before the native call on overflow.

        Instances For

          2D matmul forward via the float32 CUDA buffer path.

          This path uploads Lean Float values to Cuda.Buffer (rounding to float32), calls the existing Buffer.bmm SGEMM implementation with batch = 1, then downloads the float32 result back to Lean Float.

          Instances For