PIXELBANKv9.1.0
Menu

Problem Statement

Compute a scaled matmul C = alpha * (A @ B) with alpha a runtime scalar.

Background

Multiply the accumulator by alpha in the epilogue. This mirrors BLAS GEMM's alpha parameter.

Your Task

Implement scaled_matmul_kernel and run(M=128, N=128, K=128, alpha=0.5) comparing to alpha * (A @ B).

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 = 128, N = 128, K = 128, alpha = 0.5
Output:
True
Reasoning:
  • We start with the given input values: M = 128, N = 128, K = 128, and alpha = 0.5.
  • The scaled_matmul_kernel function computes the matrix product of A and B, resulting in a temporary matrix product A@BA @ B.
  • The kernel then scales this temporary result by the given alpha value, 0.5โ‹…(A@B)0.5 \cdot (A @ B), to produce the final output matrix C.
  • The output of the run function is True if the resulting matrix C is close to the reference solution computed by alpha * (A @ B), which is verified using torch.allclose.

Constraints:

  • Tiled matmul accumulator
  • Epilogue: acc = acc * alpha
  • alpha is a runtime scalar
๐Ÿ”’

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 Scaled Matmul - Hard | PixelBank