从零实现 LLM Inference:037. Paged Attention Slot Mapping
block_table 不再每步 gather/copy:把它常驻 GPU,用 slot_mapping 让 triton kernel 直接索引,decode 吞吐更稳。
block_table 不再每步 gather/copy:把它常驻 GPU,用 slot_mapping 让 triton kernel 直接索引,decode 吞吐更稳。
paged attention decode 每步重建 block_table 太浪费:按 session 缓存 row,只在 block 变化时更新,decode 吞吐和 TPOT 更稳。
paged attention decode 路径里不该构建 attention_mask;同时把 block_tables 的 H2D copy 合并成一次 async,收一点点 TPOT/throughput。
pack admission 会把 active sessions 拉得很高:加一个 max_active_requests(max_num_seqs)把 decode backlog 的 ITL/TPOT tail 收回来。
token budget + FIFO 仍然会遇到 head-of-line blocking:用 lookahead packing 把短请求先塞进 prefill,收敛 TTFT p99。