Nodes/XB_ToolBox/XB-BOX - 采样器(原版优化)
ComfyUI Node

XB-BOX - 采样器(原版优化)

The stock KSampler, plus a before-sampling VRAM cleanup knob

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - 采样器(原版优化)
  • model
  • positive
  • negative
  • latent_image
  • LATENT
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise1.00
cleanup不做任何清理

This is not a new sampler. Read the source and you'll see it's a straight wrapper around ComfyUI's own KSampler - same inputs, same outputs, same sampling code, called "一字不差" (word for word, per the author). What XB_KSampler adds is exactly one thing: a cleanup dropdown that runs before sampling. On a VRAM-starved card, that's genuinely worth having.

If you're running a big video model or stacking a VAE decode right before sampling, PyTorch's cached allocator can leave you with a fragmented, half-empty VRAM pool - plenty of "used" memory that's actually just cached blobs waiting to be freed. The stock KSampler doesn't care; it just tries to allocate and can OOM for no good reason. This node lets you force a clean-up pass first.

The cleanup dropdown

Four options, escalating from nothing to nuclear:

  • 不做任何清理 (no cleanup) - the default, and it's just the stock sampler.
  • 单次缓存清理 (single cache cleanup) - soft_empty_cache() + empty_cache(), clearing the PyTorch cache without unloading anything. Cheap, fast, the one you'll reach for most.
  • 卸载显存模型 (unload VRAM models) - the above plus unload_all_models(), which pushes models back to system RAM before sampling. Costs a reload, buys real headroom.
  • 卸载全量模型 (full cleanup) - everything above plus cleanup_models(), gc.collect(), and IPC collect. Slowest, freest VRAM.

Everything else

Every other input is identical to the vanilla KSampler: model, seed, steps, cfg, sampler_name (the full 44-option list), scheduler, positive, negative, latent_image, denoise. Same single LATENT output, same behavior. The sampler theory you already know applies unchanged - on flow-matching models (Flux, Wan, LTX) stick to euler-family samplers with conservative schedulers; the Karras habit from SDXL doesn't carry over. The wrapper adds nothing to that equation.

The whole point of this node is the workflow ergonomics: instead of threading a VRAM Cleaner node into the graph before your sampler, you flip a dropdown on the sampler itself. It also guards against the classic low-VRAM failure where a big VAE decode right before sampling leaves the cache full and the sampler OOMs on a perfectly reasonable step count.

Installing it

Standard XB_ToolBox install:

cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git

or via ComfyUI Manager (search XB_ToolBox), then restart. No extra dependencies for this node - it only touches ComfyUI core.

When to actually use it

If you never hit VRAM errors, leave the dropdown on no-cleanup and you've effectively got the stock sampler with a cosmetic rename. If you do hit intermittent OOMs at sampling time, especially on 8GB cards with video models, set it to single cache cleanup and see if the problem disappears - if it doesn't, escalate to unload-models. The catch is that aggressive cleanup costs time: unloading and reloading models on every single generation adds measurable latency, so the full option is really for "one-shot bake" workflows, not daily interactive tweaking. And note it runs its cleanup before sampling only - it doesn't help the VAE decode on the way out.

CategoryXB_ToolBox/原版优化

Inputs (11)

NameTypeDefaultDescription
modelMODELThe model used for denoising the input latent.
seedINT00–18446744073709550000The 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.
latent_imageLATENTThe latent image to denoise.
denoiseFLOAT1.000–1The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling.
cleanupCOMBO不做任何清理4 options: 不做任何清理, 单次缓存清理, 卸载显存模型, 卸载全量模型

Outputs (1)

NameTypeDescription
LATENTLATENT