UC_ksampler_custom
The entire sampler, on one wire
- context
- model
- positive
- negative
- noise
- guider
- sampler
- sigmas
- latent
- image
- context
- latent
- noise_latent
- image
- audio
What it's for
A standard ComfyUI graph drags a dozen wires everywhere. Model, conditioning, VAE, latent, steps, cfg, sampler, scheduler, seed - every node downstream needs some subset, so anything past one sampler turns into noodles. Apt_Preset's thesis is to fix that: its README describes designing the pack around "Loader → Controller → Sampler", and its answer to the wire problem is a RUN_CONTEXT - one bundle carrying all those values down a single connection.
UC_ksampler_custom is the sampler end of that idea. It takes a context, pulls everything it needs out of it, samples, decodes, and hands you a new context with the updated latent inside. A working text-to-image graph becomes three nodes: loader, sampler, save.
How it works
Mechanically it's the modern ComfyUI sampling chain, assembled from the pieces you'd normally wire by hand: a noise object seeded from seed, a sampler object from sampler_name, a CFG guider built from the model plus positive and negative conditioning at cfg, sigmas from scheduler at steps/denoise, the sampling itself (same machinery as core's SamplerCustomAdvanced), then a VAE decode.
The context supplies the raw materials: model, positive, negative, vae, clip, audio_vae, and a latent. You get a context from the pack's loader (the advanced loader outputs context, model, and a preset slot) or from UC_create_context, the manual door - model, clip and VAE in, context out, optionally with steps/cfg/sampler/scheduler baked in.
Every one of those can also be overridden with a real wire. That's the _custom in the name: model, positive, negative, noise, guider, sampler, sigmas, latent, and image are all optional inputs, and each replaces what the context would have provided.
The inputs and outputs that matter
Two booleans do most of the work, because they decide whether the widgets below them matter at all.
sample_parameters- off (the default) means inherit: steps, cfg, sampler and scheduler come from upstream in the context. On means custom, and the four widgets below get used. This is the node's best trick: with inheritance you set your sampler parameters once, in the loader's preset, and changing that one spot changes every sampler in the graph.latent_size- same shape. Off, the latent comes from the context. On, the node builds one fromratio_selected(31 presets, including the Wan default 848×480 and a couple of AnimateDiff sizes), or fromwidth/heightwhen set to the custom entry, withbatch_sizecopies. Dimensions get snapped to multiples of 8.denoise- 1.0 for fresh generation, lower for img2img/refine work.VAE_Decode- on by default. Turn it off and the node skips decoding entirely (faster, no image and no audio output) but still writes the latent into the context, which is what you want mid-chain when a refine sampler or an upscaler is next.tile_size- tiled latent sampling for when the image is too big for your card. Presets read as tile count | overlap in pixels (the widget labels are Chinese: quality-first, slow/good seams, medium, fast/bad seams, and two extreme VRAM-saving entries at 6×64 and 8×64). More tiles and less overlap saves more VRAM and shows more seams. Two hard limits from the code: it can't be combined with a customguider, and it needs a 4-D image latent, so it's not for video or audio latents.seed,steps,cfg,sampler_name,scheduler- the usual, and note thatNonein sampler or scheduler falls back toeuler/simple.
Outputs: context (chain it into the next node), latent (the denoised result, also what got decoded), noise_latent (the sampler's raw output - identical to latent on non-ancestral samplers), image, and audio.
Install
Part of ComfyUI-Apt_Preset:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
cd ComfyUI-Apt_Preset
python -m pip install -r requirements.txt # your ComfyUI's python
Restart ComfyUI, or install via ComfyUI Manager by pack title. No models of its own, and none of the pack's optional companions (Advanced-ControlNet, GGUF, nunchaku) matter here.
Common issues
The error messages are unusually good. Most context failures are the node telling you what's missing: "needs VAE in context", "needs VAE in context to encode image", "Cannot encode the default positive prompt without CLIP in context". If you see one, the fix is upstream, in whatever built your context.
You didn't wire conditioning or a latent, and it didn't complain. If positive or negative is empty, the node quietly encodes "" and the string blur as the negative, using the CLIP in the context. And with latent_size inherited and no latent in the context at all, you get a black 512×512 canvas VAE-encoded through the context's VAE. Both are conveniences that make a graph with a missing wire look like a graph happily ignoring your settings.
Stale context. The real cost of the pattern, and it's the same for every pack that ships one. The bundle made your graph readable and, in exchange, made its contents invisible. Load a LoRA after your loader and sample anyway, and you're sampling the base model - the wire is connected, so nothing looks wrong. When you're iterating on one stage, wire that value in explicitly (model, positive…) and let the rest ride the context.
Portability. RUN_CONTEXT is Apt_Preset's own type - nothing else speaks it, so a workflow built on this bus is married to the pack. Part of why core later shipped Subgraph.
The pack itself won't load. If no Apt_Preset node shows up, it's usually the flat install: __init__.py imports every module unguarded, so one missing dependency takes all 200-odd nodes down with an "IMPORT FAILED" for the folder. Run the requirements install and restart. That's the most reported failure mode for this pack in the wild.
Inputs (24)
| Name | Type | Default | Description |
|---|---|---|---|
| context | RUN_CONTEXT | — | |
| seed | INT | 00–18446744073709550000 | — |
| denoise | FLOAT | 1.000–1 | — |
| VAE_Decode | BOOLEAN | true | 关闭后不生成图像和音频,速度提升 |
| tile_size | COMBO | None | 图像 latent 分块采样;自定义 guider 不支持分块。 |
| sample_parameters | BOOLEAN | false | 继承context时使用上游采样参数,自定义时使用下方参数 |
| steps | INT | 80–10000 | — |
| cfg | FLOAT | 1.000–100 | — |
| sampler_name | COMBO | euler | 45 options: None, euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, +39 |
| scheduler | COMBO | simple | 10 options: None, simple, sgm_uniform, karras, exponential, ddim_uniform, +4 |
| latent_size | BOOLEAN | false | 继承context时优先使用上游 latent 尺寸 |
| ratio_selected | COMBO | 自定义宽和高 | 31 options: 自定义宽和高, [384x512]AD, [512x384]AD, [512x512]1:1, [512x768]2:3, [576x1024]9:16, +25 |
| batch_size | INT | 11–300 | — |
| width | INT | 5128–16384 | — |
| height | INT | 5128–16384 | — |
| modelopt | MODEL | — | |
| positiveopt | CONDITIONING | — | |
| negativeopt | CONDITIONING | — | |
| noiseopt | NOISE | — | |
| guideropt | GUIDER | — | |
| sampleropt | SAMPLER | — | |
| sigmasopt | SIGMAS | — | |
| latentopt | LATENT | — | |
| imageopt | IMAGE | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| context | RUN_CONTEXT | — |
| latent | LATENT | — |
| noise_latent | LATENT | — |
| image | IMAGE | — |
| audio | AUDIO | — |