Streamlining CUB with a Single-Call API

AI-generated summary of reporting by NVIDIA Developer Blog. Read the original for the full story.

Why it matters

CUDA 13.1's single-call CUB API removes the two-call boilerplate every CUDA developer currently writes, with zero measured performance overhead.

Read this as

CUB is a library of ready-made GPU algorithms like sorting and counting, part of NVIDIA's CUDA toolkit for programming graphics processors. Traditionally, programmers had to call each function twice: once to ask how much scratch memory it needs, then again to run it after allocating that memory. CUDA 13.1 adds a one-call version that handles the memory automatically, staying just as fast. This mostly affects CUDA programmers, who no longer need wrapper code that many teams, including PyTorch, maintained.

NVIDIA's CUDA 13.1 adds a single-call interface to CUB, the GPU algorithm library underpinning sorting, scanning and histogram operations in performance-critical C++ code. The change eliminates the repetitive two-call pattern that production teams, including PyTorch, currently paper over with macros and wrappers. NVIDIA reports zero overhead versus the old method. Teams using CUDA can simplify their codebases now; the old two-phase API remains supported, so there is no forced migration.

CUB's new single-call API in CUDA 13.1 embeds temporary storage allocation inside each device primitive, defaulting to stream-ordered cudaMallocAsync so execution remains fully asynchronous. An environment (env) argument accepts memory resources, cuda::stream_ref streams, and future execution options like determinism guarantees via cuda::std::execution. Benchmarked normalized runtimes for ExclusiveSum show zero overhead versus the two-phase API. Limitation: devices lacking cudaMallocAsync support require an explicitly passed memory resource.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

CUDA 13.1 CUB PyTorch NVIDIA Thrust CCCL

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading