Back to Home

ComfyUI Doubled Token Rates Without Touching the Model

A 27-billion-parameter model sits on a desktop GPU with a story half told. Every word after that arrives like a coin dropping through a slot, steady and slower than the person waiting for it. In ComfyUI, that pause was never the model thinking hard. It was the model reading itself aloud, one weight at a time.

On November 11, an engineer writing as rattus128 published the fix on the Comfy Org engineering blog. The claim is blunt: the same checkpoints on the same hardware now produce tokens up to twice as fast, with no retraining and no quality loss. A Qwen3.5 9B model on an RTX 5090 went from 106 to 219 tokens per second. On an RTX 5080 it climbed from 91 to 129. A Qwen3.8 27B checkpoint describing a 1536 by 1536 image moved from 55 to 122 tokens per second, and writing a story about an image settled at 137.

The GPU was never the problem

Text generation is sequential by construction. Each token depends on the one before it, and every step requires a full read of the weights. Large-scale inference hides that cost by batching many independent chats. A single ComfyUI workflow does the opposite: one sequence, so every step is a batch of one, and a 27B model quantised to four bits reads roughly 14 gigabytes of weights to produce a single token.

That flips the bottleneck. Diffusion models process the whole latent output on every step, so each weight is used many times and the GPU is limited by how fast it can calculate. A batch-of-one language model is limited by how fast it can read. Two workloads, two optimisations, and the image-generation half of the stack had quietly set the agenda.

Inside the model, most of that read lands in linear layers, handled by GEMM and GEMV kernels. For a single token the matrix is multiplied by a vector with M equal to one. For a small speculative batch it is a very thin matrix, around M equal to three. The blog calls this the skinny linear problem, and skinny is exactly what the old general-purpose INT8 path in v0.40.0 was worst at.

Eight rows for the price of one

The replacement kernel interleaves weights with their per-group scales in the order it consumes them. Each thread block streams one contiguous run instead of hopping between weight and scale tensors, cutting VRAM seeking and keeping the memory bus busy. The relayout happens in place once per model load, needs no extra RAM or VRAM, and is skipped for the fatter diffusion linears, which hide that latency anyway.

Then comes the trick that makes guessing cheap. Tensor cores compute a tile of operations in one instruction, and NVIDIA hardware since the 30 series optimises for a minimum tile dimension of eight. The new kernel arranges weights and inputs so the skinny dimension maps onto that eight-wide tile. For a single token the result is about the same as plain CUDA core instructions. Once speculative drafting pushes M above one, eight rows cost almost exactly what one row costs.

Qwen3.5 and Qwen3.8 are hybrid-attention models, three of every four layers using DeltaNet linear attention and the fourth using grouped-query attention. A new decode kernel handles the short query for a token or a handful of drafts without materialising an attention mask, splitting the cached prefix across thread blocks and combining partial results in the same launch.

The DeltaNet layers held the worst hidden cost. Verifying several draft tokens requires the recurrent state after each of them, and a rejected draft means restoring it, which previously meant snapshotting 64 kibibytes per head per layer after every speculative token. The new kernel records only small per-token intermediates and defers the state update, so the next call replays the accepted tokens and writes the committed state once. It spends arithmetic to save memory traffic, the trade a bandwidth-starved, compute-rich GPU wants.

The tree learns what it is writing

Qwen3.x checkpoints ship with a multi-token-prediction head, a smaller extra layer that guesses upcoming tokens from the hidden state. ComfyUI uses it for speculative decoding. The head drafts several tokens, the next pass verifies them together at roughly the cost of a single token, and every accepted draft saves a full model read.

The old implementation drafted one chain and bet everything on it. If the top choice at the first depth was wrong, the step yielded one token even when the runner-up was right. The adaptive tree version keeps a few runner-up guesses as siblings, verifies the whole tree in one pass, and limits itself to seven drafts so the work still fits in those eight free tile rows.

The shape then adapts to the text. Code, lists and descriptions that echo the prompt reward depth, because long chains get accepted whole. Creative writing rewards breadth, because the top guess is often wrong while the correct token hides in the top three. Every 32 steps the kernel scores all 64 ways of laying out seven draft rows, weights them by measured hit probabilities and CUDA event timings, and switches only when a new shape wins by at least three percent.

Nothing here requires a new workflow. Update ComfyUI, load a Qwen3.x checkpoint, leave the Text Generate node's MTP option on auto, and the decoder reshapes itself while it writes. The gains run on NVIDIA and AMD, on Windows and Linux. The post closed by noting the team is hiring engineers to make open-source generative AI faster everywhere, which suggests those fourteen gigabytes were only the first bill to renegotiate.

Comments

No comments yet. Be the first to share your thoughts!