stable-diffusion-webui-forge icon indicating copy to clipboard operation
stable-diffusion-webui-forge copied to clipboard

Tiling never coming back?

Open SomeNiceDude opened this issue 5 months ago • 6 comments

Is it officially abandoned?

SomeNiceDude avatar Jul 09 '25 21:07 SomeNiceDude

This shit been dead for a while, homie. Comfy is all we have left. People don't even respond to bounties for this thing.

x-ili-x avatar Jul 28 '25 05:07 x-ili-x

@DenOfEquity, I just came to notice your Ersatz Forge mentions 'Tiling'. So, did you get it to work again and is it a question of replacing a python script / some lines of code?

AnabelleKM avatar Aug 18 '25 23:08 AnabelleKM

Quick examples: tiling example

DenOfEquity avatar Aug 19 '25 23:08 DenOfEquity

Quick examples: tiling example

@DenOfEquity That looks absolutely perfect to me!

Is it possible to replace the needed scripts (etc.) to have Tiling working again in Forge WebUi? - I do not want to install an additional Forge fork (Ersatz Forge in this case), I would like to leave my current installation as is, just get the Tiling function integrated again.

If it is a matter of just replacing some lines of python code, I can do that, if you told me where and how.

AnabelleKM avatar Aug 20 '25 09:08 AnabelleKM

Untested in official Forge:

  • rewritten apply_circular_forge function in modules_forge/utils.py (new implementation is a bit hacky, patches a Torch function)
    • replacement code:
from typing import Optional

original_conv2dForward = torch.nn.Conv2d._conv_forward

def apply_circular_forge(model, tiling_enabled="None"):
    if not (model.is_sd1 or model.is_sd2 or model.is_sdxl):
        tiling_enabled = "None"

    model.tiling_enabled = tiling_enabled

    def __replacementConv2DForward(self, input: torch.Tensor, weight: torch.Tensor, bias: Optional[torch.Tensor]):
        modeX = 'circular' if 'X' in model.tiling_enabled else 'constant'
        modeY = 'circular' if 'Y' in model.tiling_enabled else 'constant'
        paddingX = (self._reversed_padding_repeated_twice[0], self._reversed_padding_repeated_twice[1], 0, 0)
        paddingY = (0, 0, self._reversed_padding_repeated_twice[2], self._reversed_padding_repeated_twice[3])
        
        working = torch.nn.functional.pad(input, paddingX, mode=modeX)
        working = torch.nn.functional.pad(working, paddingY, mode=modeY)
        
        return torch.nn.functional.conv2d(working, weight, bias, self.stride, torch.nn.modules.utils._pair(0), self.dilation, self.groups)

    if tiling_enabled == "None":
        torch.nn.Conv2d._conv_forward = original_conv2dForward
    else:
        torch.nn.Conv2d._conv_forward = __replacementConv2DForward

    return
  • adjustment to the tiling setting in modules/shared_options.py for width/height/both tiling (one line)
    • replacement line: "tiling": OptionInfo("None", "Tiling", gr.Radio, {"choices": ["None", "X", "Y", "X and Y"]}, infotext='Tiling').info("produce a tileable picture"),
  • non-essential: update infotext writing in modules/processing.py (one line) to properly write new setting
  • non-essential: update infotext reading inmodules/infotext_utils.py, only for back compat with old method

DenOfEquity avatar Aug 20 '25 10:08 DenOfEquity

@DenOfEquity: You are the hero of the year, I can confirm that it is working. Thank you a lot!

SDXL model, DPM++ 3M SDE, Karras, CFG 7.5, 1024x1024 (values below 1024x1024 tend to give bad results)

Image Image Image

AnabelleKM avatar Aug 20 '25 11:08 AnabelleKM