ApplyRAUNet
2048×2048 on SD1.5 without the six-fingered hands
- model
- MODEL
Every SD1.5 model has a native resolution around 512, and the moment you ask it for 1536×1536 it starts handing out extra limbs and walls of tiling - the classic failure of generating above what a model was trained on. The usual fix is hires-fix or ControlNet Tile, but there's a third path: patch the UNet itself so it can plan big images directly. That's RAU-Net from Megvii's HiDiffusion, and this node is its ComfyUI implementation.
ApplyRAUNet is essentially Kohya Deep Shrink (you may know it as PatchModelAddDownscale) with better taste. The concept is identical: during the early part of generation, it downscales the latent so the model blocks out the composition - how many legs the creature has, where the horizon goes - at a resolution it actually understands, then restores full resolution for the detail pass. The differences are in the downscale method (stride/dilation convolution and pool averaging instead of bicubic) and where the scaling happens in the network. The author's verdict after testing: it works noticeably better than Deep Shrink, at least on SD1.5.
The one rule to internalize before touching it: only use this when you have to. At or below native resolution it doesn't help and can actively hurt quality. It exists so you can generate big directly instead of upscaling afterward.
How the blocks work
The node patches paired down/up blocks of the U-Net. Downscale the latent going into an input block, upscale it back in the corresponding output block - remember the U-Net shape, so input 3 pairs with output 8 on SD1.5, not output 3. For SD1.5 the valid pairs are input 3→output 8, 6→5, 9→2; for SDXL it's 3→5 and 6→2. The defaults (3 in, 8 out) are the closest thing to the official HiDiffusion settings, and they're a fine starting point for ~2048×2048.
There's a second, optional layer: the "CA" (cross-attention) blocks, which apply the same downscale to the blocks around attention. The author is honest that this isn't a real cross-attention patch - it behaves almost exactly like Deep Shrink - but it runs from ca_start_time to ca_end_time on its own schedule, so you can have the main effect do the heavy lifting and the CA effect handle a shorter early window.
Inputs that matter
The MODEL in / patched MODEL out is the whole interface. For a first run, set:
input_blocks/output_blocks- paired, as above. Defaults3/8are SD1.5.start_time/end_time- default 0.0 → 0.45, meaning the effect is active for the first 45% of sampling (percent mode is based on sampling progress, not step count - that's what the README warns about).upscale_mode- how latents get restored.bicubicis the author's pick;bislerpis the runner-up.ca_start_time/ca_end_time,ca_input_blocks/ca_output_blocks,ca_downscale_factor(2.0 = downscale to half size) - the cross-attention layer.
Everything else - fadeouts, per-block multipliers, two-stage upscaling - lives in the yaml_parameters widget and is genuinely optional. Don't start there.
Install
ComfyUI Manager → search comfyui_jankhidiffusion → Install → restart, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/blepping/comfyui_jankhidiffusion
No model downloads, no requirements.txt. The pack is dependency-free beyond what ComfyUI already ships.
Troubleshooting
- Pairing errors: if you set an input block you must set its matching output block, or you'll get size mismatches mid-sampling. Check the pairing table above.
- ControlNet: RAUNet fights ControlNet while the scaling effect is active - the node tries a workaround that rescales the ControlNet conditioning (you'll see
Scaling controlnet conditioningin the log), but it's best-effort. The README's advice: don't run RAUNet with ControlNet unless you truly need both, shorten the effect window, and use an ancestral sampler. If the workaround misbehaves, setJANKHIDIFFUSION_DISABLE_CONTROLNET_WORKAROUNDin your environment. - SDXL: it works but it's temperamental - SDXL tolerates Deep Shrink-style effects far worse than SD1.5. Use an ancestral or SDE sampler, and consider running either the main effect or the CA effect, not both.
- Stacking: it won't coexist with Deep Shrink (same blocks), and pairing with restart sampling needs manual segment adjustment so restarts land after the scaling ends.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | Model to be patched with the RAUNet effect. | |
| input_blocks | STRING | 3 | Comma-separated list of input Downsample blocks. Default is for SD 1.5. The corresponding valid block from output_blocks must be set along with input. Valid blocks for SD1.5: 3, 6, 9 Valid blocks for SDXL: 3, 6. Original Hidiffusion implementation uses 6 for SDXL. |
| output_blocks | STRING | 8 | Comma-separated list of output Upsample blocks. Default is for SD 1.5. The corresponding valid block from input_blocks must be set along with output. Valid blocks for SD1.5: 8, 5, 2 Valid blocks for SDXL: 5, 2. Original Hidiffusion implementation uses 2 for SDXL. |
| time_mode | COMBO | percent | Time mode controls how to interpret the values in start_time and end_time. |
| start_time | FLOAT | 0.000–999 | Time normal RAUNet effects start applying - value is inclusive. |
| end_time | FLOAT | 0.450–999 | Time normal RAUNet effects end - value is inclusive. |
| upscale_mode | COMBO | Method used when upscaling latents in output Upscale blocks. | |
| ca_start_time | FLOAT | 0.000–999 | Time normal cross-attention effects start applying - value is inclusive.. |
| ca_end_time | FLOAT | 0.300–999 | Time normal cross-attention effects end - value is inclusive. |
| ca_input_blocks | STRING | 4 | Comma separated list of input cross-attention blocks. Default is for SD1.x, for SDXL you can try using 5 (or just disable it). |
| ca_output_blocks | STRING | 8 | Comma-separated list of output cross-attention blocks. Default is for SD1.x, for SDXL you can try using 4 (or just disable it). |
| ca_upscale_mode | COMBO | Mode used when upscaling latents in output cross-attention blocks. | |
| ca_downscale_mode | COMBO | adaptive_avg_pool2d | Mode used when downscaling latents in output cross-attention blocks (use avg_pool2d for normal Hidiffusion behavior). adaptive_avg_pool2d should be the same and also supports fractional scales. |
| ca_downscale_factor | FLOAT | 2.0 | Factor to downscale with in cross-attention, 2.0 means downscale to half size. Must be an integer when using ca_downscale_mode avg_pool2d. |
| two_stage_upscale_mode | COMBO | disabled | When upscaling in output Upscale blocks (non-NA), do half the upscale with this mode and half with the normal upscale mode. May produce a different effect, isn't necessarily better. |
| yaml_parametersopt | STRING | Allows specifying custom parameters via YAML. You can also override any of the normal parameters by key. See main README for possible options. Note: When specifying paramaters this way, there is very little error checking. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | Model patched with the RAUNet effect. |