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

feat: support batch node groups (aka zipped/pairwise batch nodes) #7553

Merged
merged 23 commits into from
Jan 17, 2025

Conversation

psychedelicious
Copy link
Collaborator

Summary

Adds support for batch node groups.

Previously, multiple batch nodes were combined by taking the cartesian product of their collections and executing the workflow once per permutation.

For example, say we have 2 string batch nodes which route into a string join node:
image

This results in 2 * 2 = 4 workflow executions. Every possible combination of strings are fed into the join.

These are the outputs of the join:

  • "a cute cat"
  • "a cute dog"
  • "a ferocious cat"
  • "a ferocious dog"

With batch node groups, all batch nodes in a group are first zipped together before the product is taken. The zipped group then functions like a single batch node in the product operation.

Set the two string batch nodes to the same group:
image

This will result in 2 executions. The string batch values are zipped/paired, so that the first items in both collections are used in the first execution, and the second items in both collections are used in the second execution.

These are the outputs of the join with the two batches grouped:

  • "a cute cat"
  • "a ferocious dog"

Notes:

  • Any number of batch nodes can be in a batch group.
  • All batch nodes in a batch group must have the same number of items in their collections.
  • Batch nodes must connect to something. No floating lonely batches.
  • Grouped and ungrouped batch nodes can be combined arbitrarily in a workflow. The only limitation is you can have a max of 5 groups. Technically, the backend supports any number of groups, but 5 should be enough for 99.99% of use-cases and makes for a much simpler implementation.
  • The Invoke button tooltip will tell you how many total executions will be queued.

Related Issues / Discussions

offline discussion

QA Instructions

Try it out.

Merge Plan

This PR is dependent on #7545.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog

@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations frontend PRs that change frontend files labels Jan 14, 2025
@skunkworxdark
Copy link
Contributor

skunkworxdark commented Jan 15, 2025

Can these batch nodes take a collection input to build the list up elsewhere?

e.g. The string batch input could be fed via the prompts from file node

If not, could a load from file option be added to the node?

@psychedelicious psychedelicious force-pushed the psyche/feat/ui/more-batch-types branch from 4de524d to b6aae16 Compare January 15, 2025 22:46
@psychedelicious psychedelicious force-pushed the psyche/feat/zipped-batches branch from 3fe8ae4 to 74a4197 Compare January 15, 2025 23:21
@github-actions github-actions bot added the Root label Jan 15, 2025
@psychedelicious psychedelicious marked this pull request as ready for review January 17, 2025 00:52
@psychedelicious
Copy link
Collaborator Author

Can these batch nodes take a collection input to build the list up elsewhere?

e.g. The string batch input could be fed via the prompts from file node

If not, could a load from file option be added to the node?

Batch and generator nodes cannot interact with with non-batch nodes. But we can do things like load prompts from file by implementing it in javascript. For example, load from file -> browse FS for file -> load and parse directly in the UI.

@psychedelicious psychedelicious force-pushed the psyche/feat/ui/more-batch-types branch from b6aae16 to 8a29a11 Compare January 17, 2025 01:02
Base automatically changed from psyche/feat/ui/more-batch-types to main January 17, 2025 01:19
@psychedelicious psychedelicious force-pushed the psyche/feat/zipped-batches branch from 74a4197 to 81e21cc Compare January 17, 2025 01:23
@psychedelicious psychedelicious enabled auto-merge (rebase) January 17, 2025 01:23
@psychedelicious psychedelicious merged commit 2bbcd42 into main Jan 17, 2025
15 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/zipped-batches branch January 17, 2025 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files Root
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants