Alternative Skip Layer Guidance (SLG) node implementation#8759
Merged
comfyanonymous merged 1 commit intoComfy-Org:masterfrom Jul 3, 2025
Merged
Alternative Skip Layer Guidance (SLG) node implementation#8759comfyanonymous merged 1 commit intoComfy-Org:masterfrom
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
Conversation
adlerfaulkner
pushed a commit
to LucaLabsInc/ComfyUI
that referenced
this pull request
Oct 16, 2025
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 PR adds a version of skip layer guidance (SLG) that only runs two passes, instead of running an extra one (current master). This cuts down on some of the compute overhead[1].
It also matches the logic found in deepbeepmeep/Wan2GP#61 and the results are closer to the outputs of ComfyUI-WanVideoWrapper by @kijai
I was playing around with this for a bit, and was getting better outputs when using it with Wan 2.1 than I was with the current
SkipLayerGuidanceDiTnode, though it works with other DiT models as well since the code is generic.Here are some samples for comparison: (imgsli link)
Workflow screenshots
No SLG

Old SLG

New SLG

Kijai SLG

Speed figures for the L40 GPU I was testing on via runpod:
[1] I had to add a way to replace
calc_cond_batchto do this, because that's the only place wherecond/uncondare clearly separated andmodel_optionsis exposed.Other ideas I considered:
pre_cfg_function- can replaceuncondhere with a separate pass, but that still has the compute overhead - Could add aforce_cfg1_optimizationarg to model options that forces skipping uncond, but that could cause issues for other things usingpre_cfg_functiondepending on the order.model_function_wrapperapplied here - only exposes transformer options, would have to manually add skip block to only the uncond. Separating cond/uncond here is also messy if they're batched.blocks_replacegets applied - replacement function doesn't have access to transformer_options / same issue withcond/uncondbeing batchedI think it might be better to use a wrapper/hook but I haven't used that system enough to know whether it's possible or not. Tagging @Kosinkadink based on the PR for the original hooks update in case there's a better way, though I think this current version is relatively clean.