ComfyUI Node

V-Sampler

A KSampler Advanced that does its math in Rust (and why you mostly don't need it)

By sy00186·Created 5 months ago·Updated 5 months ago· 0
V-Sampler
  • model
  • positive
  • negative
  • latent_image
  • latent
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise1.00

Here's the honest pitch before the marketing: V-Sampler (VatesAdvancedSampler) is a drop-in replacement for the built-in KSampler Advanced whose gimmick is that the boring-but-cheap parts of sampling - the sigma schedule, the noise, a poke at your GPU's memory - are written in Rust and compiled into a native extension. It looks, wires, and behaves like the sampler you already know. Whether it's better is unverified - it shipped in May 2026 with no community track record.

If you're a beginner who googled this because a workflow demanded it, relax: it takes the exact same inputs as KSampler Advanced and produces the same kind of output, so swapping it in changes nothing about how your graph thinks. It comes from the Vates family of packs (same author as the batch-loader), and its real niche is smoothing memory pressure in big multi-batch runs.

How it actually works

The node ships two halves. The Python half is a thin wrapper around Comfy's own comfy.sample.sample_custom - the same sampling loop the built-in SamplerCustom uses, with a callback injected at every step. The Rust half, vates_sampler_core, is a PyO3 extension you compile yourself with Cargo. It handles three things:

  • Sigma schedules. It reimplements karras, exponential, and polyexponential schedules in Rust, mirroring Comfy's k_diffusion math and appending the zero-sigma tail like BasicScheduler does. Any other scheduler silently falls back to comfy.samplers.calculate_sigmas.
  • Noise. It generates the initial latent noise with a PCG64 RNG in Rust, maps it to the GPU via NumPy → torch.from_numpy - zero-copy and deterministic, decoupled from torch's RNG state.
  • The memory vacuum. Each step callback runs a memory_monitor_tick (if you compiled NVML support) plus gc.collect() and torch.cuda.empty_cache(). In a long run with a big batch, repeatedly clearing cached allocations smooths fragmentation and keeps high-batch workflows from OOMing.

What does this buy a normal user? Almost nothing you can see - the sampling math runs on the GPU regardless. The defensible wins are deterministic noise and the per-step cache cleanup in batch-heavy graphs.

The inputs that matter

Everything here matches KSampler Advanced, so a basic txt2img graph already looks familiar:

  • model, positive, negative, latent_image - wire them exactly like you would into any sampler.
  • seed (0 to 2^64, default 0), steps (default 20), cfg (default 8.0) - the usual dials.
  • sampler_name and scheduler - 44 samplers and 9 schedulers, pulled straight from Comfy's own SAMPLER_NAMES / SCHEDULER_NAMES.
  • denoise (default 1.0) - for img2img / latent-restore work, same semantics as anywhere else.

The single output, latent (LATENT), plugs into VAE Decode like any sampler's.

Installing it (the part everyone misses)

ComfyUI Manager can find the pack, but Manager alone only gets you halfway. The real install is two steps:

  1. Get the Rust toolchain - the README points you at rustup.rs.
  2. Open a terminal in ComfyUI/custom_nodes/ComfyUI-Vates-Sampler/dct-core/ and run python install.py. That shells out to cargo build --release, then copies the compiled .so/.pyd next to the node. Optional NVML monitoring: export VATES_SAMPLER_BUILD_NVML=1 first.

Run install.py with the same Python interpreter ComfyUI uses - the script's own docstring stresses this, and it's the classic way to end up with a binary your ComfyUI venv can't import. Then restart ComfyUI; the first cargo build takes a while.

Gotchas and troubleshooting

  • Missing Rust core = silently pointless. If vates_sampler_core isn't importable, the node doesn't crash - it logs a warning and falls back to Comfy's own calculate_sigmas and prepare_noise. Net result: a KSampler Advanced clone with a cache flush. Not broken, but you installed a Rust toolchain for nothing. Check the console for the warning.
  • Nested tensors are rejected. A NestedTensor latent (from some video/tiled workflows) is refused with a clear error pointing you back to the built-in sampler node.
  • denoise must be positive. Setting it to 0 errors out, mirroring Comfy's own BasicScheduler refusing an empty sigma sequence.
  • Batch over 9 logs a soft warning - aligned to the 9-slot Vates batch loader, not a hard limit.
  • It needs a full ComfyUI tree. It imports comfy.sample, latent_preview, and sampler_object directly, so no stripped-down or rehosted ComfyUI.

My take: keep it in your pocket if you're running the Vates batch-loading stack and hitting VRAM walls at high batch counts - that memory vacuum is real. For everyone else, the built-in KSampler Advanced does the same job with fewer moving parts and zero compile time. Niche optimization tool, not a quality upgrade.

CategoryVates/Sampling

Inputs (10)

NameTypeDefaultDescription
modelMODEL
seedINT00–18446744073709550000
stepsINT201–10000
cfgFLOAT8.00–100
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
positiveCONDITIONING
negativeCONDITIONING
latent_imageLATENT
denoiseFLOAT1.000–1

Outputs (1)

NameTypeDescription
latentLATENT