TorchLean API

NN.Runtime.Autograd.Engine.Cuda.Trusted

Trusted CUDA Runtime Boundary #

This module contains the opaque CUDA buffer type used by the native runtime. Buffers are created by explicit FFI allocation/copy functions. The nonemptiness witness below is only what Lean needs to declare extern functions returning Buffer; it is not a default CUDA allocation and should not be used as one.

The rest of this docstring is the map from native translation units to the Lean modules that call them. DocGen documents Lean modules, not C or CUDA files, so the map lives here, on the module that is the trust boundary, rather than in a separate source browser.

Trust boundary #

The CUDA backend is a validated implementation of TorchLean's float32 eager runtime. Lean does not prove the compiled CUDA binary correct. The trusted pieces include:

TorchLean's proof layer CUDA contract therefore lives one level up: Lean states pure kernel specs, float32 agreement assumptions, and graph-level semantics; tests validate that the native backend agrees with CPU stubs and reference cases on the supported path.

Native source groups #

Opaque handle to a contiguous float32 buffer (CUDA device memory when built with -K cuda=true, otherwise a CPU stub buffer).

Implementation:

  • CUDA: csrc/cuda/tensor/torchlean_cuda_tensor.cu
  • CPU stub (default lake build): csrc/cuda/tensor/torchlean_cuda_tensor_stub.c

Runtime representation used for native CUDA buffer handles.

The NonemptyType wrapper is Lean's standard representation for external resources: it gives extern declarations a nonempty result type while preserving reference-counting information in compiled code. The underlying value is still created only by the native buffer constructors.

Instances For