Nodes/H3 SGLang Pack/Patch Sage Attention KJ (SGLang)
ComfyUI Node

Patch Sage Attention KJ (SGLang)

Sage Attention, but the attention runs inside SGLang

By TensorClay·Created about a month ago·Updated 22 days ago· 6
Patch Sage Attention KJ (SGLang)
  • model
  • MODEL
sage_attentionfalse
allow_compilefalse

Kijai's Patch Sage Attention KJ is one of those nodes that just shows up in every serious video workflow - SageAttention is the de-facto attention speedup for Wan and friends, and Kijai's patch is how you turn it on. It works by patching the attention function on the model object in the ComfyUI process. That mechanism is the whole reason this node exists: with H3 running inside SGLang workers, a host-side patch never touches the model that's actually denoising. Patch Sage Attention KJ (SGLang) mirrors the upstream contract but applies SageAttention inside the workers, where the blocks live.

The inputs

Two things to set, mirroring KJNodes' node:

  • model - an H3 SGLang model from this pack's loader.
  • sage_attention - the mode enum, and this is where all the real choice lives: disabled, auto, the INT8-QK variants (sageattn_qk_int8_pv_fp16_cuda, ..._triton, sageattn_qk_int8_pv_fp8_cuda, ..._fp8_cuda++), plus the newer sageattn3 and sageattn3_per_block_mean for Blackwell hardware.

The optional allow_compile boolean (default false) lets SageAttention use torch.compile for its kernel - that requires sageattn 2.2.0 or newer. The author's tooltip says it plainly, so pass it on: to revert, run the node again with disabled.

Installing it

The pack install is shared (Manager, search "H3 SGLang Pack", or git clone https://github.com/TensorClay/ComfyUI-H3-SGLang-Pack.git into ComfyUI/custom_nodes, restart). But SageAttention itself is an optional dependency you must add to ComfyUI's Python environment:

pip install sageattention

And there's a hardware wrinkle layered on top: the sageattn3 choices additionally require the separately built SageAttention3 package and a supported Blackwell GPU. On an older card, pick from the sageattn_qk_int8_pv_fp16_* or fp8_cuda options or leave it on auto. If you select a mode the library doesn't support, generation fails on the worker side - the node itself can't fully validate what SGLang will do with the mode until it runs.

The compatibility trap

Here's the one that'll actually bite you. If you migrated a native KJNodes workflow, you may still have the MiniMax H3 Mem Eff Sage Attention Patch in the graph after this node. The pack says it explicitly: keeping it after Patch Sage Attention KJ (SGLang) does nothing for the distributed path. That node patches native H3 blocks in the ComfyUI process, while the real blocks run inside SGLang workers using this pack's worker-native Sage implementation. For new SGLang workflows, connect this pack's Sage node directly to the sampler and don't carry over the host-side patch. The pack's compatibility target is the KJNodes contract at a specific commit - Kijai moves fast, so if KJNodes changes the enum or behavior after a bump, expect this node to lag behind.

On the speed front, the README's benchmark has a mildly anticlimactic note: on warm runs, Sage Attention landed about as fast as automatic and the other attention choices (37.3s vs 35.8–37.5s across the board). The win is real on some hardware, neutral on others - worth one A/B run to see which camp you're in.

CategorySGLang/MiniMax H3

Inputs (3)

NameTypeDefaultDescription
modelMODEL
sage_attentionCOMBOfalsePatch the attention of the model passing through this node to use sageattn. To revert, run this node again with the disabled option. Requires the sageattention library to be installed.
allow_compileoptBOOLEANfalseAllow the use of torch.compile for the sage attention function, requires latest sageattn 2.2.0 or higher.

Outputs (1)

NameTypeDescription
MODELMODEL