8000 Add backend primitive nodes by huchenlei · Pull Request #7328 · comfyanonymous/ComfyUI · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add backend primitive nodes #7328

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

Merged
merged 2 commits into from
Mar 21, 2025
Merged

Add backend primitive nodes #7328

merged 2 commits into from
Mar 21, 2025

Conversation

huchenlei
Copy link
Collaborator

This PR adds backend primitive node implementations for Int, Float, String, and Boolean types.

image

Motivation

The current frontend-only primitive nodes have two key limitations:

  1. Node inlining in API format
    • When exporting to API format, primitive nodes are removed and values are inlined to node inputs
    • This creates a disconnect between UI workflow and API payload
    • Developers can't easily determine shared values from the API format alone

Example: From API workflow, it's not obvious that two KSamplers share the same seed value

image

{
  "2": {
    "inputs": {
      "seed": 0,
      "steps": 20,
      "cfg": 8,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1
    },
    "class_type": "KSampler",
    "_meta": {
      "title": "KSampler"
    }
  },
  "3": {
    "inputs": {
      "seed": 0,
      "steps": 20,
      "cfg": 8,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1
    },
    "class_type": "KSampler",
    "_meta": {
      "title": "KSampler"
    }
  }
}
  1. Widget configuration merging complexity
    • Frontend primitive nodes attempt to merge widget configurations from all targets
    • Implementation relies on hardcoded property lists for compatibility checks
    • Not maintainable as new widget options require updates to these lists
    • Current implementation:
      const IGNORE_KEYS = new Set<string>([
        'default',
        'forceInput',
        'defaultInput',
        'control_after_generate',
        'multiline',
        'tooltip',
        'dynamicPrompts'
      ])

Solution

Implement backend primitive nodes following the pattern from existing custom node implementations (ref: [ComfyUI-Easy-Use](https://github.com/yolain/ComfyUI-Easy-Use/blob/3e84b8cd77719341adc71b08b5789bdb07b1a543/py/nodes/logic.py#L78-L274)).

This approach:

  • Preserves node relationships in API format
  • Simplifies configuration management
  • Improves developer experience

Implementation Considerations

  1. COMBO Widget Handling

    • COMBO widgets should accept STRING type inputs when converted to sockets
    • Potential future implementation: combo primitive node that dynamically adjusts options based on output targets
  2. Validation Strategy

    • Replace complex config merging with proactive validation
    • Perform validation on primitive node outputs when:
      • Connections change
      • Widget values change
    • Visual feedback: flag errors before execution with red links and hover error text
    • This approach reduces widget config merging complexity while maintaining validation

@comfyanonymous comfyanonymous merged commit a4a956d into master Mar 21, 2025
6 checks passed
@huchenlei huchenlei deleted the primitive_nodes branch March 21, 2025 15:09
KohakuBlueleaf added a commit to KohakuBlueleaf/ComfyUI that referenced this pull request Apr 8, 2025
* Allow disabling pe in flux code for some other models.

* Initial Hunyuan3Dv2 implementation.

Supports the multiview, mini, turbo models and VAEs.

* Fix orientation of hunyuan 3d model.

* A few fixes for the hunyuan3d models.

* Update frontend to 1.13 (comfyanonymous#7331)

* Add backend primitive nodes (comfyanonymous#7328)

* Add backend primitive nodes

* Add control after generate to int primitive

* Nodes to convert images to YUV and back.

Can be used to convert an image to black and white.

* Update frontend to 1.14 (comfyanonymous#7343)

* Native LotusD Implementation (comfyanonymous#7125)

* draft pass at a native comfy implementation of Lotus-D depth and normal est

* fix model_sampling kludges

* fix ruff

---------

Co-authored-by: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com>

* Automatically set the right sampling type for lotus.

* support output normal and lineart once (comfyanonymous#7290)

* [nit] Format error strings (comfyanonymous#7345)

* ComfyUI version v0.3.27

* Fallback to pytorch attention if sage attention fails.

* Add model merging node for WAN 2.1

* Add Hunyuan3D to readme.

* Support more float8 types.

* Add CFGZeroStar node.

Works on all models that use a negative prompt but is meant for rectified
flow models.

* Support the WAN 2.1 fun control models.

Use the new WanFunControlToVideo node.

* Add WanFunInpaintToVideo node for the Wan fun inpaint models.

* Update frontend to 1.14.6 (comfyanonymous#7416)

Cherry-pick the fix: Comfy-Org/ComfyUI_frontend#3252

* Don't error if wan concat image has extra channels.

* ltxv: fix preprocessing exception when compression is 0. (comfyanonymous#7431)

* Remove useless code.

* Fix latent composite node not working when source has alpha.

* Fix alpha channel mismatch on destination in ImageCompositeMasked

* Add option to store TE in bf16 (comfyanonymous#7461)

* User missing (comfyanonymous#7439)

* Ensuring a 401 error is returned when user data is not found in multi-user context.

* Returning a 401 error when provided comfy-user does not exists on server side.

* Fix comment.

This function does not support quads.

* MLU memory optimization (comfyanonymous#7470)

Co-authored-by: huzhan <huzhan@cambricon.com>

* Fix alpha image issue in more nodes.

* Fix problem.

* Disable partial offloading of audio VAE.

* Add activations_shape info in UNet models (comfyanonymous#7482)

* Add activations_shape info in UNet models

* activations_shape should be a list

* Support 512 siglip model.

* Show a proper error to the user when a vision model file is invalid.

* Support the wan fun reward loras.

---------

Co-authored-by: comfyanonymous <comfyanonymous@protonmail.com>
Co-authored-by: Chenlei Hu <hcl@comfy.org>
Co-authored-by: thot experiment <94414189+thot-experiment@users.noreply.github.com>
Co-authored-by: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com>
Co-authored-by: Terry Jia <terryjia88@gmail.com>
Co-authored-by: Michael Kupchick <michael@lightricks.com>
Co-authored-by: BVH <82035780+bvhari@users.noreply.github.com>
Co-authored-by: Laurent Erignoux <lerignoux@gmail.com>
Co-authored-by: BiologicalExplosion <49753622+BiologicalExplosion@users.noreply.github.com>
Co-authored-by: huzhan <huzhan@cambricon.com>
Co-authored-by: Raphael Walker <slickytail.mc@gmail.com>
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
0