{"slug": "gpu-puzzles-2021", "title": "GPU Puzzles (2021)", "summary": "Sasha Rush released GPU Puzzles, an interactive notebook teaching beginner GPU programming through coding exercises that map Python to CUDA kernels using NUMBA. The puzzles aim to build intuition for GPU architectures critical to machine learning, covering fundamentals to algorithms powering deep learning.", "body_md": "- by\n[Sasha Rush](http://rush-nlp.com)-[srush_nlp](https://twitter.com/srush_nlp)\n\nGPU architectures are critical to machine learning, and seem to be becoming even more important every day. However, you can be an expert in machine learning without ever touching GPU code. It is hard to gain intuition working through abstractions.\n\nThis notebook is an attempt to teach beginner GPU programming in a completely interactive fashion. Instead of providing text with concepts, it throws you right into coding and building GPU kernels. The exercises use NUMBA which directly maps Python code to CUDA kernels. It looks like Python but is basically identical to writing low-level CUDA code. In a few hours, I think you can go from basics to understanding the real algorithms that power 99% of deep learning today. If you do want to read the manual, it is here:\n\nI recommend doing these in Colab, as it is easy to get started. Be\nsure to make your own copy, turn on GPU mode in the settings (`Runtime / Change runtime type`\n\n, then set `Hardware accelerator`\n\nto `GPU`\n\n), and\nthen get to coding.\n\n(If you are into this style of puzzle, also check out my [Tensor\nPuzzles](https://github.com/srush/Tensor-Puzzles) for PyTorch.)\n\n```\n!pip install -qqq git+https://github.com/danoneata/chalk@srush-patch-1\n!wget -q https://github.com/srush/GPU-Puzzles/raw/main/robot.png https://github.com/srush/GPU-Puzzles/raw/main/lib.py\npython\nimport numba\nimport numpy as np\nimport warnings\nfrom lib import CudaProblem, Coord\nwarnings.filterwarnings(\n    action=\"ignore\", category=numba.NumbaPerformanceWarning, module=\"numba\"\n)\n```\n\nImplement a \"kernel\" (GPU function) that adds 10 to each position of vector `a`\n\nand stores it in vector `out`\n\n. You have 1 thread per position.\n\n**Warning** This code looks like Python but it is really CUDA! You cannot use\nstandard python tools like list comprehensions or ask for Numpy properties\nlike shape or size (if you need the size, it is given as an argument).\nThe puzzles only require doing simple operations, basically\n+, *, simple array indexing, for loops, and if statements.\nYou are allowed to use local variables.\nIf you get an\nerror it is probably because you did something fancy :).\n\n*Tip: Think of the function call as being run 1 time for each thread.\nThe only difference is that cuda.threadIdx.x changes each time.*\n\n``` php\ndef map_spec(a):\n    return a + 10\n\ndef map_test(cuda):\n    def call(out, a) -> None:\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 1 lines)\n\n    return call\n\nSIZE = 4\nout = np.zeros((SIZE,))\na = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Map\", map_test, [a], out, threadsperblock=Coord(SIZE, 1), spec=map_spec\n)\nproblem.show()\n# Map\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0.]\nSpec : [10 11 12 13]\n```\n\nImplement a kernel that adds together each position of `a`\n\nand `b`\n\nand stores it in `out`\n\n.\nYou have 1 thread per position.\n\n``` python\ndef zip_spec(a, b):\n    return a + b\n\ndef zip_test(cuda):\n    def call(out, a, b) -> None:\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 1 lines)\n\n    return call\n\nSIZE = 4\nout = np.zeros((SIZE,))\na = np.arange(SIZE)\nb = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Zip\", zip_test, [a, b], out, threadsperblock=Coord(SIZE, 1), spec=zip_spec\n)\nproblem.show()\n# Zip\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0.]\nSpec : [0 2 4 6]\n```\n\nImplement a kernel that adds 10 to each position of `a`\n\nand stores it in `out`\n\n.\nYou have more threads than positions.\n\n``` php\ndef map_guard_test(cuda):\n    def call(out, a, size) -> None:\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 2 lines)\n\n    return call\n\nSIZE = 4\nout = np.zeros((SIZE,))\na = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Guard\",\n    map_guard_test,\n    [a],\n    out,\n    [SIZE],\n    threadsperblock=Coord(8, 1),\n    spec=map_spec,\n)\nproblem.show()\n# Guard\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0.]\nSpec : [10 11 12 13]\n```\n\nImplement a kernel that adds 10 to each position of `a`\n\nand stores it in `out`\n\n.\nInput `a`\n\nis 2D and square. You have more threads than positions.\n\n``` php\ndef map_2D_test(cuda):\n    def call(out, a, size) -> None:\n        local_i = cuda.threadIdx.x\n        local_j = cuda.threadIdx.y\n        # FILL ME IN (roughly 2 lines)\n\n    return call\n\nSIZE = 2\nout = np.zeros((SIZE, SIZE))\na = np.arange(SIZE * SIZE).reshape((SIZE, SIZE))\nproblem = CudaProblem(\n    \"Map 2D\", map_2D_test, [a], out, [SIZE], threadsperblock=Coord(3, 3), spec=map_spec\n)\nproblem.show()\n# Map 2D\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0. 0.]\n [0. 0.]]\nSpec : [[10 11]\n [12 13]]\n```\n\nImplement a kernel that adds `a`\n\nand `b`\n\nand stores it in `out`\n\n.\nInputs `a`\n\nand `b`\n\nare vectors. You have more threads than positions.\n\n``` php\ndef broadcast_test(cuda):\n    def call(out, a, b, size) -> None:\n        local_i = cuda.threadIdx.x\n        local_j = cuda.threadIdx.y\n        # FILL ME IN (roughly 2 lines)\n\n    return call\n\nSIZE = 2\nout = np.zeros((SIZE, SIZE))\na = np.arange(SIZE).reshape(SIZE, 1)\nb = np.arange(SIZE).reshape(1, SIZE)\nproblem = CudaProblem(\n    \"Broadcast\",\n    broadcast_test,\n    [a, b],\n    out,\n    [SIZE],\n    threadsperblock=Coord(3, 3),\n    spec=zip_spec,\n)\nproblem.show()\n# Broadcast\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0. 0.]\n [0. 0.]]\nSpec : [[0 1]\n [1 2]]\n```\n\nImplement a kernel that adds 10 to each position of `a`\n\nand stores it in `out`\n\n.\nYou have fewer threads per block than the size of `a`\n\n.\n\n*Tip: A block is a group of threads. The number of threads per block is limited, but we can\nhave many different blocks. Variable cuda.blockIdx tells us what block we are in.*\n\n``` php\ndef map_block_test(cuda):\n    def call(out, a, size) -> None:\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        # FILL ME IN (roughly 2 lines)\n\n    return call\n\nSIZE = 9\nout = np.zeros((SIZE,))\na = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Blocks\",\n    map_block_test,\n    [a],\n    out,\n    [SIZE],\n    threadsperblock=Coord(4, 1),\n    blockspergrid=Coord(3, 1),\n    spec=map_spec,\n)\nproblem.show()\n# Blocks\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0. 0. 0. 0. 0. 0.]\nSpec : [10 11 12 13 14 15 16 17 18]\n```\n\nImplement the same kernel in 2D. You have fewer threads per block\nthan the size of `a`\n\nin both directions.\n\n``` php\ndef map_block2D_test(cuda):\n    def call(out, a, size) -> None:\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        # FILL ME IN (roughly 4 lines)\n\n    return call\n\nSIZE = 5\nout = np.zeros((SIZE, SIZE))\na = np.ones((SIZE, SIZE))\n\nproblem = CudaProblem(\n    \"Blocks 2D\",\n    map_block2D_test,\n    [a],\n    out,\n    [SIZE],\n    threadsperblock=Coord(3, 3),\n    blockspergrid=Coord(2, 2),\n    spec=map_spec,\n)\nproblem.show()\n# Blocks 2D\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0.]]\nSpec : [[11. 11. 11. 11. 11.]\n [11. 11. 11. 11. 11.]\n [11. 11. 11. 11. 11.]\n [11. 11. 11. 11. 11.]\n [11. 11. 11. 11. 11.]]\n```\n\nImplement a kernel that adds 10 to each position of `a`\n\nand stores it in `out`\n\n.\nYou have fewer threads per block than the size of `a`\n\n.\n\n**Warning**: Each block can only have a *constant* amount of shared\nmemory that threads in that block can read and write to. This needs\nto be a literal python constant not a variable. After writing to\nshared memory you need to call `cuda.syncthreads`\n\nto ensure that\nthreads do not cross.\n\n(This example does not really need shared memory or syncthreads, but it is a demo.)\n\n``` php\nTPB = 4\ndef shared_test(cuda):\n    def call(out, a, size) -> None:\n        shared = cuda.shared.array(TPB, numba.float32)\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n\n        if i < size:\n            shared[local_i] = a[i]\n            cuda.syncthreads()\n\n        # FILL ME IN (roughly 2 lines)\n\n    return call\n\nSIZE = 8\nout = np.zeros(SIZE)\na = np.ones(SIZE)\nproblem = CudaProblem(\n    \"Shared\",\n    shared_test,\n    [a],\n    out,\n    [SIZE],\n    threadsperblock=Coord(TPB, 1),\n    blockspergrid=Coord(2, 1),\n    spec=map_spec,\n)\nproblem.show()\n# Shared\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             1 |             0 |             0 |             1 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0. 0. 0. 0. 0.]\nSpec : [11. 11. 11. 11. 11. 11. 11. 11.]\n```\n\nImplement a kernel that sums together the last 3 position of `a`\n\nand stores it in `out`\n\n.\nYou have 1 thread per position. You only need 1 global read and 1 global write per thread.\n\n*Tip: Remember to be careful about syncing.*\n\n``` python\ndef pool_spec(a):\n    out = np.zeros(*a.shape)\n    for i in range(a.shape[0]):\n        out[i] = a[max(i - 2, 0) : i + 1].sum()\n    return out\n\nTPB = 8\ndef pool_test(cuda):\n    def call(out, a, size) -> None:\n        shared = cuda.shared.array(TPB, numba.float32)\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 8 lines)\n\n    return call\n\nSIZE = 8\nout = np.zeros(SIZE)\na = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Pooling\",\n    pool_test,\n    [a],\n    out,\n    [SIZE],\n    threadsperblock=Coord(TPB, 1),\n    blockspergrid=Coord(1, 1),\n    spec=pool_spec,\n)\nproblem.show()\n# Pooling\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0. 0. 0. 0. 0.]\nSpec : [ 0.  1.  3.  6.  9. 12. 15. 18.]\n```\n\nImplement a kernel that computes the dot-product of `a`\n\nand `b`\n\nand stores it in `out`\n\n.\nYou have 1 thread per position. You only need 2 global reads and 1 global write per thread.\n\n*Note: For this problem you don't need to worry about number of shared reads. We will\nhandle that challenge later.*\n\n``` python\ndef dot_spec(a, b):\n    return a @ b\n\nTPB = 8\ndef dot_test(cuda):\n    def call(out, a, b, size) -> None:\n        shared = cuda.shared.array(TPB, numba.float32)\n\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 9 lines)\n    return call\n\nSIZE = 8\nout = np.zeros(1)\na = np.arange(SIZE)\nb = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Dot\",\n    dot_test,\n    [a, b],\n    out,\n    [SIZE],\n    threadsperblock=Coord(SIZE, 1),\n    blockspergrid=Coord(1, 1),\n    spec=dot_spec,\n)\nproblem.show()\n# Dot\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0.]\nSpec : 140\n```\n\nImplement a kernel that computes a 1D convolution between `a`\n\nand `b`\n\nand stores it in `out`\n\n.\nYou need to handle the general case. You only need 2 global reads and 1 global write per thread.\n\n``` python\ndef conv_spec(a, b):\n    out = np.zeros(*a.shape)\n    len = b.shape[0]\n    for i in range(a.shape[0]):\n        out[i] = sum([a[i + j] * b[j] for j in range(len) if i + j < a.shape[0]])\n    return out\n\nMAX_CONV = 4\nTPB = 8\nTPB_MAX_CONV = TPB + MAX_CONV\ndef conv_test(cuda):\n    def call(out, a, b, a_size, b_size) -> None:\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n\n        # FILL ME IN (roughly 17 lines)\n\n    return call\n\n# Test 1\n\nSIZE = 6\nCONV = 3\nout = np.zeros(SIZE)\na = np.arange(SIZE)\nb = np.arange(CONV)\nproblem = CudaProblem(\n    \"1D Conv (Simple)\",\n    conv_test,\n    [a, b],\n    out,\n    [SIZE, CONV],\n    Coord(1, 1),\n    Coord(TPB, 1),\n    spec=conv_spec,\n)\nproblem.show()\n# 1D Conv (Simple)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0. 0. 0.]\nSpec : [ 5.  8. 11. 14.  5.  0.]\n```\n\nTest 2\n\n```\nout = np.zeros(15)\na = np.arange(15)\nb = np.arange(4)\nproblem = CudaProblem(\n    \"1D Conv (Full)\",\n    conv_test,\n    [a, b],\n    out,\n    [15, 4],\n    Coord(2, 1),\n    Coord(TPB, 1),\n    spec=conv_spec,\n)\nproblem.show()\n# 1D Conv (Full)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\nSpec : [14. 20. 26. 32. 38. 44. 50. 56. 62. 68. 74. 80. 41. 14.  0.]\n```\n\nImplement a kernel that computes a sum over `a`\n\nand stores it in `out`\n\n.\nIf the size of `a`\n\nis greater than the block size, only store the sum of\neach block.\n\nWe will do this using the [parallel prefix sum](https://en.wikipedia.org/wiki/Prefix_sum) algorithm in shared memory.\nThat is, each step of the algorithm should sum together half the remaining numbers.\nFollow this diagram:\n\n``` python\nTPB = 8\ndef sum_spec(a):\n    out = np.zeros((a.shape[0] + TPB - 1) // TPB)\n    for j, i in enumerate(range(0, a.shape[-1], TPB)):\n        out[j] = a[i : i + TPB].sum()\n    return out\n\ndef sum_test(cuda):\n    def call(out, a, size: int) -> None:\n        cache = cuda.shared.array(TPB, numba.float32)\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n        # FILL ME IN (roughly 12 lines)\n\n    return call\n\n# Test 1\n\nSIZE = 8\nout = np.zeros(1)\ninp = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Sum (Simple)\",\n    sum_test,\n    [inp],\n    out,\n    [SIZE],\n    Coord(1, 1),\n    Coord(TPB, 1),\n    spec=sum_spec,\n)\nproblem.show()\n# Sum (Simple)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0.]\nSpec : [28.]\n```\n\nTest 2\n\n```\nSIZE = 15\nout = np.zeros(2)\ninp = np.arange(SIZE)\nproblem = CudaProblem(\n    \"Sum (Full)\",\n    sum_test,\n    [inp],\n    out,\n    [SIZE],\n    Coord(2, 1),\n    Coord(TPB, 1),\n    spec=sum_spec,\n)\nproblem.show()\n# Sum (Full)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [0. 0.]\nSpec : [28. 77.]\n```\n\nImplement a kernel that computes a sum over each column of `a`\n\nand stores it in `out`\n\n.\n\n``` python\nTPB = 8\ndef sum_spec(a):\n    out = np.zeros((a.shape[0], (a.shape[1] + TPB - 1) // TPB))\n    for j, i in enumerate(range(0, a.shape[-1], TPB)):\n        out[..., j] = a[..., i : i + TPB].sum(-1)\n    return out\n\ndef axis_sum_test(cuda):\n    def call(out, a, size: int) -> None:\n        cache = cuda.shared.array(TPB, numba.float32)\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        local_i = cuda.threadIdx.x\n        batch = cuda.blockIdx.y\n        # FILL ME IN (roughly 12 lines)\n\n    return call\n\nBATCH = 4\nSIZE = 6\nout = np.zeros((BATCH, 1))\ninp = np.arange(BATCH * SIZE).reshape((BATCH, SIZE))\nproblem = CudaProblem(\n    \"Axis Sum\",\n    axis_sum_test,\n    [inp],\n    out,\n    [SIZE],\n    Coord(1, BATCH),\n    Coord(TPB, 1),\n    spec=sum_spec,\n)\nproblem.show()\n# Axis Sum\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0.]\n [0.]\n [0.]\n [0.]]\nSpec : [[ 15.]\n [ 51.]\n [ 87.]\n [123.]]\n```\n\nImplement a kernel that multiplies square matrices `a`\n\nand `b`\n\nand\nstores the result in `out`\n\n.\n\n*Tip: The most efficient algorithm here will copy a block into\nshared memory before computing each of the individual row-column\ndot products. This is easy to do if the matrix fits in shared\nmemory. Do that case first. Then update your code to compute\na partial dot-product and iteratively move the part you\ncopied into shared memory.* You should be able to do the hard case\nin 6 global reads.\n\n``` python\ndef matmul_spec(a, b):\n    return a @ b\n\nTPB = 3\ndef mm_oneblock_test(cuda):\n    def call(out, a, b, size: int) -> None:\n        a_shared = cuda.shared.array((TPB, TPB), numba.float32)\n        b_shared = cuda.shared.array((TPB, TPB), numba.float32)\n\n        i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x\n        j = cuda.blockIdx.y * cuda.blockDim.y + cuda.threadIdx.y\n        local_i = cuda.threadIdx.x\n        local_j = cuda.threadIdx.y\n        # FILL ME IN (roughly 14 lines)\n\n    return call\n\n# Test 1\n\nSIZE = 2\nout = np.zeros((SIZE, SIZE))\ninp1 = np.arange(SIZE * SIZE).reshape((SIZE, SIZE))\ninp2 = np.arange(SIZE * SIZE).reshape((SIZE, SIZE)).T\n\nproblem = CudaProblem(\n    \"Matmul (Simple)\",\n    mm_oneblock_test,\n    [inp1, inp2],\n    out,\n    [SIZE],\n    Coord(1, 1),\n    Coord(TPB, TPB),\n    spec=matmul_spec,\n)\nproblem.show(sparse=True)\n# Matmul (Simple)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0. 0.]\n [0. 0.]]\nSpec : [[ 1  3]\n [ 3 13]]\n```\n\nTest 2\n\n```\nSIZE = 8\nout = np.zeros((SIZE, SIZE))\ninp1 = np.arange(SIZE * SIZE).reshape((SIZE, SIZE))\ninp2 = np.arange(SIZE * SIZE).reshape((SIZE, SIZE)).T\n\nproblem = CudaProblem(\n    \"Matmul (Full)\",\n    mm_oneblock_test,\n    [inp1, inp2],\n    out,\n    [SIZE],\n    Coord(3, 3),\n    Coord(TPB, TPB),\n    spec=matmul_spec,\n)\nproblem.show(sparse=True)\n# Matmul (Full)\n \n   Score (Max Per Thread):\n   |  Global Reads | Global Writes |  Shared Reads | Shared Writes |\n   |             0 |             0 |             0 |             0 |\nproblem.check()\nFailed Tests.\nYours: [[0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]\n [0. 0. 0. 0. 0. 0. 0. 0.]]\nSpec : [[  140   364   588   812  1036  1260  1484  1708]\n [  364  1100  1836  2572  3308  4044  4780  5516]\n [  588  1836  3084  4332  5580  6828  8076  9324]\n [  812  2572  4332  6092  7852  9612 11372 13132]\n [ 1036  3308  5580  7852 10124 12396 14668 16940]\n [ 1260  4044  6828  9612 12396 15180 17964 20748]\n [ 1484  4780  8076 11372 14668 17964 21260 24556]\n [ 1708  5516  9324 13132 16940 20748 24556 28364]]\n```\n\n", "url": "https://wpnews.pro/news/gpu-puzzles-2021", "canonical_source": "https://github.com/srush/gpu-puzzles", "published_at": "2026-06-19 23:13:01+00:00", "updated_at": "2026-06-19 23:37:39.341859+00:00", "lang": "en", "topics": ["machine-learning", "developer-tools"], "entities": ["Sasha Rush", "NUMBA", "CUDA", "PyTorch", "Google Colab"], "alternates": {"html": "https://wpnews.pro/news/gpu-puzzles-2021", "markdown": "https://wpnews.pro/news/gpu-puzzles-2021.md", "text": "https://wpnews.pro/news/gpu-puzzles-2021.txt", "jsonld": "https://wpnews.pro/news/gpu-puzzles-2021.jsonld"}}