Neural wiring diagrams for message passing in multiscale organizations
In our recent paper, “Dynamic task delegation for hierarchical agents”, Sophie Libkind and I described a task delegation from an agent to a team of subordinates as morphisms in a certain operad called . However, such morphisms include a great deal of data, and the examples we gave there barely scratched the surface of what’s possible. In this post I’ll show how “recumbent” neural wiring diagrams—with arbitrary feedback and “axon” splitting—give rise to a message-passing language for describing certain such task delegations. That is, I’ll define a cyclic operad and a functor .
The arXiv paper that this post cites contains an error, and had to be taken down for the time being. However, the math in this post still stands.1
1 Introduction
In our recent paper, “Dynamic task delegation for hierarchical agents”,2 Sophie Libkind and I described what we called task delegations, procedures involving an agent and a team of subordinates, as the morphisms in a certain operad . Think of agents as things that perform tasks, like travel agents, agent 007, and cleaning agents: you give the agent a task of some type, and it comes back to you with an outcome.
We formalize this in terms of what we call “task-solution interfaces”, but which I want to call portfolios. A portfolio consists of a set of tasks and for each task a set of possible outcomes for that task. Then an agent is understood as something connecting one portfolio—the set of tasks that can be assigned—to a bunch of portfolios, one for each of ’s subordinates. The agent itself is intuitively an “evolving planner”: it performs a task by planning how to orchestrate its subordinates in solving their own subtasks and using those solutions to choose new subtasks for them to solve, repeatedly, until principal agent is ready to determine an outcome . Once this task is solved, can “evolve” in the sense that it can update how it will plan tasks in the future.
Sophie and I formalized all of this is formalized using the theory of polynomial functors. A portfolio is a polynomial ; these are the objects, and agents are the morphisms, in a category-enriched operad . The morphisms are given by the formula where is the free monad monad, is an inner hom, and is the category of coalgebras for a polynomial . If you’re reeling from either the weight of all that notation or from the sheer amount of data in such a thing, this is normal. On the one hand, it makes sense: there should be a lot of room within the realm of all “evolving planners,” so has to package all that. On the other hand, we need intuition for what sorts of things we can say in this language.
In this blog post, I’ll show how recumbent wiring diagrams give a way to visualize cases of such hierarchical planning, though they are still relatively simple compared to what’s possible. Recumbent string diagrams were those used by Joyal and Street in their seminal work on string diagrams, though I learned about them from Delpeuch and Vicary. Let’s begin there, then move on to how they connect to my work with Sophie, then generalize to add wire-splitting and feedback, and finally conclude.
2 The operad of recumbent wiring diagrams
Recumbent string diagrams in the sense of Joyal and Street are graphs embedded in the plane, which look as shown on the left; I’d usually draw them as wiring diagrams, as shown to the right:
The thing to notice about the graph is that none of the wires go backwards, and that no two vertices project to the same point on the -axis; this is the “recumbency” requirement. In terms of computations, this says that no two computations take place at the same time.
There are a couple of differences between string diagrams and wiring diagrams. First, string diagrams were presented as topological and embedded in the plane, whereas wiring diagrams were presented as combinatorial and just about connectivity. Second, string diagrams do not include an outer box, because they are understood as being built up from monoidal product and composition, whereas wiring diagrams do include the outer box, because they are understood as morphisms in an colored operad and the outer box is the codomain . In this post, we’ll take an operadic viewpoint, but we’ll need the recumbency condition from Joyal and Street: not the topology, but the fact that no two vertices / boxes occur at the same time.
The operad of wiring diagrams for symmetric monoidal categories is the story of how you can nest whole wiring diagrams into boxes. Indeed, the objects in this (colored) operad are the box shapes, the morphisms are the wiring diagrams, and placing a wiring diagram into a box is composition. Recumbent wiring diagrams also form an operad, one that’s much easier to write down, as I’ll now explain.
Fix a set of “wire labels”; a finite -set is a pair , where is a finite set and picks a label for each . We define a box to be a pair of finite -sets. For example, and would be drawn
A recumbent wiring diagram (or WD), denoted , is defined as a list of finite -sets together with -preserving bijections for each , where and and and . That all sounds confusing but let me rewrite it in case : The idea is that the represent the extra wires that are present at the same time as box .
Let’s do an example, but with one label to avoid having to consider labels.
There is one additional wire present during and another additional wire present during , so we have , , and . Here , , , , , , , and . And we have the desired bijections
Recumbent wiring diagrams (with labels in ) can be substituted in an obvious way, so they form a multicategory, also known as a nonsymmetric colored operad. We’ll denote it .
3 Recumbent WDs as message passing plans
In my work with Sophie, we were interested in evolving planners, but in this section we’ll take the “evolution” out of it. We’ll see that for any function , there is a map of multicategories The idea is that a recumbent wiring diagram gives a message passing plan, which is a morphism in . In fact, it’s an especially simple sort of morphism. Namely, the morphisms that arise via the “message passing” functor will be constant: the corresponding coalgebra only has one state, so as mentioned there is no evolution involved. Second, these morphisms will not use the monoidal product but instead the much simpler monoidal product . Recall that , which allows one or more things to happen simultaneously. Clearly there is a map , which avoids all simultaneity. In other words, these planners only talk to one of their subordinates at a time. In case it wasn’t clear, this corresponds to the recumbency requirement.
So how does work? Before we answer that, let’s simplify the target category a bit. Let denote the Kleisli category of the free monad monad . Its objects are polynomials and a map is a natural transformation . To each position (task) , it assigns a flowchart of -tasks, and then returns the result as an outcome in . This is the category that Harrison Grodin called the category of poly-morphic effect handlers. Coproducts in lift to coproducts in , so we can consider the operad whose morphisms are of the form and we again denote this . The idea is that assigns each task in a flowchart of tasks from different ’s, one at a time.
There is an identity-on-objects inclusion that includes such as the constant coalgebras , so to obtain a map of operads as in (MP), it suffices to find an operad functor So again, we ask how does this functor work? First we’ll give the full technicalities and then give a simple example; the reader can feel free to skip to right around the diagram (myWD) below. So here go the technical details. Let’s begin with how works objects.
Recall that a box is a pair of finite -sets. For each , let and, for , let . Then the functor sends that box to the polynomial For example, if the box has two wires on the left and one on the right, with associated sets and , then will send it to .
Let’s move on to morphisms. Suppose that are boxes and that is a recumbent wiring diagram given by finite -sets and bijections , as in [rWD]. These give rise to bijections These in turn give rise to projection maps These immediately give rise to a map of polynomials and hence the required map of polynomials
While the above few paragraphs may be a bit technical for a blog post, one sees that to turn a recumbent wiring diagram into the required map of polynomials is really just a matter of putting isomorphisms and projections together. But perhaps we can clarify a bit more what’s happening on a simple recumbent wiring diagram such as the following:
We’ll use the labels to also denote the sets assigned by , and we’ll use juxtaposition to denote products, e.g. means . Then is supposed to be a map of polynomials Since there’s always a map , it suffices to find a map of polynomials and this is the same as three maps all of which we can take to be projections. Now what do all these projections mean in terms of the diagram in (myWD)?
On the left side of the surrounding box, we have two wires and , so an element of the product set “comes in” on the left. Its first projection to is delivered to the box . Then, an output of that box is of the form , so now we have at our disposal, and projection gives rise to inputs of the form which are delivered to the second box. Then, an output of that box is of the form , so we now have at our disposal, and projection gives rise to an element of the form which is delivered to the right side of the surrounding box.
But we can do better with less work.
4 A cyclic operad of recumbent “neural” WDs
In this section we’ll see that we can get what we might call neural wiring diagrams,
diagrams with splitting and feedback, by simply relieving ourselves of constraints we never used! For example, nothing in the definition of needed the maps in (rWD) to be bijections; what we actually used were functions in the direction of the inverses of the isomorphisms shown. We also can dispense with labels and the function and use polynomials to represent collections of wires. The polynomial can be used to represent two wires, one carrying set and one carrying set . We want to imagine those two wires together carrying elements of type , and this is exactly the set of ’s “global sections”. Note that the global sections functor is contravariant and strong monoidal:
So a polynomial represents a set of wires, and for each wire , a set that the wire is “carrying”. A map of polynomials sends each -wire to a -wire as well as a function . For example, if and , then such a map would be given by two functions and , which we could draw this way
With this technology, we can describe recumbent neural wiring diagrams as forming a cyclic operad . An object is a pair of polynomials, representing a box with input ports and output ports . For any , a -ary morphism is going to represent a recumbent neural wiring diagram. For example we will be able to represent this diagram
as a map , where To see how, we need to define the maps in the cyclic operad . They are actually pretty simple: we pick a few (in this case three) polynomials to represent the extra wires that hold values while various boxes are firing, and then we write down a bunch of polynomial morphisms to say how the wires relate from one time step to the next.
So the idea is that we can use these to define agents in the sense of my paper with Sophie. Whereas for an arbitrary agent in , the agent has a great deal of control over the way information is passed between its subordinates, an agent arising via the functor always has its subagents pass messages according to the wiring diagram (rnWD2). The only thing these simpler agents do is to hold state, namely whatever is currently in the feedback wires. Let’s get into it.
Recall that for any , the cyclic group has elements which add according to modular arithmetic, e.g. and . Now we can define the maps as follows: For the diagram (rnWD2), there are inner boxes, represents the feedback wire, represents the (forward-going) wires holding values while is firing, and represents the (forward-going) wires holding values while is firing. We invite the reader to use (rnWD2), which includes some function , to guess the maps corresponding to . Anyone who knows polynomial maps will not find these difficult to guess without even checking the diagram, but then can use the diagram to verify that it all makes sense.
So we’ve now seen that polynomials give a very compact way to represent recumbent neural wiring diagrams. But the point is that these can be used to represent some morphisms in . That is, we will now construct a functor This functor on objects is given by . We’ll denote this latter polynomial as follows: Where does send a morphism ? Again, let and , and suppose , where for each , we write and This morphism must be sent to an object in This looks a bit daunting, but it’s all notation; everything is actually quite calm.
The carrier of this coalgebra will be the set of values on the feedback wires, . It suffices to find a map We just apply to the maps we already had:
and by the universal property defining , this is equivalent to the desired map. So in the case of (rnWD2), this would be All together these give rise to a map as desired.
5 Conclusion
In this post we showed how recumbent wiring diagrams provide a syntax for by specifying a functor from a cyclic operad of wiring diagrams into this complicated object . Both the objects and the morphisms in are much more general than what arise from the functor. But gives a baseline understanding of what is possible in . While maps in might be called “evolving planners" or”evolving programs”, some of these are given by pure message passing, or pure “neuron firing” protocols, as dictated by a neural wiring diagram.
Footnotes
It turns out that the free monad monad is monoidal as a functor, but not as a monad, with respect to the -product; in particular, the monad multiplication is not a -monoidal natural transformation. This means that the Kleisli category of the free monad monad is not monoidal, but only pre-monoidal, with respect to . This post only relies on the -monoidal structure, and every monad is monoidal with respect to coproducts when they exist. Hence, this post still stands. I will make appropriate edits throughout.↩︎
See the edit at the top of this blog post.↩︎