PIXELBANKv9.1.0
Menu

Problem Statement

Compute the inclusive prefix sum (cumulative sum) along each row of a (M, N) tensor using tl.cumsum. Each row fits in one block.

Background

tl.cumsum(x, axis=0) returns the running sum along the block axis. Pad invalid lanes with 0 so they don't affect earlier prefixes, and mask them out on store.

Your Task

Implement cumsum_kernel and run(M=64, N=300) comparing to torch.cumsum(x, dim=1).

How it is tested

Your solution must define a top-level function run(...) that allocates inputs on the GPU, launches your Triton kernel, and returns a boolean from torch.allclose(triton_out, torch_reference, ...). The grader prints run(...); the expected output is True.

Example:

Input:
M = 64, N = 300
Output:
True
Reasoning:
  • The input values M = 64 and N = 300 define the size of the tensor, with 64 rows and 300 columns.
  • The cumsum_kernel function computes the cumulative sum along each row using tl.cumsum, padding invalid lanes with 0 and masking them out on store.
  • The result from cumsum_kernel is compared to the result from torch.cumsum(x, dim=1) using torch.allclose, which checks if the two tensors are element-wise equal within a tolerance.
  • Since the implementation of cumsum_kernel is correct and matches the result from torch.cumsum, the output of run(M=64, N=300) is True, indicating that the two results are identical.

Constraints:

  • Use tl.cumsum(row, axis=0)
  • Pad invalid lanes with other=0.0 and mask the store
  • One program per row
๐Ÿ”’

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Triton Row Cumulative Sum - Hard | PixelBank