project6
c1936a55cb
arch(moe): translate CCCL block_histogram.cuh — segment size histogram for expert load analysis
block_histogram.cuh entire design:
Two algorithms for counting observations per bin:
1. BLOCK_HISTO_SORT: sort → detect discontinuities → run lengths = bin counts
Consistent throughput regardless of distribution.
2. BLOCK_HISTO_ATOMIC: atomicAdd per bin.
Fast for uniform, slow for skewed (atomic contention).
Template param selects algorithm at compile time.
Translation: We already do HISTO_SORT (argsort by expert_id → segment detect).
Added: compute seg_sizes histogram (seg_ends - seg_starts) which enables:
- Understanding expert load balance (skewed = some experts get 100 tokens,
others get 1 → HISTO_ATOMIC contention equivalent: Python loop overhead
for 1-token F.linear calls dominates)
- Future: batch 1-token segments into padded GEMM (HISTO_SORT guaranteed
consistent throughput, matches batch-friendly GEMM patterns)
+ dispatch_copy_mdspan contiguous-check in same commit area.
CCCL source: cub/cub/block/block_histogram.cuh (full 412-line file)
Maps to: qwen3_6_scripts/qwen3_5.py (_pure_pytorch_experts)
2026-08-07 09:12:24 +00:00
..
2026-07-30 16:06:20 +00:00
2026-07-30 16:06:20 +00:00
2026-08-07 07:55:04 +00:00
2026-08-07 08:56:50 +00:00
2026-07-30 16:06:20 +00:00
2026-08-05 08:24:43 +00:00
2026-08-07 07:05:40 +00:00
2026-07-30 16:06:20 +00:00
2026-08-05 08:24:43 +00:00
2026-08-06 06:33:26 +00:00
2026-08-07 08:56:36 +00:00
2026-08-07 04:37:44 +00:00
2026-08-07 04:44:18 +00:00
2026-08-07 06:20:02 +00:00
2026-07-30 16:06:20 +00:00
2026-08-07 02:46:46 +00:00
2026-08-07 08:18:41 +00:00
2026-08-07 09:12:24 +00:00
2026-08-07 07:45:28 +00:00
2026-08-05 08:36:52 +00:00
2026-08-06 02:55:51 +00:00
2026-07-30 16:06:20 +00:00
2026-07-30 16:06:20 +00:00
2026-08-07 09:01:57 +00:00
2026-08-05 08:36:52 +00:00
2026-08-07 06:36:12 +00:00
2026-08-07 01:54:52 +00:00