ComfyUI Node

UC_ksampler

Your entire sampler row — steps, cfg, sampler, size, decode — collapsed into one node

By cardenluo·Created 2 years ago·Updated about 15 hours ago· 334
UC_ksampler
  • context
  • model
  • positive
  • negative
  • latent
  • latent_image
  • latent_mask
  • context
  • latent
  • image
  • audio
seed0
denoise1.00
VAE_Decodetrue
sample_parametersfalse
steps8
cfg1.00
samplereuler
schedulersimple
latent_sizefalse
ratio_selectedNone
batch_size1
width512
height512

If you've looked at a modern ComfyUI graph, you know the drill: Empty Latent Image, KSampler, VAEDecode, and about nine widgets you re-type every time. UC_ksampler is that whole row as one node - it pulls model, conditioning, latent and VAE out of a RUN_CONTEXT, samples, decodes, and hands you back a context plus the latent, the image and any audio.

The design bet is that you set steps/cfg/sampler once, upstream, and let samplers inherit. Get used to the two inheritance toggles and this node disappears into the background; fight them and you'll spend an evening wondering why changing steps did nothing.

The inputs that matter

  • context - required. Everything else has a fallback: if model, positive or negative aren't wired, they come off the context.
  • sample_parameters - the master inheritance switch. Off means "inherit context" and the four widgets below are ignored; on means "custom" and your local steps, cfg, sampler, scheduler win.
  • latent_size - the same idea for geometry. Off means prefer the upstream latent's dimensions; on means build a fresh latent from width/height (or ratio_selected, which is a dropdown of ~30 named sizes like [768x1024]3:4, [512x384]AD and [720x1280]竖屏标清).
  • seed, denoise - the obvious two. denoise at 1.0 is txt2img; drop it and you're doing an img2img pass.
  • VAE_Decode - leave it on and you get a decoded IMAGE plus audio through the context's audio VAE. Turn it off and the node skips decoding entirely, which is a real speedup when you're chaining samplers and only want the latent.

Then the optional sockets, which are the interesting part. latent_image takes an IMAGE and VAE-encodes it for you. latent_mask applies a MASK as a noise_mask on the latent, which is ComfyUI's inpainting path. latent lets you inject a latent directly. Order of precedence, straight from the code: an image wins over a wired latent, which wins over the context's latent, which falls back to a black latent at your chosen size - repeated to batch_size - if there's nothing at all.

Default values tell you what era this was built for: steps 8, cfg 1.0, euler, simple. That's a distilled flow-matching model's settings, not SDXL's. Worth knowing when you import an SD 1.5 workflow and everything comes out flat: at CFG 1 ComfyUI doesn't even run the negative pass, and your negative prompt is decoration.

Outputs

context (updated with the new latent and the sampling settings actually used), latent, image, audio. The context output is what you daisy-chain - sampler two takes sampler one's context and inherits its steps. audio only has anything in it when the context carries an audio_vae, so on audio-capable video models you get the sound track on the same wire as the picture.

If a conditioning socket is left empty the node encodes defaults through CLIP rather than erroring - an empty string for positive, the word blur for negative. Convenient, and also the reason a node with no text encoder wired "works" and generates mush. The pack leans on CLIP for these fallbacks, so a context without a clip will fail there and only there.

Install

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

Restart ComfyUI. The node is under Apt_Preset/unit_context; Manager users can search Apt_Preset. Nothing model-side to download beyond whatever checkpoint you're sampling, and if you use it with UC_load_model, that loader will already have encoded a default positive and negative into the context for you.

Common issues

The one you'll hit first is a context that doesn't have what the node needs. A missing VAE only errors if it's actually needed - decoding, or encoding a latent_image. A missing model or CLIP errors wherever it first gets used, which is often not at this node. Feed it a UC_create_context output if in doubt.

Second: inheritance is silent. sample_parameters off means the steps box on the node is dead, greyed-out-looking or not. Everyone loses ten minutes to this. Same for latent_size and your width/height.

Third: tiling and VRAM belong elsewhere. This node has no tile or memory dials; if you're OOMing during sampling, that's a job for the pack's controller stacks or the tiled variants, not for fiddling with batch_size and hoping.

CategoryApt_Preset/unit_context

Inputs (20)

NameTypeDefaultDescription
contextRUN_CONTEXT
seedINT00–18446744073709550000
denoiseFLOAT1.000–1
VAE_DecodeBOOLEANtrue关闭后不生成图片和音频,速度提升
sample_parametersBOOLEANfalse继承context时使用上游参数,自定义时使用下方参数
stepsINT80–10000
cfgFLOAT1.000–100
samplerCOMBOeuler45 options: None, euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, +39
schedulerCOMBOsimple10 options: None, simple, sgm_uniform, karras, exponential, ddim_uniform, +4
latent_sizeBOOLEANfalse继承context时优先使用上游latent尺寸
ratio_selectedCOMBONone32 options: None, customer_WxH, [384x512]AD, [512x384]AD, [512x512]1:1, [512x768]2:3, +26
batch_sizeINT11–300
widthINT5128–16384
heightINT5128–16384
modeloptMODEL
positiveoptCONDITIONING
negativeoptCONDITIONING
latentoptLATENT
latent_imageoptIMAGE
latent_maskoptMASK

Outputs (4)

NameTypeDescription
contextRUN_CONTEXT
latentLATENT
imageIMAGE
audioAUDIO