dot-sd_generate_plan: Build an executable step plan for sd_generate (async...

.sd_generate_planR Documentation

Build an executable step plan for sd_generate (async orchestration)

Description

Mirrors the routing logic of sd_generate (cfg auto-1.0 for guidance-distilled Flux/Flux.2, strategy selection, VAE tiling resolution) but instead of running the pipeline, returns a list of steps. Each step is one of:

  • type = "gen" — a single sd_generate_async() call. Carries a ready-to-use params list, width/height, a label, and uses_init (whether it consumes the previous step's image as init_image).

  • type = "upscale" — a synchronous R-side resize/ESRGAN step run between two gen steps. Carries width/height, upscaler, upscale_factor.

The final step (the image returned to the caller) has final = TRUE.

Usage

.sd_generate_plan(
  ctx,
  prompt,
  negative_prompt = "",
  width = 512L,
  height = 512L,
  init_image = NULL,
  strength = 0.75,
  sample_method = SAMPLE_METHOD$EULER,
  sample_steps = 20L,
  cfg_scale = 7,
  seed = 42L,
  batch_count = 1L,
  scheduler = SCHEDULER$DISCRETE,
  clip_skip = -1L,
  eta = 0,
  flow_shift = NULL,
  hr_strength = 0.4,
  hr_steps = NULL,
  upscaler = NULL,
  upscale_factor = 4L,
  vae_mode = "auto",
  vae_auto_threshold = 1048576L,
  vae_tile_size = 64L,
  vae_tile_overlap = 0.25,
  cache_mode = c("off", "easy", "ucache"),
  cache_config = NULL
)

Arguments

ctx

SD context created by sd_ctx

prompt

Text prompt describing desired image

negative_prompt

Negative prompt (default "")

width

Image width in pixels (default 512)

height

Image height in pixels (default 512)

init_image

Optional init image for img2img. If provided, runs img2img instead of txt2img. Requires vae_decode_only = FALSE.

strength

Denoising strength for img2img (default 0.75). Ignored for txt2img.

sample_method

Sampling method (see SAMPLE_METHOD)

sample_steps

Number of sampling steps (default 20)

cfg_scale

Classifier-free guidance scale (default 7.0)

seed

Random seed (-1 for random)

batch_count

Number of images to generate (default 1)

scheduler

Scheduler type (see SCHEDULER)

clip_skip

Number of CLIP layers to skip (-1 = auto)

eta

Eta parameter for DDIM-like samplers

flow_shift

Flow shift for flow-matching models (Flux, SD3). NULL (default) lets the model pick an architecture-specific value; set a numeric value to override. Ignored by non-flow models.

hr_strength

Denoising strength for highres fix refinement pass (default 0.4). Only used when auto-routing selects highres fix.

vae_mode

VAE processing mode: "normal", "tiled", or "auto" (VRAM-aware: queries free GPU memory and enables tiling only when estimated peak VAE usage exceeds available VRAM minus a 50 MB reserve). Default "auto".

vae_tile_size

Tile size for VAE tiling (default 64)

vae_tile_overlap

Overlap for VAE tiling (default 0.25)

cache_mode

Step caching mode: "off" (default), "easy" (EasyCache), or "ucache" (UCache).

cache_config

Optional fine-tuned cache config from sd_cache_params.

Details

This lets the Shiny GUI drive the multi-step highres-fix pipeline through the single-shot async engine: run a gen step, poll it, feed its result into the next step, all without blocking the R session.

Value

List of step descriptors (see above).


sd2R documentation built on June 19, 2026, 9:08 a.m.