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

Support passthrough/skipping nodes #2805

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

RunDevelopment
Copy link
Member

Fixes #373.

I had to change a lot of stuff, because passthrough affects not only how chains are executed, but also the type state and visuals of the chain.

The UI

I changed the disable toggle to be an icon that opens a popover. It now only displays the current state of the node (enabled, disabled, skipped) and has a tooltip explaining the current state.

image
image

When a node is skipped, all inputs that are not mapped to outputs will be faded out. This makes it easy to see that those inputs do not have an effect anymore. This is consistent with how disabling a node makes the whole node transparent.

image

How inputs are mapped to outputs

To skip a node, we need to know how to rewire inputs to outputs. This is done is 2 ways:

  1. By using simple rules to automatically determine the mapping.
  2. By manually declaring the mapping in the backend.

This allows us to correct the automatic mapping if it doesn't work for a particular node (which should be very rare). The manual mapping is done with Output().as_passthrough_of(input_id).

I added a new shape_as=input_id property to ImageOutput. This new property has 3 functions: (1) it will set the output type to the shape of the given input image, (2) it will make this output a passthrough for the input, and (3) it will be used to check the shape of the returned image (not implemented yet). This means that we already have quite a few nodes that manually set the mapping, which is good.

The automatic method works almost exactly as proposed by @theflyingzamboni in #373. The only differences are that I handle a few more edge cases and that I always pick the first input (regardless of whether if there are other possible mappings). See the PassthroughMap class for details.

How passthrough is implemented

I implemented passthrough as a frontend optimization. So the backend has no concept of passthrough except for manual mappings. It's implemented alongside the other optimizations (e.g. removing disabled nodes) and works by simply rewiring edges.

From
image

To
image

The optimization for removing unused nodes without side effects will then take care of removing skipped nodes. Since we only remove one level of skipped nodes per optimization, I changed the optimizer to perform multiple passes. This will correctly remove chains of skipped nodes.

@joeyballentine
Copy link
Member

I wanna test this out before merging, but it'll be a few days before I can do that

Copy link
Member

@joeyballentine joeyballentine left a comment

Choose a reason for hiding this comment

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

Works perfectly. Good job

@joeyballentine joeyballentine merged commit fae9cbd into chaiNNer-org:main Apr 24, 2024
17 checks passed
@RunDevelopment RunDevelopment deleted the pass-through branch April 24, 2024 12:04
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.

Node disable/passthrough
2 participants