|
Uni20
Asynchronous tensor and runtime library.
|
Status: speculative and non-normative.
This document does not describe an implemented MPI, RPC, or distributed backend. It records constraints and possible layering for future design work. The current local kernel-dispatch contract is defined by `kernel_dispatch.md`.
Distributed execution raises questions that are larger than choosing a local BLAS, LAPACK, CPU, or device kernel. It may require:
The useful idea from local dispatch is composability: a distributed plan may invoke the ordinary local dispatcher for each local leaf. It does not follow that MPI or RPC should simply be inserted as another backend in every local backend_list.
Any future distributed design must preserve the existing Uni20 invariants.
Communication, replication, redistribution, and materialization must be represented by the operation or plan. They must not appear as invisible fallback from a local kernel.
Distributed planning must preserve quantum-number, block-space, local-space, and leg-orientation metadata. A distributed symmetry-aware path may not silently project the operation to one dense matrix.
Logical block identifiers and placement metadata must survive plan construction and local execution.
Rank arrival order, network timing, or scheduler timing cannot establish legality. Dependencies must be represented by epochs, tasks, or another explicit causal model.
A distributed selection protocol may communicate in order to reach one consistent decision. For example, it may use a dedicated collective agreement to accept or reject a candidate. That protocol is not a rank-local KernelAttempt: every participant must remain in the selection phase and observe the same outcome. Failure or disagreement inside the agreement is a terminal plan-construction error, not permission for one rank to continue its own backend walk.
The selected plan becomes committed no later than the first of:
After commitment, failure is terminal for the distributed operation. Falling back to a different distributed algorithm or local backend would otherwise risk duplicate communication or partial output.
A distributed plan eventually hands local descriptors to a local backend. Those descriptors retain their mdspan accessor semantics. Distribution does not make an opaque device buffer host-readable or erase a transform accessor.
A plausible architecture separates global planning from local kernel selection:
The local leaf remains the existing contract:
This keeps local backend lists focused on implementations that can legally operate on the same local arguments.
Two broad designs are possible.
A distributed operation wrapper chooses a plan before invoking local kernels.
Advantages:
Risks:
This is the safer default direction.
`../backends/mpi/persistent_dispatch.md` develops one concrete form of the planner-above-dispatch direction: a root controller validates the distributed operation, chooses or builds an immutable command descriptor, and submits it to worker runtimes.
In that model, workers do not independently walk distributed candidates. They execute the command selected by the controller. A worker may still invoke ordinary local kernel dispatch for a resolved local work item, but a local provider failure after command submission fails the distributed operation; it does not reopen distributed selection.
The collective-acceptance discussion below mainly constrains an expert SPMD mode or a future collectively planned operation. It is not required for every decision in the root-controller model.
A distributed backend could participate in an outer dispatch walk and, after accepting the operation, recursively invoke local dispatch.
Advantages:
Risks:
KernelAttempt vocabulary may be too small for collective planning;This design should be considered only with a precise distributed argument type and a collectively consistent acceptance protocol.
A local kernel_accepts_types result is compile-time and therefore consistent for the same program and argument types. Runtime acceptance is more difficult.
A distributed candidate must not allow:
Possible approaches include:
A collectively agreed rejection may continue to the next distributed candidate. A successful agreement to accept commits the selected plan. A selection-protocol failure or disagreement is a terminal plan-construction error. None of these outcomes is an ordinary rank-local backend decline.
A distributed value needs an explicit model for:
These properties are not mdspan layout. An mdspan describes one resolved local view; it does not describe the global ownership graph.
A future distributed operation should lower global values to local work items carrying both logical identity and placement. Local kernel dispatch should see only the resolved local descriptors needed for that work item.
Distributed execution is naturally asynchronous, but the design must still distinguish three levels:
A possible task graph is:
Raw threads and scheduler timing are not substitutes for these dependencies.
Before implementation, the design needs explicit answers for:
A local KernelDispatchError may be one component of a distributed diagnostic, but it is not sufficient by itself.
Useful distributed diagnostics would likely include:
Diagnostics must not require extra collectives that change execution semantics unless diagnostic collection is itself explicitly enabled and safe.
A distributed implementation would need deterministic focused tests for:
The following questions are intentionally unresolved:
Async<T> epochs?Material from this document should move into normative subsystem documentation only after the repository contains:
Until then, examples here are architectural sketches rather than promised APIs or roadmap commitments.