PagedAttention keeps a block table per sequence, mapping logical block numbers to physical memory blocks. Attention kernels use this table to find each cached token, so the blocks need not be contiguous in memory.
Implement block_table_lookup(block_table, token_idx, block_size), returning the physical block and offset of a token.
token_idx // block_size.Divide the token index by the block size to get the logical block, look it up in the table, and take the remainder as the offset.
No results yet
Run your code to check it against the examples, or submit to run every test.