LTX Attn — Query Map
Flip the lens and see who's doing the looking
- query_map
Key Map answers "what is this head looking at?" Query Map answers the mirror question: "which tokens are actively doing the looking?" The pack itself frames it as "who is actively looking" - and unlike the Key Map, this one works for both self-attention and cross-attention, which is where it gets genuinely interesting.
Cross-attention is video→text: each video token queries against the text tokens from your prompt. So the Query Map in ca mode shows you which video regions are attending to the prompt's tokens - the classic way to see prompt adherence as a spatial pattern. In sa mode it's the self-attention mirror of the Key Map, showing which regions of the frame are emitting the attention.
How it works
Where Key Map collapses the query dimension (W.mean(dim=1)), this collapses the key dimension (W.mean(dim=2)), giving you a [Sq] vector of "total attention emitted by each query token," reshaped to [frames, latent_h, latent_w]. One rendered tile per head, same layout as the Key Map.
The knob that unlocks the good stuff is key_token_idx. Set it to -1 (default) and you average over all keys - the whole picture. Set it to a specific text token index in ca mode and you isolate which video regions are attending to that one token. That's how you ask "where in the frame is the model looking at the word 'sword'?" - a genuinely useful diagnostic when a prompt isn't landing where you expect.
The inputs that matter
attn_type-saorca. This is the decision that changes what the map means.block_idx,head_indices,step_idx- same as Key Map: which block, which heads, which denoising step (-1= last captured).key_token_idx- the text-token isolator described above.aggregate_frames-mean/max/firstfor collapsing frames.num_frames,latent_height,latent_width- same geometry requirement as Key Map; these must exactly match the capture or you get a shape error.LTX Latent Dimsexists to feed these.normalize_per_head,cell_size,colormap- rendering details; defaults are fine.
Output is a single query_map IMAGE.
Same prerequisites as its sibling: the block must have been captured with store_mode=full_fp16 (or hybrid + full_blocks) so a dense multi-head map exists. A reduced capture won't have one, and a block stored via full_targets (sparse per-head dict) raises - single-head consumers like Head Freeze don't care, but this node needs every head.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/g-raw/ComfyUI-LTX-Attention-Toolkit.git
Restart ComfyUI. No extra dependencies, no model downloads - same story as the rest of the pack. And the same WIP caveat: store formats can break between versions.
Common issues
Mostly the same three as Key Map: geometry mismatch (feed the right num_frames/latent dims), no dense map because you captured in reduced mode, and forgetting that the store only exists after the capture run finishes - queue this node as a separate later run with the handle typed in. One more: in ca mode, don't set key_token_idx past the number of text tokens in your prompt - it clamps to the last key, so you'll silently be looking at a different token than you think.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| store_handle | STRING | — | |
| attn_type | COMBO | sa | 2 options: sa, ca |
| block_idx | INT | 00–47 | — |
| step_idx | INT | -1-1–255 | — |
| head_indices | STRING | all | — |
| num_frames | INT | 11–256 | — |
| latent_height | INT | 321–256 | — |
| latent_width | INT | 321–256 | — |
| key_token_idx | INT | -1-1–65535 | — |
| aggregate_frames | COMBO | mean | 3 options: mean, max, first |
| colormap | COMBO | inferno | 7 options: inferno, viridis, magma, plasma, hot, turbo, +1 |
| normalize_per_head | BOOLEAN | true | — |
| cell_size | INT | 9616–512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| query_map | IMAGE | — |