Krea 2 Scanline Attention
Scanline Attention Is the Other Half of a Krea 2 LoRA
- model
- MODEL
Most LoRAs do their work in the weights. A scanline-distilled LoRA does half its work in the attention pattern, and the weights are worth little unless that pattern comes back at inference. That's what this node puts back. If you've grabbed a scanline LoRA for Krea 2 and thought "this looks soft and vaguely wrong", you skipped it.
Why anyone would do this to Krea 2
Krea 2 is a 12B single-stream transformer and the base the open ecosystem built on through 2026. Every image token attends to every other one plus the whole text prefix - fine at 1024, exactly what makes big canvases crawl. Sparse attention cuts the cost, but a model trained dense can't use a restricted view, so you train under the restriction: distil a LoRA while the DiT can only look along rows, then re-apply the rows at inference. The author (LodestoneRock, the Chroma person, behind the RamTorchRun trainer this node mirrors) shipped this so that graph is reproducible on your machine.
What the mask actually is
Two rules. Text is global: text tokens see everything, and every image token sees all of them. Image tokens are the constrained ones - each attends only to image tokens within window // 2 rows of its own. Rows, not tokens. At 1024×1024 the latent is 128×128 and the node's wrapper halves that to a 64×64 token grid, so window 11 gives each token five rows up and five down out of 64 - attention in stripes, text glued on top of all of them.
The fiddly part is alignment. Training held the image at a 128-aligned offset with text padded out to 512; ComfyUI hands the model unpadded text. So the node re-pads text and the tail to multiples of 128, masks the padding out, and runs flex_attention over a cached block mask built at 128 tiles. tile_aligned admits every valid pair inside an active tile - the graph training actually saw. Off gives the cleaner diagonal band: close, but not the same thing.
The settings that matter
One MODEL in, one MODEL out - wire it after your LoRA loader and into the sampler. Three widgets:
enabled is the one you'll use most. Off returns the model completely unpatched, so you can A/B the LoRA with and without the pattern on a fixed seed - the fastest way to learn whether a LoRA needs this node at all.
window is an odd integer, default 11, max 255. Leave it unless the LoRA card says otherwise - the example runs window 11 next to a LoRA named scan11, and mismatching them is the quietest way to get mediocre output.
tile_aligned stays on - it's the trained graph. Off is an experiment, not a setting.
Installing
ComfyUI Manager, search "Krea 2 Scanline", or:
cd ComfyUI/custom_nodes
git clone https://github.com/lodestone-rock/krea2_scanline
Restart. No requirements.txt, no dependencies in pyproject.toml - it all comes from torch and ComfyUI. Two hard requirements instead: ComfyUI 0.32.0 or newer - the attention-override contract this node hooks into - and CUDA, because flex_attention isn't running on a CPU.
The node needs no model files, but the workflow does: your Krea 2 checkpoint, the Qwen3-VL text encoder, the Qwen-Image VAE. The pack ships workflows/krea2_scanline_t2i.json, wired for the author's own turbo build and LoRA at 8 steps, CFG 1, euler, simple - swap the filenames, keep the sampler settings.
Where people get burned
Wrong model. Anything non-Krea 2 gets a hard error, not a warning: Krea2ScanlineAttention supports Krea 2 models only. Good. Reaching for it with a Flux or SDXL checkpoint because the name sounded useful is the usual first mistake.
"It's doing nothing." Any call carrying extra tokens - reference latents, the reference-image tricks people run on Krea 2 - falls back to dense attention, logging [krea2-scanline] extra tokens (reference latents?): dense attention for this call once. You'd never notice without the console, and you'd be running base-model attention under a LoRA that wants the stripes.
The first generation stalls. It compiles flex_attention on first use and caches masks per device, prompt length and resolution, eight at a time - change either and it rebuilds. Don't benchmark the first render.
AMD or CPU. attend raises scanline attention requires CUDA from inside the sampler, with no fallback. Non-CUDA backends need not apply.
Stacking attention nodes. It wraps whatever override already exists and calls through to it on dense fallbacks - but whichever node sets an override last owns it, so keep this one at the end of the chain.
Speed without the LoRA. The mask cuts most of the attention work and the payoff grows with resolution, but the base model never trained under it - run it bare and you buy speed with coherence. Use the pairing or skip the node.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| enabled | BOOLEAN | true | — |
| window | INT | 111–255 | Odd number of latent-token rows each image token attends to. |
| tile_aligned | BOOLEAN | true | Admit every pair in an active 128x128 tile (the trained graph). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |