Skip to content

Implement decorators to register benchmarks add axis and options#347

Open
oleksandr-pavlyk wants to merge 2 commits intoNVIDIA:mainfrom
oleksandr-pavlyk:add-decorators
Open

Implement decorators to register benchmarks add axis and options#347
oleksandr-pavlyk wants to merge 2 commits intoNVIDIA:mainfrom
oleksandr-pavlyk:add-decorators

Conversation

@oleksandr-pavlyk
Copy link
Copy Markdown
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk commented May 4, 2026

Closes #351

Add decorators for registering a benchmark, adding axis and options.

cuda.bench.register(fn) continues returning Benchmark, and supports
legacy use.

New signature added: cuda.bench.register() which returns a decorator.

@bench.register()
@bench.axis.float64("Duration (s)", [7e-5, 1e-4, 5e-4])
@bench.option.min_samples(120)
def single_float64_axis(state: bench.State):
   ...

This pattern supplements earlier pattern of

def single_float64_axis(state: bench.State):
   ...

bench.register(single_float64_axis
    ).add_floa64_axis("Duration (s)", [7e-5, 1e-4, 5e-4]
    ).set_min_samples(120);

This PR adds to #346, and should be merged after it has been merged.
Update: The #346 has been merged.

cuda.bench.register(fn) continues returning Benchmark, and supports
legacy use.

New signature added:
   cuda.bench.register():
      Returns a decorator

```
@bench.register()
@bench.axis.float64("Duration (s)", [7e-5, 1e-4, 5e-4])
@bench.option.min_samples(120)
def single_float64_axis(state: bench.State):
   ...
```
The C++ counterpart's purpose is to demonstrate use of CUPTI
metrics, but these are not supported in Python bindings, so
this example is a duplicate of example/throughput.py
@jrhemstad jrhemstad moved this from Todo to In Review in CCCL May 5, 2026
@oleksandr-pavlyk oleksandr-pavlyk changed the title Add decorators Implement decorators to register benchmarks add axis and options May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

cuda.bench should support decorators to annotate functions as benchmarks

2 participants