Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update spec for Row Variables and no-input-extensions #1402

Merged
merged 9 commits into from
Aug 20, 2024

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Aug 8, 2024

Also some driveby updates e.g. missed in #906.
Closes #1097, #745.

@acl-cqc acl-cqc requested a review from a team as a code owner August 8, 2024 10:00
@acl-cqc acl-cqc requested a review from aborgna-q August 8, 2024 10:00
@@ -791,15 +791,16 @@ There are two classes of type: `AnyType` $\supset$ `CopyableType`. Types in thes
classes are distinguished by whether the runtime values of those types can be implicitly
copied or discarded (multiple or 0 links from on output port respectively):

- For the broadest class (`AnyType`), the only operation supported is the identity operation (aka no-op, or `lift` - see [Extension Tracking](#extension-tracking) below). Specifically, we do not require it to be possible to copy or discard all values, hence the requirement that outports of linear type must have exactly one edge. (That is, a type not known to be in the copyable subset). All incoming ports must have exactly one edge.
- For the broadest class (`AnyType`), the only operation supported is the identity operation (aka no-op, or `lift` - see [Extension Tracking](#extension-tracking) below). Specifically, we do not require it to be possible to copy or discard all values, hence the requirement that outports of linear type must have exactly one edge. (That is, a type not known to be in the copyable subset).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a driveby commoning up, see below

@@ -812,7 +813,7 @@ Extensions ::= (Extension)* -- a set, not a list
Type ::= Sum([#]) -- disjoint union of rows of other types, tagged by unsigned int
| Opaque(Name, [TypeArg]) -- a (instantiation of a) custom type defined by an extension
| Function(#, #, Extensions) -- monomorphic function: arguments, results, and delta (see below)
| Variable -- refers to a TypeParam bound by the nearest enclosing FuncDefn node, or an enclosing Function Type
| Variable -- refers to a TypeParam bound by an the nearest enclosing FuncDefn node or polymorphic type scheme
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dates back to #906!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, by an the back to by an

| BoundedUSize(u64)
| Extensions(Extensions) -- may contain TypeArg's of kind Extensions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just putting in same order as corresponding TypeParams

@ss2165
Copy link
Member

ss2165 commented Aug 8, 2024

I don't think spec should be explicit about inference, I think that is more a feature of the reference implementation.

the union of these two must match the set of extensions on each successor node.
Similarly, every dataflow node in the HUGR has a set of extensions required to execute the node (computed from its operation), also known as the "delta". The delta of any node must be a subset of its parent,
except for FuncDefn's:
* the delta of any child of a FuncDefn, must be a subset of the extensions in the FuncDefn's *type*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit awkward. Suggestions welcome

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just remove the comma I think

Having these as explicit nodes on the graph allows us to search for the
point before extensions were added when we want to copy graphs, allowing
us to get the version with minimal extension requirements.
# Having these as explicit nodes on the graph allows us to search for the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any point in keeping these sections I've commented out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think so

b: List[Type]
signature:
inputs: Sum([a]), Sum([b])
outputs: Sum([(a,b)]) # Syntax! Sum([a,b]) would be either-a-or-b, this has one variant
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bleurgh. It'd be awkward to write these examples not in the "declarative format", but OTOH I don't think we are really moving in this direction, and it's very unclear how to write these ATM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better just to say what it is in the comment

Suggested change
outputs: Sum([(a,b)]) # Syntax! Sum([a,b]) would be either-a-or-b, this has one variant
outputs: Sum([(a,b)]) # sum with a single variant of type (a, b)

@aborgna-q aborgna-q requested review from ss2165 and removed request for aborgna-q August 8, 2024 10:07
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Every node in the HUGR is annotated with the set of extensions required to produce its inputs,
and each operation provides (a way to compute) the set of extensions required to execute the node, known as the "delta";
the union of these two must match the set of extensions on each successor node.
Similarly, every dataflow node in the HUGR has a set of extensions required to execute the node (computed from its operation), also known as the "delta". The delta of any node must be a subset of its parent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Similarly, every dataflow node in the HUGR has a set of extensions required to execute the node (computed from its operation), also known as the "delta". The delta of any node must be a subset of its parent,
Similarly, every dataflow node in the HUGR has a set of extensions required to execute the node (computed from its operation), also known as the "delta". The delta of any node must be a subset of its parent's delta,

the union of these two must match the set of extensions on each successor node.
Similarly, every dataflow node in the HUGR has a set of extensions required to execute the node (computed from its operation), also known as the "delta". The delta of any node must be a subset of its parent,
except for FuncDefn's:
* the delta of any child of a FuncDefn, must be a subset of the extensions in the FuncDefn's *type*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just remove the comma I think

Having these as explicit nodes on the graph allows us to search for the
point before extensions were added when we want to copy graphs, allowing
us to get the version with minimal extension requirements.
# Having these as explicit nodes on the graph allows us to search for the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think so

b: List[Type]
signature:
inputs: Sum([a]), Sum([b])
outputs: Sum([(a,b)]) # Syntax! Sum([a,b]) would be either-a-or-b, this has one variant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better just to say what it is in the comment

Suggested change
outputs: Sum([(a,b)]) # Syntax! Sum([a,b]) would be either-a-or-b, this has one variant
outputs: Sum([(a,b)]) # sum with a single variant of type (a, b)

@acl-cqc acl-cqc enabled auto-merge August 20, 2024 09:34
@acl-cqc acl-cqc added this pull request to the merge queue Aug 20, 2024
Merged via the queue into main with commit 67f0668 Aug 20, 2024
18 checks passed
@acl-cqc acl-cqc deleted the acl/spec_rowvar_exts branch August 20, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update spec wrt RowVariables
2 participants