Nodes/ComfyUI_StoryDiffusion/StoryDiffusion_KSampler
ComfyUI Node

StoryDiffusion_KSampler

The sampler that remembers who your character is

By smthemex·Created 2 years ago·Updated 11 months ago· 514
StoryDiffusion_KSampler
  • model
  • positive
  • negative
  • condition
  • latent_image
  • LATENT
seed0
steps20
cfg8.0
sampler_name
scheduler
sa32_degree0.5
sa64_degree0.5
denoise1.00

StoryDiffusion_KSampler is the pack's replacement for ComfyUI's stock KSampler, and it's the piece that makes "the same character across five scenes" physically happen. A normal KSampler denoises each latent independently - every frame is a coin flip on the face. This one carries an identity bank across the whole batch, so once it generates a character's first scene, the later scenes borrow that identity instead of re-rolling it.

The mechanism is the StoryDiffusion paper's trick, repackaged: while the first image of a character is being denoised, the sampler writes that character's self-attention maps into a keyed memory bank. Every subsequent scene for that character reads from the bank at each step, which steers the attention toward the stored identity. The two sliders no stock sampler has, sa32_degree and sa64_degree (both 0–1, default 0.5), control how strongly that attention is applied - the 32×32 and 64×64 attention resolutions of the bank. Start at 0.5; if faces drift between scenes, nudge them up; if the output gets stiff or glued to the reference pose, ease them back down.

Inputs

Mostly it looks like the KSampler you already know:

  • model - the patched MODEL from StoryDiffusion_Apply. Don't feed it a raw checkpoint loader's model unless you're in classic mode.
  • condition (DIFFINFO) - the crucial one, from StoryDiffusion_CLIPTextEncode's condition output. It carries the role indices, per-role embeddings, dual-scene positions and the infer mode. Miss this and the sampler doesn't know who anyone is.
  • positive / negative - from the same CLIPTextEncode. Remember: these are the pack's dict structures, not stock conditioning. They only make sense together with condition, which is exactly why this sampler exists.
  • seed, steps, cfg, sampler_name, scheduler, denoise - standard fare. sampler_name has the full 44-choice list and scheduler the usual nine. CFG default of 8 is SDXL-flavored; some modes override it internally (DreamO forces 4.5 on v1.1).
  • latent_image - an empty latent (size from the CLIPTextEncode's width/height outputs) or an img2img latent.

Output

A single LATENT with one frame per scene line in scene_text, stacked in order. It decodes like any latent - VAEDecodeSave Image. Feed that batch to Comic_Type and you've got a storyboard-to-comic pipeline.

The two behaviors worth knowing

In classic mode (Apply's pass-through), the sampler stops being special: positive arrives as a plain list of per-scene conditionings, and it just samples each one and batches the results - useful when you want the pack's multi-character CLIP handling on a normal workflow you already have. In the story modes, it also handles the dual-scene inserts (both characters in one frame), reloading the MS-Diffusion or StoryMaker pipeline mid-run to merge the two identities. That's the slow part, and on modest cards you'll see it stutter at that step. It's normal.

Install and pitfalls

Same one-time pack install as the rest of ComfyUI_StoryDiffusion:

cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_StoryDiffusion.git
cd ComfyUI_StoryDiffusion
pip install -r requirements.txt

The single biggest confusion is wiring: people drop a stock KSampler in and get a "expected DIFFINFO" or shape error because the conditioning isn't standard. Use the pack's own sampler, in the pack's own graph - the included storydiffusion_workflow.json shows the intended layout, and it's worth opening even though the downloaded example graphs are famously spaghetti. Also, denoise below 1.0 works as img2img here, but for face-ID img2img modes the reference faces come from the CLIPTextEncode's image input, not from the latent, so lower the denoise for structure, not for identity.

CategoryStorydiffusion

Inputs (13)

NameTypeDefaultDescription
modelMODELThe model used for denoising the input latent.
seedINT00–2147483647The random seed used for creating the noise.
stepsINT201–10000The number of steps used in the denoising process.
cfgFLOAT8.00–100The Classifier-Free Guidance scale balances creativity and adherence to the prompt. Higher values result in images more closely matching the prompt however too high values will negatively impact quality.
sampler_nameCOMBOThe algorithm used when sampling, this can affect the quality, speed, and style of the generated output.
schedulerCOMBOThe scheduler controls how noise is gradually removed to form the image.
positiveCONDITIONINGThe conditioning describing the attributes you want to include in the image.
negativeCONDITIONINGThe conditioning describing the attributes you want to exclude from the image.
conditionDIFFINFOSwitch infer mode witch your chocie.
latent_imageLATENTThe latent image to denoise.
sa32_degreeFLOAT0.50–1
sa64_degreeFLOAT0.50–1
denoiseFLOAT1.000–1The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling.

Outputs (1)

NameTypeDescription
LATENTLATENTThe denoised latent.