Nodes/Kraken Tools/πŸ™ Kraken KSampler
ComfyUI Node

πŸ™ Kraken KSampler

The KSampler that stops crashing your WAN and Flux graphs

By krakenunboundΒ·Created 8 months agoΒ·Updated 8 months agoΒ· 2
πŸ™ Kraken KSampler
  • model
  • positive
  • latent_image
  • negative
  • vae
  • LATENT
  • IMAGE
β—„seed0β–Ί
β—„steps20β–Ί
β—„cfg7.00β–Ί
β—„sampler_nameβ–Ύβ–Ί
β—„schedulerβ–Ύβ–Ί
β—„denoise1.00β–Ί
β—„add_noiseβ–Ύβ–Ί
β—„start_at_step0β–Ί
β—„end_at_step10000β–Ί
β—„return_with_leftover_noiseβ–Ύβ–Ί
β—„negative_modeautoβ–Ί
β—„amp_modeautoβ–Ί
β—„decode_switchonβ–Ί
β—„tiled_decodeoffβ–Ί
β—„tile_size256β–Ί
β—„debug_logsoffβ–Ί

Here's a stack trace that has ended more than a few WAN 2.2 sessions than anyone wants to admit:

RuntimeError: Unexpected floating ScalarType in at::autocast::prioritize

It's ugly, it's confusing, and it's caused by a second, outer torch.autocast context being wrapped around a model that already manages its own precision. WAN, Flow models, and fp8 checkpoints handle precision internally - the community shorthand is that they're "autocast-native" - and Comfy's older samplers wrapping them in another autocast context blows up. πŸ™ Kraken KSampler exists specifically to not do that.

It's the sampling node in Kraken Tools (krakenunbound/comfyui-kraken-tools), a wrapper around Comfy's KSampler with an amp_mode of auto that detects WAN/Flow/fp8 models and disables the outer autocast for them, while leaving it on for ordinary SD/SDXL where AMP is a free speedup. If you've been running WAN 2.2 with a stock KSampler and a custom node pack that sets torch.autocast globally, this is the fix.

How it works

All the standard knobs are there - seed, steps, cfg, sampler_name (the full 44-entry list), scheduler (9 options including karras and sgm_uniform), denoise, add_noise, start_at_step / end_at_step, return_with_leftover_noise - so it drops in where any KSampler goes. The differences are the parts most samplers don't have:

  • amp_mode - auto (default), on, or off. In auto it peeks at the model and disables the outer autocast for WAN/Flow/fp8. You can force it either way; you almost never need to. For reference, the AMP dtype it picks is bf16 on Ampere-or-newer GPUs (SM 80+), fp16 below.
  • negative_mode - auto, use, or ignore. The auto setting is a quiet modern-model lifesaver: guidance-distilled models like Flux run at CFG 1 and don't want your negative prompt doing anything, and some WAN variants ignore it entirely. Auto handles "this model doesn't need a negative" without you re-plumbing the graph. You can still wire negative in as a conditional input when you want it.
  • decode_switch + vae + tiled_decode + tile_size - a built-in VAE decode stage. Wire a vae in, leave decode on, and the node hands back both LATENT and a decoded IMAGE. tiled_decode on with a sensible tile_size (256 default) is the answer for big latents on small cards - it decodes in chunks so a 2K render doesn't OOM the VAE. If you leave decode on with no VAE connected, the node tells you loudly instead of silently failing.
  • debug_logs - an optional that prints what the node decided (AMP state, decode path) to the console. Turn it on once when something's weird.

Outputs

  • LATENT β†’ the sampled latent, for a separate VAE decode or upscale-in-latent.
  • IMAGE β†’ the decoded image (or a placeholder if you turned decode off), straight to a preview/Save node.

Install

Standard pack install. ComfyUI Manager β†’ search "Kraken Tools" β†’ Install β†’ restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/krakenunbound/comfyui-kraken-tools
cd comfyui-kraken-tools
pip install -r requirements.txt

The node is "compatible with ComfyUI 0.3.x+ and PyTorch 2.x" per the author, and it defensively tries several KSampler kwargs to bridge version differences. No model downloads.

Where people get burned

  • CFG on WAN. WAN 2.2 doesn't want the SDXL-style CFG around 7; it wants low-to-none. If your WAN output looks overcooked, the sampler isn't broken - the cfg slider is set for SD habits.
  • Negative mode surprises. If you're used to always wiring a negative, auto occasionally making it inert looks like a bug. It's not; check negative_mode and debug_logs before blaming the node.
  • Decode on with no VAE = placeholder. Turning decode on but leaving vae unplugged returns an IMAGE that isn't your render. Wire the VAE or turn decode off.
  • The pack touches torch globally. Kraken Tools' __init__.py flips on TF32 matmul and cudnn benchmark at import. That's a background detail, not a sampler setting, but it means this pack changes your runtime slightly the moment it's installed.

If you never touch WAN or fp8 models, the stock KSampler is fine and you don't need this. If you do, this is the node that turns a "WAN crashed with an autocast error" week into a "WAN just ran" afternoon.

CategoryπŸ¦‘ Kraken Tools/Sampling

Inputs (21)

NameTypeDefaultDescription
modelMODELβ€”
positiveCONDITIONINGβ€”
latent_imageLATENTβ€”
seedINT00–18446744073709550000β€”
stepsINT201–10000β€”
cfgFLOAT7.000–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
denoiseFLOAT1.000–1β€”
add_noiseCOMBO2 options: enable, disable
start_at_stepINT00–10000β€”
end_at_stepINT100000–10000β€”
return_with_leftover_noiseCOMBO2 options: disable, enable
negative_modeCOMBOauto3 options: auto, use, ignore
amp_modeCOMBOauto3 options: auto, on, off
decode_switchCOMBOon2 options: off, on
tiled_decodeCOMBOoff2 options: off, on
tile_sizeINT25664–2048β€”
negativeoptCONDITIONINGβ€”
vaeoptVAEβ€”
debug_logsoptCOMBOoff2 options: off, on

Outputs (2)

NameTypeDescription
LATENTLATENTβ€”
IMAGEIMAGEβ€”