fix(stg): drop unsupported momentum_buffer kwarg from APG call (#492) - #555
Open
Tai An (Anai-Guo) wants to merge 1 commit into
Open
fix(stg): drop unsupported momentum_buffer kwarg from APG call (#492)#555Tai An (Anai-Guo) wants to merge 1 commit into
Tai An (Anai-Guo) wants to merge 1 commit into
Conversation
STGGuiderAdvanced.predict_noise passes momentum_buffer=None to apg(),
but apg() is defined as
def apg(noise_pred_pos, noise_pred_neg, cfg_scale, eta=1.0, norm_threshold=0.0)
so every sampling step with apply_apg=True dies with
TypeError: apg() got an unexpected keyword argument 'momentum_buffer'
The keyword was inert regardless: apg()'s body never references momentum.
The sibling call in STGGuiderAPG.predict_noise already omits it, and
dropping it here makes the two call sites agree.
Fixes Lightricks#492
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.
Fixes #492
Problem
STGGuiderAdvanced.predict_noisecallsapg()with amomentum_buffer=Nonekeyword that
apg()does not accept:apply_apgis a node input onLTXVApplySTGAdvanced(stg.py:626), so turningit on makes sampling fail immediately with
which is exactly what #492 reports.
Why removing it is the right fix
apg()'s body never references momentum at all, so the argument was inerteven before it started raising — passing
Nonecould not have had an effect.STGGuiderAPG.predict_noiseatstg.py:857, alreadycalls
apg(noise_pred_pos, noise_pred_neg, self.cfg_scale, self.eta, self.norm_threshold)with no momentum argument. Of the twoapg()call sitesin the file, only this one disagrees with the signature.
Restoring real momentum support would be a behaviour change (
MomentumBufferisconstructed in
STGGuiderAPG.__init__and reset on timestep increase, but isnever threaded into
apg()), so I left that alone — happy to open a separateissue for it if you'd like it tracked.
Verification
No ComfyUI runtime needed:
project()andapg()were lifted out ofstg.pywith
astand executed as-is against real tensors.So the unpatched path reproduces the reported error verbatim, and the patched
call is bit-identical to the already-working
STGGuiderAPGpath.Notes
apply_apg=False.black 24.4.2(the pinned.pre-commit-config.yamlversion) leaves the callformatting unchanged — the magic trailing comma keeps it exploded.
2026-08-26 without review, alongside two of their unrelated PRs; apg() got unexpected keyword argument 'momentum_buffer' when apply_apg=True #492 is still
open and the bug is still on
master. Reopening that fix here with runtimeevidence. Credit to omribz156 for spotting it first.
🤖 Generated with Claude Code