Sparse attention · Interactive video token layout

Spatial tiling of Q and K/V

One walkthrough, two tabs. See how the original video-token sequences are rearranged into 8 × 8 tiles, how much padding is introduced, and why both finish at 500 blocks.

Q 29,696 real + 2,304 pad
K/V 30,080 real + 1,920 pad
Both → 32,000 slots → 500 blocks
Sparse attention · Q input layout

From 29,696 Q tokens to 500 spatial blocks

A single, step-by-step view of how an original 1D Q sequence is interpreted as video frames, divided into 8 × 8 patches, padded, and flattened into 64-slot blocks.

Benchmark: video tiling enabledFrame size: 45 × 80 tokensSpatial tile: 8 × 8Q only
29,696
Original real Q tokens
→
+2,304
Padding slots added
=
32,000
Padded Q token slots
÷ 64 →
500
Spatial Q blocks
Read this first · scale of every diagram
1 smallest cell = 8 token slots

It covers 1 spatial row × 8 adjacent columns. The number printed inside is the number of real tokens, not a cell ID.

88 real
0 padding
00 real
8 padding
01

Split the original Q sequence into video frames

Before any padding, these are all real tokens. Each complete video frame is 45 rows × 80 tokens per row = 3,600 tokens.

Frame 1 · token 1Frame 9 · token 29,696
8 × 3,600+896=29,696 real Q tokens

Frame 9 is a partial frame: 896 = 11 complete rows × 80 + 16 additional tokens in row 12. The first eight frames are full.

02

Tile each complete frame: 45 × 80 → 60 tiles

This happens to every one of the first eight frames. You see one representative frame below.

One complete frame 10 tile columns × 6 tile rows

→ 80 tokens across = 10 smallest cells × 8 tokens↓ 45 real rows + 3 padded rows
8 real tokens in smallest cell0 real (8 padding)

What is one tile?

→
8 smallest cells stacked
8 rows × 8 tokens per row
= 64 token slots per tile
Horizontal tiles80 ÷ 8 = 10
Vertical tile rows⌈45 ÷ 8⌉ = 6
Tile count10 × 6 = 60

Where does padding appear?

Rows 1–40400 blue cells
Rows 41–4550 blue cells
Rows 46–4830 coral cells
Padding tokens30 × 8 = 240

Each frame has 50 full tiles and 10 edge tiles. Each edge tile contains 40 real tokens + 24 padding slots.

Across all 8 full frames
8 × 60 = 480 blocks
8 × 240 = 1,920 padding
03

Tile the 9th (partial) frame: 896 → 1,280 slots

Q ends partway through row 12. Fixed-height 8-row tiles still occupy two tile rows: rows 1–8 and 9–16.

Partial frame 9 20 outlined 8 × 8 tiles

→ Each smallest cell = 8 token slots↓ 16 allocated rows
8 = 8 real tokens0 = 0 real, 8 padded slots
Inspect a smallest cell · click any number above
Row 12, columns 17–24: 0 real tokens, 8 padding slots
Enclosing tile: rows 9–16, columns 17–24

How many real tokens are in each row?

Rows 1–88 × 80 = 640
Rows 9–113 × 80 = 240
Row 122 blue cells × 8 = 16
Rows 13–160 real tokens
Total real tokens896

Why not stop at row 12?

Tile row #2 covers all rows 9–16 because each tile's height is 8. Even if rows 13–16 contain no real Q tokens, their slots belong to the allocated tiles.

10 tiles in rows 1–810 × 64 = 640
10 tiles in rows 9–1610 × 64 = 640
Total allocated1,280 slots
Padding slots1,280 − 896 = 384

Inside the 20 tiles

First 10 tiles (rows 1–8)64 real each
Next 2 tiles (rows 9–16)32 real each
Last 8 tiles (rows 9–16)24 real each

The 384 padded slots are 48 coral cells × 8 slots. Those coral cells are what the extra tile rows and row-12 remainder introduce.

04

Flatten spatial tiles into 500 Q blocks

Each outlined 8 × 8 tile becomes one contiguous block of 64 slots in the tiled Q sequence. Click any tiny block to inspect its real-token count.

Real portion of blockPadded portion of blockEach small bar in this diagram = one entire 64-slot block (not one 8-slot cell).
Selected Q block
Frame 9 · local block 20 · 24 real tokens + 40 padding slots
Q block #500 of 500, after tiling and flattening.
29,696
Real Q tokens · unchanged
2,304
Padding · 1,920 + 384
32,000
500 blocks × 64 slots