Metadata-Version: 2.5
Name: lemma-ml
Version: 0.1.0
Summary: A tiny PyTorch-style ML library: an LLM writes the CUDA, Bend proves it equal to your code.
Project-URL: Homepage, https://github.com/Fortuna-laboratories/lemma
Author: Francesco Sacco
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: libclang>=18
Requires-Dist: numpy>=2
Provides-Extra: cuda
Requires-Dist: cupy-cuda13x>=14; extra == 'cuda'
Requires-Dist: nvidia-cuda-nvrtc<14,>=13; extra == 'cuda'
Requires-Dist: nvidia-cuda-runtime<14,>=13; extra == 'cuda'
Provides-Extra: cuda12
Requires-Dist: cupy-cuda12x>=13; extra == 'cuda12'
Requires-Dist: nvidia-cuda-nvrtc-cu12; extra == 'cuda12'
Requires-Dist: nvidia-cuda-runtime-cu12; extra == 'cuda12'
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# Lemma

**Lemma is a tiny PyTorch-style ML library. It uses an LLM as a stochastic compiler that writes optimized CUDA kernels, and it formally verifies that each kernel is correct.**

> This is a proof of concept, not a production-ready ML library.

```bash
pip install "lemma-ml[cuda]"      # NVIDIA driver with CUDA 13
pip install "lemma-ml[cuda12]"    # drivers that only support CUDA 12
lemma doctor                      # checks the GPU, clang, Bend and the LLM agent
```

The package installs as `lemma-ml` and is imported as `lemma`.

## How it works

1. You write Python code with Lemma. It looks like PyTorch.
2. Lemma compiles it twice: to a naive intermediate representation (IR), and to a CUDA kernel written by an LLM.
3. The LLM's CUDA is parsed by clang and lifted to the same IR.
4. [Bend](https://github.com/bendlang/bend) proves the two IRs equal, over real arithmetic.
5. Only a kernel that passes the proof is installed and run on the GPU. If none passes, compilation raises `lemma.verify.Rejected`.

The literature calls this *translation validation*: proving that optimized code is equivalent to the spec it was compiled from.

License: Apache-2.0. Copyright 2026 Francesco Sacco.
