TorchLean API

NN.Examples.DeepDives.Floats.GraphNumericalCertificate

A graph numerical certificate #

This example certifies a four-node scalar graph:

x in [1, 2]       c in [0.5, 1]
       \             /
        y = x + c
             |
        z = y * c

The source intervals are executable binary32 endpoints. The checker propagates them with directed rounding, rejects non-finite intermediate intervals, and records the backend capsules selected when the portable CPU profile replans the graph. The resulting range trace is an executable check; a ProvedRealEnclosure supplies the separate proof that an exact-real execution is enclosed. Larger graphs use the same artifact-generation and replay path.

The example uses scalar nodes so the interval endpoints remain easy to inspect. The certificate machinery itself stores only one scalar hull per tensor and is independent of tensor rank.

Instances For

    Build a binary32 interval from two bit patterns.

    Every source range in this file is written in hexadecimal rather than as a decimal literal. That keeps the certificate an exact artifact: no decimal-to-binary conversion sits between what is written here and what the checker sees.

    Instances For

      Did an executable certificate operation return a checked value?

      Instances For

        Input and constant assumptions. Hexadecimal endpoints preserve the exact binary32 artifact.

        Instances For

          Replay the same graph using the bit-level IEEE32 interpreter and check every intermediate.

          Instances For

            Deliberately replace the addition range with $[0,0]$. This models a corrupted or optimistic external artifact; replay must not accept it merely because $[0,0]$ is itself a valid interval.

            Instances For

              A complete model pass #

              The small graph above makes each range easy to inspect. This graph runs the same machinery over a two-layer MLP with matrix weights and explicit bias tensors:

              input [1,2]
                -> matmul [2,3]
                -> add bias [1,3]
                -> ReLU
                -> matmul [3,1]
                -> add bias [1,1]
              

              Nothing in certificate generation is told that this is an MLP. The checker sees ten ordinary IR nodes and obtains each transfer from GraphRangeRegistry. Kernel selection independently chooses a capsule for every operation. The final replay executes the stored graph with bit-level binary32 semantics and checks all ten intermediate tensors against the regenerated ranges.

              A two-layer matrix MLP expressed only in the canonical operation IR.

              Instances For

                Source ranges cover inputs, both weight matrices, and both bias tensors. A single enclosure per tensor is sufficient for this certificate format; the graph walk remains independent of rank.

                Instances For

                  Constant payloads use the IR's canonical flat storage ABI; node shapes recover the typed matrix view during evaluation. The explicit order below is row-major.

                  Generate the operation-local range trace and bind it to the checked CPU capsule plan.

                  Instances For

                    Execute the stored graph in the bit-level binary32 interpreter and check every node.

                    Instances For

                      Generate and replay both graphs, and reject the deliberately tampered base artifact.

                      Instances For

                        Help text for the certificate example.

                        Instances For

                          Public runner for the certificate examples. A failed positive check or an accepted negative check produces a nonzero exit code, so this command is also suitable for regression testing.

                          Instances For