Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/pmpp-v2-checkers.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
name: PMPP v2 checker regression tests
name: PMPP v2 and v3 checker regression tests

on:
pull_request:
paths:
- "problems/pmpp_v2/**"
- "problems/pmpp_v3/**"
- "problems/pmpp_v2.yaml"
- "problems/pmpp_v3.yaml"
- "tests/pmpp_v2/**"
- ".github/workflows/pmpp-v2-checkers.yml"
push:
branches: [main]
paths:
- "problems/pmpp_v2/**"
- "problems/pmpp_v3/**"
- "problems/pmpp_v2.yaml"
- "problems/pmpp_v3.yaml"
- "tests/pmpp_v2/**"
- ".github/workflows/pmpp-v2-checkers.yml"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This repo holds reference kernels for the KernelBot which hosts regular competit
You can see what's going on [gpumode.com](https://www.gpumode.com/)

## Competitions
1. [PMPP practice problems](https://github.com/gpu-mode/reference-kernels/tree/main/problems/pmpp_v2)
1. [PMPP v3 practice problems](problems/pmpp_v3) ([v2 archive](problems/pmpp_v2))
2. [AMD $100K kernel competition](problems/amd)
3. [BioML kernels](problems/bioml)
4. [AMD $100K distributed kernel competition](problems/amd_distributed)
Expand Down
20 changes: 10 additions & 10 deletions problems/pmpp_v2.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
name: pmpp_v2 Practice Problems
# when does this end (individual problems might close earlier)
deadline: ""
deadline: "2026-12-01T04:21:18Z"
# A description for this particular competition
description: ""
# the list of problems
problems:
- directory: pmpp_v2/conv2d_py
name: conv2d_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/grayscale_py
name: grayscale_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/histogram_py
name: histogram_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/matmul_py
name: matmul_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/prefixsum_py
name: prefixsum_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/sort_py
name: sort_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/vectoradd_py
name: vectoradd_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v2/vectorsum_py
name: vectorsum_v2
deadline: "2100-12-31"
deadline: "2026-12-01T04:21:18Z"
gpus:
- B200
- H100
- A100
- L4
- L4
71 changes: 71 additions & 0 deletions problems/pmpp_v3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: pmpp_v3 Practice Problems
# when does this end (individual problems might close earlier)
deadline: ""
# A description for this particular competition
description: ""
# the list of problems
problems:
- directory: pmpp_v3/conv2d_py
name: conv2d_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/grayscale_py
name: grayscale_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/histogram_py
name: histogram_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/matmul_py
name: matmul_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/prefixsum_py
name: prefixsum_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/sort_py
name: sort_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/vectoradd_py
name: vectoradd_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
- directory: pmpp_v3/vectorsum_py
name: vectorsum_v3
deadline: "2100-12-31"
gpus:
- B200
- H100
- A100
- L4
19 changes: 19 additions & 0 deletions problems/pmpp_v3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# PMPP v3 practice problems

PMPP v3 starts eight fresh leaderboards with the current hardened evaluations
from reference-kernels commit `4c06b025c9193d80f6748e3139d6e5e17423ad7a`.
The v2 leaderboard results remain available as an archive.

Use the names in [pmpp_v3.yaml](../pmpp_v3.yaml): `conv2d_v3`, `grayscale_v3`,
`histogram_v3`, `matmul_v3`, `prefixsum_v3`, `sort_v3`, `vectoradd_v3`, and
`vectorsum_v3`. All eight support B200, H100, A100, and L4.

```sh
popcorn submit --leaderboard grayscale_v3 --gpu B200 --mode leaderboard submission.py
```

The checks require plain, materialized tensors with the expected shape, dtype,
device, and finite values. Sorting checks the exact sorted input; prefix sum uses
a tolerance based on input magnitude. Ranked runs regenerate inputs and check
every timed output. V3 preserves those checks, test cases, and benchmark shapes
in an independent directory so later changes can be versioned separately.
66 changes: 66 additions & 0 deletions problems/pmpp_v3/conv2d_py/reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from utils import make_match_reference, DeterministicContext
import torch
import torch.nn.functional as F
from task import input_t, output_t


def ref_kernel(data: input_t) -> output_t:
"""
Reference implementation of 2D convolution using PyTorch.
Args:
data: Tuple of (input tensor, kernel tensor)
Returns:
Output tensor after convolution
"""
with DeterministicContext():
input_tensor, kernel, output = data
return F.conv2d(
input_tensor,
kernel,
# No padding and no striding
stride=1,
padding=0,
)


def generate_input(
size: int, kernelsize: int, channels: int, batch: int, seed: int
) -> input_t:
"""
Generates random input and kernel tensors.
Returns:
Tuple of (input tensor, kernel tensor)
"""
gen = torch.Generator(device="cuda")
gen.manual_seed(seed)

# Generate input tensor: [batch, in_channels, height, width]
input_tensor = torch.randn(
batch, channels, size, size, device="cuda", dtype=torch.float32, generator=gen
).contiguous()

# Generate kernel tensor: [out_channels, in_channels, kernel_height, kernel_width]
# Here we use same number of output channels as input channels for simplicity
kernel = torch.randn(
channels,
channels,
kernelsize,
kernelsize,
device="cuda",
dtype=torch.float32,
generator=gen,
).contiguous()

output_tensor = torch.empty(
batch,
channels,
size - kernelsize + 1,
size - kernelsize + 1,
device="cuda",
dtype=torch.float32,
)

return input_tensor, kernel, output_tensor


check_implementation = make_match_reference(ref_kernel, rtol=1e-3, atol=1e-3)
10 changes: 10 additions & 0 deletions problems/pmpp_v3/conv2d_py/solutions/correct/ref.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from task import input_t, output_t
from utils import DeterministicContext
import torch.nn.functional as F


def custom_kernel(data: input_t) -> output_t:
input_tensor, kernel, output = data
with DeterministicContext():
output[...] = F.conv2d(input_tensor, kernel, stride=1, padding=0)
return output
7 changes: 7 additions & 0 deletions problems/pmpp_v3/conv2d_py/solutions/wrong/empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# the nop kernel
from task import input_t, output_t


def custom_kernel(data: input_t) -> output_t:
_, _, output = data
return output
17 changes: 17 additions & 0 deletions problems/pmpp_v3/conv2d_py/submission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from task import input_t, output_t
import torch
import torch.nn.functional as F


def custom_kernel(data: input_t) -> output_t:
"""
Implementation of 2D convolution using PyTorch with no padding and no striding.
Args:
data: Tuple of (input tensor, kernel tensor)
spec: Convolution specifications
Returns:
Output tensor after convolution
"""
input_tensor, kernel, output = data
output[...] = F.conv2d(input_tensor, kernel, stride=1, padding=0)
return output
13 changes: 13 additions & 0 deletions problems/pmpp_v3/conv2d_py/task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import TypedDict, TypeVar, Tuple
import torch

input_t = TypeVar("input_t", bound=Tuple[torch.Tensor, torch.Tensor, torch.Tensor])
output_t = TypeVar("output_t", bound=torch.Tensor)


class TestSpec(TypedDict):
size: int
kernelsize: int
channels: int
batch: int
seed: int
50 changes: 50 additions & 0 deletions problems/pmpp_v3/conv2d_py/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# name: conv2d-py

files:
- {"name": "submission.py", "source": "@SUBMISSION@"}
- {"name": "task.py", "source": "task.py"}
- {"name": "utils.py", "source": "../utils.py"}
- {"name": "reference.py", "source": "reference.py"}
- {"name": "eval.py", "source": "../eval.py"}

lang: "py"

description: |
Return a plain, materialized torch.Tensor. Tensor subclasses and deferred
computation during checking are not allowed; compute the result inside custom_kernel.

Implement a 2D convolution kernel that matches the reference implementation.
The kernel should perform 2D convolution with the given specifications
We will benchmark different sizes, kernel sizes, channels and batch sizes but they will all
be even numbers with the exception of batch size which can sometimes be 1
We assume no padding and striding and instead vary the size of the input and kernel,
number of channels, and batch size.

Input: Tuple of (input_tensor, kernel)
- input_tensor: 4D tensor of shape (batch, channels, height, width) with arbitrary values
- kernel: 4D tensor of shape (channels, channels, kernelsize, kernelsize) with arbitrary values
Output: 4D tensor of shape (batch, channels, height-kernelsize+1, width-kernelsize+1) with convolved values

config:
main: "eval.py"

templates:
Python: "../template.py"

tests:
- {"size": 32, "kernelsize": 4, "channels": 16, "batch": 1, "seed": 4242}
- {"size": 32, "kernelsize": 4, "channels": 16, "batch": 2, "seed": 5236}
- {"size": 64, "kernelsize": 4, "channels": 32, "batch": 1, "seed": 1001}
- {"size": 64, "kernelsize": 8, "channels": 32, "batch": 2, "seed": 5531}
- {"size": 128, "kernelsize": 8, "channels": 64, "batch": 1, "seed": 9173}

benchmarks:
- {"size": 128, "kernelsize": 8, "channels": 64, "batch": 4, "seed": 54352}
- {"size": 128, "kernelsize": 16, "channels": 64, "batch": 4, "seed": 93246}
- {"size": 256, "kernelsize": 16, "channels": 128, "batch": 2, "seed": 6256}
- {"size": 256, "kernelsize": 16, "channels": 128, "batch": 2, "seed": 8841}
- {"size": 256, "kernelsize": 32, "channels": 128, "batch": 1, "seed": 6252}

test_timeout: 180
benchmark_timeout: 180
ranked_timeout: 420
Loading
Loading