muh-pipeline b4803c3259 [BASE] qwen3_6_scripts/sampler.py: CCCL topk unsorted output optimization
Random CCCL pick: cub/test/catch2_test_device_topk_env_api.cu (290 lines, full)

CCCL DeviceTopK uses cuda::execution::output_ordering::unsorted —
top-k results are NOT sorted by default. The test sorts results
AFTER retrieval only for verification, not during the algorithm.

Our sampler's torch.topk(logits, k) defaults to sorted=True, which
adds an unnecessary final sort step after the radix selection.
For sampling, we only need the THRESHOLD value (min of top-k set)
to mask logits below it — the ordering within top-k is irrelevant.

Change: torch.topk(..., sorted=False) in the top-k fast path.
This skips the O(k log k) sort of the selected elements.
For Qwen3.6 with top_k=20, k=20 sort is cheap, but it's free
to eliminate and matches CCCL's unsorted-by-default design.

CCCL also teaches: determinism::not_guaranteed is acceptable for
top-k in sampling contexts (temperature > 0 = inherent randomness).

Base file modified: qwen3_6_scripts/sampler.py (deployed via patch_ops.sh)
2026-08-06 02:55:51 +00:00
2026-07-30 17:03:23 +08:00

project_6

Description
No description provided
Readme 427 MiB
Languages
C++ 41.8%
Cuda 31.6%
Python 22.2%
C 2.1%
CMake 1.1%
Other 1.1%