No explicit copy #80
Replies: 9 comments 12 replies
-
Not convinced. I realize copies lead to difficulties, but they also solve problems.
Another way of looking at it is that having a copy node is a great way of capturing all the issues with linearity into one place...maybe we should consider whether there are other ways around the builder problems etc. I note these problems are all with the implementation - so there is something to be said for making spec + implementation diverge on this front. However if the spec details all the API calls, does the presence/absence of copies not change any of these APIs? And, if we keep copies in the implementation, I guess that doesn't help solve the problems in the builder - so what other problems are there with copy nodes that we are thinking about? |
Beta Was this translation helpful? Give feedback.
-
I don't follow here: why does the state (order) edge need to be copied to the copy node? |
Beta Was this translation helpful? Give feedback.
-
I'd like to see some elaboration/enumeration of the other problems whose existence is implied by "e.g. in the builder, if there is a state edge". I wonder if that one might be solved by constructing a copy node (in the builder) for every non-linear port, and then eliding copy1's in |
Beta Was this translation helpful? Give feedback.
-
From the implementation side, I think we can have a nice interface if we allow logical multiports. The main annoyance I see is having to modify the underlying ports (let's call them physical ports) each time we connect or disconnect a classical wire. Now that we have port capacities however, this cost is reduced (although it still requires shifting the following physical ports, and updating the links). We have to redefine |
Beta Was this translation helpful? Give feedback.
-
A nice side-effect is that |
Beta Was this translation helpful? Give feedback.
-
So initially I thought that, due to difficulties in (I think) (Builder) implementation, the proposal was to change the spec (and even perhaps keep the implementation the same) - that didn't seem the right approach. I am somewhat neutral on the spec. I note the spec came after the implementation, i.e. following Lukas' implementation-focused work in Hack Month! (We did at that time consider having two kinds of port, non/linear, but decided it looked like too many levels of indirection in the implementation and rather ugly.) If the implementation can be made nicer by changing the idea of copy nodes, maybe the spec should once again follow after the implementation is settled. Clearly it seems that Agustin and others have ideas on how the new implementation could look - are these spelled out in more detail anywhere? One property that we don't really capitalize on at the moment is that the only nodes that have variable-output-arity have no other outputs of that kind. Indeed, excluding dataflow nodes, they have no other outputs (e.g. Oh, and CFG nodes have variable-arity inputs.... |
Beta Was this translation helpful? Give feedback.
-
summary of chat with @acl-cqc and @aborgna-q
|
Beta Was this translation helpful? Give feedback.
-
A potential solution to building graphs conveniently when using explicit copy nodes would be a method that, when given a port, does the following:
If we want copying to be more implicit, there is options:
|
Beta Was this translation helpful? Give feedback.
-
Explicit copy nodes lead to lots of difficulties. We found this with Tierkreis. The problems stem from the fact that there is some strong coupling between the source of the value and the copy node, which leads to special casing on copies. E.g. in the builder, if there is a state edge on a node, an output of which is then copied, the state edge either needs to move or be copied on to the copy node.
I propose instead changing to allowing multiple edges leaving a classical output port.
In the spec we use the copy for:
In terms of implementation, this can be done by still using copy nodes in the underlying portgraph. By obscuring global
PortIndex
in the hugr interface (using instead(NodeIndex, PortOffset)
to identify ports), we can map the source of edges leaving copy nodes to original output port.Beta Was this translation helpful? Give feedback.
All reactions