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

Allow any valid node with no incoming connections and with side effects to run automatically #2944

Merged
merged 8 commits into from
Jun 17, 2024

Conversation

joeyballentine
Copy link
Member

  • Refactored useRunNode a bit, moving some of the qualifications into the hook
  • Changed the definition of starting node to be any valid node without an incoming connection. This means we can run far more nodes ahead of time now. The cache is properly cleared once a node has an incoming connection.

This is necessary to be able to allow connections to Load Image. (which I will do in a separate future PR)

@RunDevelopment
Copy link
Member

This needs to be an opt-in system, I think. We have nodes like Create Noise that can potentially take multiple seconds to run. I think the a1111 web UI Text to Image node is also valid without incoming connections. Having nodes like this run every time you change an input isn't a good idea.

@RunDevelopment
Copy link
Member

And about correctness: isStartingNode now isn't correct anymore, since it doesn't consider the incoming connections of a node. You need to review every usage of this function.

@joeyballentine
Copy link
Member Author

That's a valid concern. But also, I think you misread this PR. I didn't change the actual isStartingNode function. In fact, I don't even use it for this calculation anymore.

@joeyballentine
Copy link
Member Author

joeyballentine commented Jun 8, 2024

Having nodes like this run every time you change an input isn't a good idea.

I thought about this for a bit, and I'm wondering if this is actually true. We're basically just running any node we can run individually ahead of time, which will end up saving a bit of time when the entire chain is run. I don't really see a downside.

In fact, I almost think these nodes (create noise, create gradient, etc) should have a large image output like load image, so you can create the image and visualize it without having to re-run the chain constantly to see it.

@joeyballentine
Copy link
Member Author

One thing to note is that since this doesnt actually change the isStartingNode function, the hook for doing those fast type tags won't run for these anymore, so I'm thinking I probably should change it to be done there instead.

As for implementation, I'm thinking of making "starting nodes" have side effects (technically all of them do anyway since they display some kind of information after being run. The idea is that since these nodes need to run, and we run them automatically, they have side effects. Limiting this to just nodes with side effects would mean we can opt-in to this feature in an easier way. Thoughts?

@joeyballentine
Copy link
Member Author

I got rid of the isStartingNode function and replaced it with a new hook that determines whether "automatic" features should be used. Then, i made it so that the load nodes have side effects, and use side effects to help determine whether the node should run. Technically, these nodes do have side effects, so it was kinda incorrect before anyway.

I still would kinda like to have more nodes run automatically, but i think i'll just give those nodes large image outputs in a separate PR and give them side effects.

.vscode/settings.json Outdated Show resolved Hide resolved
@joeyballentine joeyballentine changed the title Allow any valid node with no incoming connections to be a "starting node" Allow any valid node with no incoming connections to run automatically Jun 17, 2024
@joeyballentine joeyballentine changed the title Allow any valid node with no incoming connections to run automatically Allow any valid node with no incoming connections and with side effects to run automatically Jun 17, 2024
@joeyballentine
Copy link
Member Author

Going to merge this as I need it for what i'm going to work on next. Feel free to make PRs for any further suggestions

@joeyballentine joeyballentine merged commit 5035430 into main Jun 17, 2024
17 checks passed
@joeyballentine joeyballentine deleted the starter-node-redefine branch June 17, 2024 04:50
@@ -166,6 +166,7 @@ def _for_ext(ext: str | Iterable[str], decoder: _Decoder) -> _Decoder:
DirectoryOutput("Directory", of_input=0),
FileNameOutput("Name", of_input=0),
],
side_effects=True,
Copy link
Member

Choose a reason for hiding this comment

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

@joeyballentine Making these nodes side-effect nodes is major change. It completely messes up our current system of "only nodes with side effects run" and is going to cause these nodes to be executed unnecessarily.

Why did you make this change in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

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

It actually doesn't mess that up in practice, at least not that I found in testing. I think it's because they already run.

Anyway, I did that because they technically do have side effects. I explained this. We've even talked about similar things before: when I gave every image output a preview, you said they all had side effects. When we talked about giving every node the ability to toggle an image preview inline in the output, you said we'd need a way to toggle side effects on those nodes.

Why is that suddenly not the case now?

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.

2 participants