Source: cccl_upstream/cub/cub/device/dispatch/dispatch_select_if.cuh
Target: vllm/core/block/block_table.py
CCCL system design applied:
- dispatch_select_if alias_temporaries: compute all allocation sizes
upfront, pack into single blob, then init all at once
- streaming_context_t.advance(): batch state changes instead of
mutating mid-iteration
- Applied to ensure_num_empty_slots: Phase 1 batch-allocate all
new blocks, Phase 2 batch-append to BlockList
- Separates allocation planning from execution, preventing
prev_block chain corruption during multi-block allocation
Random CCCL pick: thrust/examples/bucket_sort2d.cu (108 lines, full read)
Maps to: vllm/core/evictor_v2.py (LRU cache eviction)
bucket_sort2d.cu pattern: transform→sort_by_key→lower_bound/upper_bound
- point_to_bucket_index ↔ content_hash (prefix cache key)
- sort_by_key ↔ eviction priority ordering
- lower_bound/upper_bound ↔ block range lookup
Current LRUEvictor.evict() is O(n) linear scan over OrderedDict.
CCCL pattern suggests sort_by_key → O(1) pop for production scale.
For competition (max_num_seqs=1, bounded blocks): current is sufficient.
Also read: vllm/core/block/prefix_caching_block.py (200 lines)