TorchLean API

NN.Backend.Capsule

Backend Capsules #

A backend capsule is TorchLean's unit of delegation to fast code.

The capsule does not prove the foreign implementation. It records the contract TorchLean expects from that implementation: which op it implements, which spec it refines, what layout and shape conventions are assumed, how the value/VJP claims are justified, and what trust level the planner must account for.

A source file inside the TorchLean checkout that supports a backend contract.

Instances For
    Instances For
      @[implicit_reducible]
      @[implicit_reducible]

      Reference to a native/FFI symbol used by a backend capsule.

      The linter checks that path exists, that symbol occurs in that source file, and that buildTarget?, when present, names a Lake target in lakefile.lean.

      Instances For

        Whether a selected capsule is wired to an executable runtime path.

        • eager : RuntimeSupport

          The capsule can be selected by an eager runtime path.

        • testOnly : RuntimeSupport

          The capsule has a direct bridge/check, but is not selected by the eager runtime yet.

        • plannerOnly : RuntimeSupport

          The capsule is useful for planning/auditing only.

        • notWired : RuntimeSupport

          The capsule is intentionally registered before runtime wiring exists.

        Instances For

          Source-level provenance for a contract descriptor. Provenance is not correctness evidence.

          Instances For

            Concrete tensor-layout convention named by a backend contract.

            • canonicalTensor : TensorLayout

              TorchLean's ordinary typed tensor representation.

            • flatRowMajor : TensorLayout

              Contiguous flat storage with the last axis varying fastest.

            • libTorchCudaView : TensorLayout

              A contiguous CUDA tensor view owned by LibTorch.

            Instances For

              A structured backend obligation, independent of how evidence for it is obtained.

              Instances For
                Instances For

                  How a capsule justifies one part of its contract.

                  runtimeGuard and testSuite record useful engineering assurance but do not discharge a theorem. Only theorem and checker contain proof terms.

                  Instances For

                    A structured contract claim together with its evidence and human-readable explanation.

                    Instances For

                      A contract claim enforced by a named runtime guard.

                      Instances For

                        A contract claim covered by a named regression suite.

                        Instances For

                          A contract claim delegated to an explicitly named trusted boundary.

                          Instances For

                            The four contract fields carried by every kernel capsule.

                            Instances For

                              Whether a claim has the expected kind and operation for a capsule contract field.

                              Instances For

                                A contract-carrying fast kernel or reference implementation.

                                Instances For

                                  Whether each descriptor states the obligation advertised by its field.

                                  Evidence is useful only when it proves or checks the right claim. This guard prevents, for example, a value-refinement theorem from being placed in the shape field and then accepted as shape evidence.

                                  Instances For

                                    Stable identity used when adjacent graph nodes select the same registered capsule.

                                    Instances For

                                      Whether the trust policy admits this capsule.

                                      Instances For

                                        Whether the backend preference admits this capsule's provider.

                                        Instances For

                                          Whether this capsule is available on the selected device.

                                          Instances For

                                            Whether the capsule's gradient boundary is compatible with the requested execution config.

                                            none is inference mode, so any forward-capable capsule is suitable even when it also advertises a VJP. externalAutograd is intentionally opt-in. A native backend VJP is still compatible with the normal TorchLean tape mode: the TorchLean tape owns the node and calls the backend for the local VJP.

                                            Instances For

                                              Planner-side admissibility predicate for a single capsule.

                                              Instances For

                                                Pick the first admissible capsule for a typed operation.

                                                Instances For