π Kraken KSampler
The KSampler that stops crashing your WAN and Flux graphs
- model
- positive
- latent_image
- negative
- vae
- LATENT
- IMAGE
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, oroff. 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, orignore. Theautosetting 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 wirenegativein as a conditional input when you want it. - decode_switch + vae + tiled_decode + tile_size - a built-in VAE decode stage. Wire a
vaein, leave decode on, and the node hands back both LATENT and a decoded IMAGE.tiled_decodeon with a sensibletile_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
cfgslider is set for SD habits. - Negative mode surprises. If you're used to always wiring a negative,
autooccasionally making it inert looks like a bug. It's not; checknegative_modeanddebug_logsbefore blaming the node. - Decode on with no VAE = placeholder. Turning decode on but leaving
vaeunplugged returns an IMAGE that isn't your render. Wire the VAE or turn decode off. - The pack touches torch globally. Kraken Tools'
__init__.pyflips 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.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | β | |
| positive | CONDITIONING | β | |
| latent_image | LATENT | β | |
| seed | INT | 00β18446744073709550000 | β |
| steps | INT | 201β10000 | β |
| cfg | FLOAT | 7.000β100 | β |
| sampler_name | 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 | |
| denoise | FLOAT | 1.000β1 | β |
| add_noise | COMBO | 2 options: enable, disable | |
| start_at_step | INT | 00β10000 | β |
| end_at_step | INT | 100000β10000 | β |
| return_with_leftover_noise | COMBO | 2 options: disable, enable | |
| negative_mode | COMBO | auto | 3 options: auto, use, ignore |
| amp_mode | COMBO | auto | 3 options: auto, on, off |
| decode_switch | COMBO | on | 2 options: off, on |
| tiled_decode | COMBO | off | 2 options: off, on |
| tile_size | INT | 25664β2048 | β |
| negativeopt | CONDITIONING | β | |
| vaeopt | VAE | β | |
| debug_logsopt | COMBO | off | 2 options: off, on |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | β |
| IMAGE | IMAGE | β |