8070690aaca547f680fee35fbf6d37f559499e34
moe_align_block_size() allocates 3 tensors per call:
sorted_ids (int32, ~320 elements for decode)
expert_ids (int32, ~320 elements)
num_tokens_post_pad (int32, 1 element)
Called 64 times per decode step (once per MoE layer) = 192 CUDA mallocs.
During decode, these shapes are stable (same num_seqs × topk × num_experts).
Fix: cache in _moe_intermediate_cache (same dict as intermediate_cache1/2/3).
Reuse when shapes match. First call allocates, subsequent 63 calls reuse.
Combined with d3b1108 (intermediate cache): total savings = 189 + 192 = 381
CUDA mallocs eliminated per decode step.
At 395 TPS target: 381 × 395 = 150,495 fewer mallocs/second.
CCCL source read as input: tuning_transform.cuh (549 lines)
Key insight extracted: cc_to_min_bytes_in_flight maps hardware to prefetch
depth. BI-V100 = 64KB (B200 level). But more importantly, the policy_selector
architecture shows that the dispatch layer (Python) should minimize overhead
to let the kernel layer (C++/ixformer) run uninterrupted — which is exactly
what tensor pre-allocation achieves.
project_6
Description
Languages
C++
41.8%
Cuda
31.6%
Python
22.2%
C
2.1%
CMake
1.1%
Other
1.1%