CUDA
CUDA runs supported Float32 operations on an NVIDIA GPU without changing the model’s tensor types or graph. The linked guide chapters give the full provider and trust account; the material below collects the commands used to build and test the native path.
Build and Run
Build with CUDA support:
lake -R -K cuda=true build
Run a small CUDA example:
lake -R -K cuda=true exe torchlean mlp --device cuda --steps 100
Run a broader CUDA regression pass:
scripts/checks/example_regression.sh --cuda
Run the CUDA sanitizer suite when changing native kernels:
scripts/checks/cuda_sanitize_tests.sh --all-tools
What CUDA Covers
The CUDA path is used for supported Float32 tensor operations: elementwise arithmetic, reductions,
matmul/cuBLAS paths, convolution/pooling kernels, shape/view operations, attention kernels, FFT/FNO
support where enabled, and model examples that choose --device cuda.
Determinism
Some CUDA reduction and backward paths use floating-point accumulation. Because Float32 addition is not associative, atomic accumulation can be schedule-dependent. TorchLean also provides an opt-in deterministic reductions mode for the covered reduction, gather/scatter, and pooling-backward paths:
let _ := Runtime.Autograd.Cuda.Buffer.setDeterministicReductionsChecked true
or:
TORCHLEAN_CUDA_DETERMINISTIC_REDUCTIONS=1 lake -R -K cuda=true exe torchlean mlp --device cuda
The setting covers the reduction, gather/scatter, and pooling-backward paths named in the GPU chapter, which also explains what the CUDA tests establish. For provider selection, VJP ownership, and assurance policies, read Inside the Backend Planner.