TorchLean API

NN.Runtime.Autograd.Engine.LibTorch.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 crosses a C++/LibTorch FFI boundary. Lean does not prove the compiled native implementation correct. The trusted pieces include LibTorch and ATen, their CUDA libraries, compiler and runtime, GPU hardware, and Lean's external-object ABI and finalizers.

TorchLean retains its own tape and selected local VJPs. ATen computes tensor values and local backward operations with autograd recording disabled. Proof-facing kernel specifications, float32 agreement hypotheses, and graph semantics remain Lean definitions. Runtime regression and numerical parity tests provide evidence for a particular build and set of inputs.

Native source groups #

The GPU random stream is evaluated with ATen integer operations and checked against the seeded contract.

Storage representation of a tape buffer. Encoded values retain a complete format descriptor on their handle, rather than narrowing to one of the native dtypes.

Instances For

    Bytes per native scalar. Encoded buffers require their format descriptor for a word width and cannot use the native checkpoint framing.

    Instances For

      Opaque handle to a contiguous, dtype-carrying CUDA buffer in csrc/libtorch/torchlean.cpp. Builds without -K cuda=true cannot create one.

      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