r/StableDiffusion • u/ninjazombiemaster • 4d ago
No Workflow Self-Refining Sampler+
https://github.com/Alex240z/ComfyUI-SelfRefiningSamplerPlus



Based on: https://arxiv.org/html/2601.18577v1 and builds on pre-existing work by Kijai (The SamplerSelfRefineVideo Node).
I have found that Minimax H3-Image loves the Self-Refining Sampler. Seeing this, I spun up an improved version (SRS+) that is compatible with sampling methods besides Euler, has more easily adjustable sub-step and perturb amounts per step.
It seems to significantly improve the model's ability to resolve fine details, especially when combined with the "Empty-Image Trick" I shared previously (if using T2V). One place this is evident are patterns like fishnet, lace, sequins and other challenging fabrics/textiles. It seems to improve line-art for anime/illustration styles, and can often fix self-correct body-horror deformities.
As a starting point, try running it from steps 2-4 with 3 sub-steps and an uncertainty threshold of 0.03. But I'm much more curious what settings you try and results you get with them. Since it does sub-step, it increases gen time but I think it is well worth it.
I've tested it less with video, but it has shown promise there, too.
Just socket this chungus into a SamplerCustomAdvanced like any other sampler. Let me know if you have any issues, or what kind of results you get.
View all comments
Show parent comment
1
u/alwaysbeblepping 3d ago
Actually, looking at the code there is a significant difference in the normal branch. Restart noises the latent back up to a specific sigma but preserves all the existing noise as well as the partially denoised image part. Your normal branch seems to be doing a LCM/pingping step (just to the same sigma) so all the noise gets replaced.
I've heard people talk about LCM being good for low step models. I actually don't doubt it but I also understand why that would be the case. The whole idea of low-step is a straight path to the clean image, it seems like replacing 100% of the noise is the most disruptive thing you could do.
There really is a reason to prefer using
torch.lerpto manually reinventing it, though. :) Especially that version which requires two multiplications on your large video tensors and an addition. It also can be written as(eps_mix - denoised) * sigma + denoisedwith only one multiplication and less intermediate values (or(eps_mix - denoised).mul_(sigma).add_(denoised)for the in-place version).torch.lerp(denoised, eps_mix, sigma)can use an optimized kernel, possibly use in-place operations internally (lowering how much peak VRAM you need and maybe decreasing memory fragmentation).Optimizing latent twiddling doesn't matter a lot of the time but video latents actually can be big enough to notice a difference. Doing the math differently can (sometimes) change seeds slightly so there's an argument for not doing something like going into ComfyUI and replacing all the existing manual LERP implementations but if you're making a new node...
That's my opinion, anyway, which you didn't ask for but got all the same!