XB-BOX - 高级采样器(原版优化)
KSamplerAdvanced with the pre-run memory sweep
- model
- positive
- negative
- latent
- LATENT
The advanced sibling of XB_ROCmKSampler: ComfyUI's stock KSamplerAdvanced, wrapped with the same cleanup dropdown bolted on the front. If you need step-range control - start at step 40, stop at 80, keep leftover noise for a chained pass - this is the one, and it brings the same pre-run memory cleanup the basic version offers.
Everything the basic node does, this does with the extra dials. And because it's a wrapper around the official KSamplerAdvanced (same "原版优化" family, same legacy-alias lineage as XB_ROCmKSampler), there's no custom sampling logic to distrust - the official node does the sampling, the wrapper just cleans up before handing over.
The inputs that matter
All the KSamplerAdvanced staples, plus cleanup:
- model, positive, negative, latent - standard.
- add_noise (
enable/disable) and noise_seed - decide whether this pass adds fresh noise; disable it when the pass continues from a prior latent's noise state. - start_at_step / end_at_step - the range of steps this node runs. The advanced sampler's whole point: run steps 0–20 with one model/prompt, then a second node from 20–40 with another.
- return_with_leftover_noise (
disable/enable) - keep the last step's noise so a subsequent pass can chain. Enable when this is the first half of a two-stage denoise. - steps, cfg, sampler (44), scheduler (9) - same as stock.
- cleanup - the four-level memory sweep:
不做任何清理→单次缓存清理→卸载显存模型→卸载全量模型. For a two-node advanced setup, running the cleanup on both halves is usually overkill; set the heavy level on the node where the graph actually OOMs.
Output is LATENT.
Where the advanced dials earn their keep
The two-node refiner pattern - that's the classic. High-noise model for steps 0–N with return_with_leftover_noise enabled, low-noise model for N–end with add_noise disabled. XB_ToolBox even sells a dual loader (XB_ModelLoaderV2) built around exactly that setup. If you're on AMD and the refiner pass keeps dying to fragmentation, this node's cleanup is the guardrail that setup needs.
How it works under the hood
Same design as its sibling: it copies the official INPUT_TYPES, injects cleanup, and on execution pops the cleanup level, runs the memory sweep, then forwards your kwargs (with the legacy latent→latent_image and sampler→sampler_name remaps) to nodes.KSamplerAdvanced().sample(). Nothing custom about the math, everything custom about the hygiene.
Install & usage
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
# or: ComfyUI Manager → "XB_ToolBox"
No extra deps. The same practical ladder as the basic node: leave cleanup off until you see an OOM, then step up one level at a time. For chained advanced setups, remember the leftover-noise contract - if you disable return_with_leftover_noise on a pass the next one expects to continue, the handoff breaks and you get a jump-cut in your denoise, cleanup or no cleanup.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| add_noise | COMBO | 2 options: enable, disable | |
| noise_seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| sampler | COMBO | 44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent | LATENT | — | |
| start_at_step | INT | 00–10000 | — |
| end_at_step | INT | 100000–10000 | — |
| return_with_leftover_noise | COMBO | 2 options: disable, enable | |
| cleanup | COMBO | 不做任何清理 | 4 options: 不做任何清理, 单次缓存清理, 卸载显存模型, 卸载全量模型 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |