TorchLean API

NN.Backend.Lowering

Backend Lowering Plans #

Graph-aware lowering data for backend execution.

GraphExecutionPlan chooses a capsule for each runtime-relevant IR node. A GraphLoweringPlan groups those choices into backend calls. The conservative lowering in this file coalesces adjacent nodes only when they use the same operation and the exact same capsule contract. More aggressive fusion can be added later as new capsules with their own contracts.

Why adjacent planned nodes share one audit/scheduling group. This does not assert kernel fusion.

Instances For

    One lowered backend call, with source IR nodes kept for audit and debugging.

    Instances For

      Graph lowering plan: backend groups in execution order.

      Instances For

        Erase lowering metadata to the older single-kernel execution-plan row.

        Instances For

          Whether this lowered group crosses a trusted-external boundary.

          Instances For

            Whether a planned node can be appended to this lowered backend group.

            Instances For

              Append a node to an existing backend group, preserving source-node provenance.

              Instances For

                Source IR node ids covered by the lowering plan, in execution order.

                Instances For

                  Selected capsule names, in lowering order.

                  Instances For

                    Erase lowering metadata to the audit/execution-plan view.

                    Instances For

                      Audit the selected backend boundaries of the lowering plan.

                      Instances For

                        Whether any lowered group crosses a trusted-external boundary.

                        Instances For

                          Lower one graph-planned node to a singleton backend group.

                          Instances For

                            Default lowering: one backend group per runtime-relevant IR node.

                            Instances For

                              Fold state for conservative same-boundary lowering.

                              Instances For

                                Add one planned node to the lowering state, coalescing with the previous group when safe.

                                Instances For

                                  Conservative grouping: adjacent nodes with the same backend boundary share one audit/scheduling group.

                                  This does not claim that one kernel invocation implements the group. A future fused capsule must declare its multi-node pattern and execution contract explicitly.

                                  Instances For