Draft: StrictCompositeComponent - #295
Draft
gpeairs wants to merge 6 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
gpeairs
marked this pull request as draft
August 26, 2026 15:51
47 tasks
Member
Author
|
Minor things so I don't forget
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a draft of a proposed v2.0 CompositeComponent change, which would be introduced in v1 as StrictCompositeComponent. The main idea is to allow the type of every node in the graph to be derived from the composite component type. Opening a PR now for visibility/discussion.
With current CompositeComponents, anything can happen in
_build_subcomponentsor_graph!. Two instances of the same type can have different subcomponent types, different numbers of nodes, different node IDs, different hook mappings, all of which can only be determined at runtime. This is annoying in several places, for example:map_hookskeys on node index, which doesn't have static meaning and depends on the order the graph is built up; ParameterSet addressing has no guarantees about subcomponent namespaces; type-level validation in general is impossible.So in more detail, we want:
Type{MyComp}aloneType{MyComp}alone (separate from slots so you can have one subcomponent in multiple nodes)map_hookskeyed by node ID_build_subcomponentsderivable from declared slots + parameter filtering/forwardingPathsubcomponents can still be used, but they have to be built up in_graph!. Route subcomponents are trickier, they probably have to be added in_graph!, which is possible (weakening some guarantees, but not so harmful in this case). Templates are still possible (with fixed types) -- just another kind of parameter forwarding -- but maybe this is also an opportunity to better formalize them.I can imagine cases where users want to customize the node ID or component name as a parameter (for compatibility with some changing external schema). Maybe that can done with a variant, although variant composites still have issues with ParameterSet.
You can have variable subcomponent types if you use type parameters (see
ExampleStrictRectangleTransmon{JunctionType}).We could go one step further and require that edges be specified at the type level (call that "DeclarativeCompositeComponent"), so that
_graph!is also fully determined. This is maybe too restrictive to require in general -- harder to work with Paths, edges created withattach!, or routes, although maybe we could find a way.