Closed ss2165 closed 6 days ago
Attention: Patch coverage is 90.93484%
with 32 lines
in your changes missing coverage. Please review.
Project coverage is 85.82%. Comparing base (
9962f97
) to head (6b3085d
). Report is 16 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚨 Try these New Features:
This PR contains breaking changes to the public Rust API.
I'm wondering about the purpose of static inputs. So these are statically known runtime values, which are statically known because they are produced by a const node? We already have a mechanism to provide statically known information to an operation via TypeArg
s; this isn't a hack but appears to be the most natural way to do this anyway. In that light I'd advocate for removing static inputs entirely instead of allowing multiple of them. Am I missing something?
I'm wondering about the purpose of static inputs. So these are statically known runtime values, which are statically known because they are produced by a const node? We already have a mechanism to provide statically known information to an operation via
TypeArg
s; this isn't a hack but appears to be the most natural way to do this anyway. In that light I'd advocate for removing static inputs entirely instead of allowing multiple of them. Am I missing something?
We do not allow hugr::ops::constant::Value
inside TypeArg
s because Value
does not have ==
. Allowing Value
inside TypeArg
would mean that Type
would not have ==
, which is untenable.
Value
cannot be given ==
because:
Value::Function
, i.e. an embedded HUGR. A Hugr can't have ==
because Value
can't, and because equality of programs is problematic.CustomConst
which does not support equality.CustomConst
cannot be given ==
because:
....and specifically, TypeArg
does not allow to contain static functions.
Now, IIUC there are proposals to allow a TypeArg:Node
, which if it referenced a funcdefn, would allow a "loadconst"-like op to produce a function value (the TypeArg replacing the Const, or indeed, you could say it was a "loadfunction"-like op) - and then removing the ability to have Hugr's nested inside consts (==> equivalent to saying static function values can only be produced by LoadFunction). I haven't thought through monomorphic-vs-polymorphic, typeapply, etc. yet tho
In that light I'd advocate for removing static inputs entirely instead of allowing multiple of them
In some sense, this could well be where we are headed - but we certainly wouldn't want to remove them until we have finalized+implemented https://github.com/CQCL/hugr/discussions/1425! So in the meantime, aren't "static inputs" just the hugr-core way of representing (with nodes and edges) the noderef-like "terms" proposed in that discussion?
So in the meantime, aren't "static inputs" just the hugr-core way of representing (with nodes and edges) the noderef-like "terms" proposed in that discussion?
I don't think so. This PR introduces an additional parameter list to operations, so that operations can have three different types of inputs:
TypeArg
in core, Term
in model)And this does not appear to be an implementation detail, but part of the specification of an operation.
operations can have three different types of inputs:
- static values (TypeArg in core, Term in model)
- runtime values, but statically known
- runtime values
I thought the idea of #1425 was that the first two of these would be Terms in the model, which would include all "constant values" (probably excluding nested Hugrs, instead allowing references to function nodes). That some of these Terms would (at least initially) be turned into nodes with edges and others would be left as TypeArgs is an implementation detail of hugr-core and not part of the model.
That some of these Terms would (at least initially) be turned into nodes with edges and others would be left as TypeArgs is an implementation detail of hugr-core and not part of the model.
Yes, in the standup where we gave the thumbs up for this I understood it in that way. But that appears not compatible with how this PR does it since it makes static inputs into their own part of the signature. It therefore can't be a hugr-core
implementation detail.
That some of these Terms would (at least initially) be turned into nodes with edges and others would be left as TypeArgs is an implementation detail of hugr-core and not part of the model.
But that appears not compatible with how this PR does it since it makes static inputs into their own part of the signature. It therefore can't be a
hugr-core
implementation detail.
I'm not sure I understand here - PR leaves the signature of a node unchanged, as a pub type Signature = FuncTypeBase<NoRV>
. An OpDef now has a type_row of static inputs as well, i.e. an OpDefSignature
rather than a PolyFuncTypeBase<RowVariable>
- is that the problem, i.e. in the serialization==model-representation of extension definitions ?
PR leaves the signature of a node unchanged,
Don't think this is true it may not be stored in the dataflow signature part but nodes still have to report their static signature, like using ExtOpSignature
for extension ops.
Don't think this is true it may not be stored in the dataflow signature part but nodes still have to report their static signature, like using
ExtOpSignature
for extension ops.
Ah I see. Yes if that gets written out in the model then that doesn't sound like what we want. That info will eventually go in the model in the Term (equiv to TypeArg) part, IIUC.
Closing as stale, subsumed by work in #1433
Extension operations can now have some number of static inputs that come between their dataflow input ports and the state order input port.
This can be used for compile-time-known inputs to operations. I have attempted to keep the serialization backwards compatible.
OpDefs can either declare their static inputs as a row, or it can be calculated like the rest of the signature.
Closes #1594
BREAKING CHANGE:
OpType, OpTrait, DataflowOpTrait
methods which assumed one static input now support many. E.g.static_input_port
->static_input_ports
. Returning aVec
rather than anOption
. Operation definitions support static input type declarations, so a new typeOpDefSignature
has been introduced for this to hold thePolyFuncTypeRV
and the static inputs. The cached signature of an ExtensionOp is also a new typeExtOpSignature
that holds the dataflowSignature
and the static inputs.OpTag::StaticInput
removed because it doesn't actually narrow things down any more.