[GH-PAGES] Updated website
This commit is contained in:
@@ -231,10 +231,10 @@ We can now run the decorated function above. Pass `print_data=True` to see the p
|
||||
|
||||
vector-add-performance:
|
||||
size Triton Torch
|
||||
0 4096.0 9.600000 9.600000
|
||||
0 4096.0 9.540372 9.600000
|
||||
1 8192.0 19.200000 19.200000
|
||||
2 16384.0 38.400001 38.400001
|
||||
3 32768.0 63.999998 63.999998
|
||||
3 32768.0 76.800002 76.800002
|
||||
4 65536.0 127.999995 127.999995
|
||||
5 131072.0 219.428568 219.428568
|
||||
6 262144.0 341.333321 384.000001
|
||||
@@ -254,7 +254,7 @@ We can now run the decorated function above. Pass `print_data=True` to see the p
|
||||
|
||||
.. rst-class:: sphx-glr-timing
|
||||
|
||||
**Total running time of the script:** ( 0 minutes 10.981 seconds)
|
||||
**Total running time of the script:** ( 0 minutes 10.987 seconds)
|
||||
|
||||
|
||||
.. _sphx_glr_download_getting-started_tutorials_01-vector-add.py:
|
||||
|
@@ -306,11 +306,11 @@ We will then compare its performance against (1) :code:`torch.softmax` and (2) t
|
||||
3 640.0 682.666684 640.000002 160.000000
|
||||
4 768.0 702.171410 664.216187 163.839992
|
||||
.. ... ... ... ...
|
||||
93 12160.0 812.359066 405.755985 198.936606
|
||||
94 12288.0 812.429770 415.661740 199.197579
|
||||
95 12416.0 810.840807 412.149375 198.854847
|
||||
96 12544.0 810.925276 412.971190 199.111113
|
||||
97 12672.0 811.007961 412.097543 199.167004
|
||||
93 12160.0 812.359066 405.755985 199.038365
|
||||
94 12288.0 812.429770 415.661740 199.298541
|
||||
95 12416.0 810.840807 412.149375 198.954424
|
||||
96 12544.0 809.290334 412.546756 199.209928
|
||||
97 12672.0 809.389265 412.097543 199.167004
|
||||
|
||||
[98 rows x 4 columns]
|
||||
|
||||
@@ -329,7 +329,7 @@ In the above plot, we can see that:
|
||||
|
||||
.. rst-class:: sphx-glr-timing
|
||||
|
||||
**Total running time of the script:** ( 1 minutes 12.654 seconds)
|
||||
**Total running time of the script:** ( 1 minutes 12.618 seconds)
|
||||
|
||||
|
||||
.. _sphx_glr_download_getting-started_tutorials_02-fused-softmax.py:
|
||||
|
@@ -59,14 +59,14 @@ algorithm to multiply a (MxK) by a (KxN) matrix:
|
||||
|
||||
where each iteration of the doubly-nested for-loop corresponds to a Triton program instance.
|
||||
|
||||
.. GENERATED FROM PYTHON SOURCE LINES 44-119
|
||||
.. GENERATED FROM PYTHON SOURCE LINES 44-129
|
||||
|
||||
Compute Kernel
|
||||
----------------
|
||||
|
||||
The above algorithm is, actually, fairly straightforward to implement in Triton.
|
||||
The main difficulty comes from the computation of the memory locations at which blocks
|
||||
of :code:`A` and :code:`B` must be read in the inner loop. For that, we need
|
||||
of :code:`A` and :code:`B` must be read in the inner loop. For that, we need
|
||||
multi-dimensional pointer arithmetics.
|
||||
|
||||
Pointer Arithmetics
|
||||
@@ -108,7 +108,7 @@ L2 Cache Optimizations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
As mentioned above, each program instance computes a :code:`[BLOCK_SIZE_M, BLOCK_SIZE_N]`
|
||||
block of :code:`C`.
|
||||
block of :code:`C`.
|
||||
It is important to remember that the order in which these blocks are computed does
|
||||
matter, since it affects the L2 cache hit rate of our program. and unfortunately, a
|
||||
a simple row-major ordering
|
||||
@@ -137,26 +137,14 @@ switching to the next column:
|
||||
pid_m = group_id * GROUP_M + (pid % group_size);
|
||||
pid_n = (pid % width) // (group_size);
|
||||
|
||||
.. GENERATED FROM PYTHON SOURCE LINES 119-130
|
||||
|
||||
.. code-block:: default
|
||||
|
||||
|
||||
# For example, in the following matmul where each matrix is 9 blocks by 9 blocks,
|
||||
# we can see that if we compute the output in row-major ordering, we need to load 90
|
||||
# blocks into SRAM to compute the first 9 output blocks, but if we do it in grouped
|
||||
# ordering, we only need to load 54 blocks.
|
||||
# .. image:: grouped_vs_row_major_ordering.png
|
||||
#
|
||||
# In practice, this can improve the performance of our matrix multiplication kernel by
|
||||
# more than 10\% on some hardware architecture (e.g., 220 to 245 TFLOPS on A100).
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
For example, in the following matmul where each matrix is 9 blocks by 9 blocks,
|
||||
we can see that if we compute the output in row-major ordering, we need to load 90
|
||||
blocks into SRAM to compute the first 9 output blocks, but if we do it in grouped
|
||||
ordering, we only need to load 54 blocks.
|
||||
.. image:: grouped_vs_row_major_ordering.png
|
||||
|
||||
In practice, this can improve the performance of our matrix multiplication kernel by
|
||||
more than 10\% on some hardware architecture (e.g., 220 to 245 TFLOPS on A100).
|
||||
|
||||
|
||||
.. GENERATED FROM PYTHON SOURCE LINES 131-134
|
||||
@@ -374,8 +362,8 @@ We can test our custom matrix multiplication operation against a native torch im
|
||||
b = torch.randn((512, 512), device='cuda', dtype=torch.float16)
|
||||
triton_output = matmul(a, b, activation=None)
|
||||
torch_output = torch.matmul(a, b)
|
||||
print(f"{triton_output=}")
|
||||
print(f"{torch_output=}")
|
||||
print(f"triton_output={triton_output}")
|
||||
print(f"torch_output={torch_output}")
|
||||
if triton.testing.allclose(triton_output, torch_output):
|
||||
print("✅ Triton and Torch match")
|
||||
else:
|
||||
@@ -484,36 +472,36 @@ We can now compare the performance of our kernel against that of cuBLAS. Here we
|
||||
M cuBLAS ... Triton Triton (+ LeakyReLU)
|
||||
0 128.0 0.455111 ... 0.512000 0.512000
|
||||
1 256.0 2.730667 ... 3.276800 2.978909
|
||||
2 384.0 7.372800 ... 8.507077 8.507077
|
||||
3 512.0 14.563555 ... 16.384000 15.420235
|
||||
2 384.0 7.372800 ... 7.899428 7.899428
|
||||
3 512.0 14.563555 ... 16.384000 16.384000
|
||||
4 640.0 22.260869 ... 24.380953 24.380953
|
||||
5 768.0 32.768000 ... 34.028308 34.028308
|
||||
6 896.0 39.025776 ... 40.140799 35.123201
|
||||
6 896.0 39.025776 ... 40.140799 35.150663
|
||||
7 1024.0 49.932191 ... 52.428801 52.428801
|
||||
8 1152.0 44.566925 ... 46.656000 45.938215
|
||||
8 1152.0 44.566925 ... 46.656000 46.656000
|
||||
9 1280.0 51.200001 ... 56.109587 56.109587
|
||||
10 1408.0 64.138541 ... 64.902096 64.138541
|
||||
11 1536.0 80.430545 ... 76.106321 75.296679
|
||||
12 1664.0 63.372618 ... 62.492442 62.061463
|
||||
12 1664.0 62.929456 ... 62.061463 62.061463
|
||||
13 1792.0 72.983276 ... 69.810085 69.379162
|
||||
14 1920.0 68.435645 ... 67.764707 69.818184
|
||||
15 2048.0 73.584279 ... 75.234154 74.898285
|
||||
16 2176.0 83.500614 ... 81.143743 78.916269
|
||||
17 2304.0 68.056616 ... 73.501144 73.051599
|
||||
18 2432.0 71.125224 ... 80.269900 80.963875
|
||||
19 2560.0 77.833728 ... 76.920185 76.382283
|
||||
20 2688.0 80.027544 ... 79.524227 82.284288
|
||||
21 2816.0 83.392363 ... 79.587973 76.785575
|
||||
22 2944.0 82.509987 ... 79.230573 79.993627
|
||||
23 3072.0 81.589488 ... 83.761985 82.301023
|
||||
24 3200.0 84.768213 ... 89.385477 89.012517
|
||||
25 3328.0 80.617354 ... 80.707733 86.217120
|
||||
26 3456.0 81.518272 ... 85.223646 82.183044
|
||||
27 3584.0 84.033077 ... 93.564405 95.047985
|
||||
28 3712.0 86.267139 ... 88.015279 89.194055
|
||||
29 3840.0 84.874902 ... 88.402879 87.217666
|
||||
30 3968.0 92.442373 ... 87.850207 87.347124
|
||||
31 4096.0 93.531519 ... 85.926841 85.871865
|
||||
14 1920.0 69.120002 ... 70.892307 69.120002
|
||||
15 2048.0 73.584279 ... 74.898285 74.565406
|
||||
16 2176.0 83.155572 ... 80.817862 79.855747
|
||||
17 2304.0 68.446623 ... 72.828879 73.275679
|
||||
18 2432.0 71.305746 ... 82.388456 81.908060
|
||||
19 2560.0 78.019048 ... 77.283019 75.676673
|
||||
20 2688.0 83.552988 ... 83.552988 83.922689
|
||||
21 2816.0 81.827785 ... 77.330158 79.154642
|
||||
22 2944.0 81.166173 ... 77.747321 79.483304
|
||||
23 3072.0 79.863336 ... 82.661468 82.420822
|
||||
24 3200.0 83.660130 ... 90.395483 85.906037
|
||||
25 3328.0 83.226931 ... 87.368079 83.613586
|
||||
26 3456.0 80.220468 ... 81.600781 83.459178
|
||||
27 3584.0 87.466332 ... 92.887804 84.983685
|
||||
28 3712.0 84.159518 ... 83.178475 83.666116
|
||||
29 3840.0 83.591840 ... 84.228485 85.663823
|
||||
30 3968.0 91.885495 ... 84.680037 84.154440
|
||||
31 4096.0 89.181212 ... 90.260743 90.200084
|
||||
|
||||
[32 rows x 5 columns]
|
||||
|
||||
@@ -523,7 +511,7 @@ We can now compare the performance of our kernel against that of cuBLAS. Here we
|
||||
|
||||
.. rst-class:: sphx-glr-timing
|
||||
|
||||
**Total running time of the script:** ( 2 minutes 30.126 seconds)
|
||||
**Total running time of the script:** ( 2 minutes 29.710 seconds)
|
||||
|
||||
|
||||
.. _sphx_glr_download_getting-started_tutorials_03-matrix-multiplication.py:
|
||||
|
@@ -5,12 +5,12 @@
|
||||
|
||||
Computation times
|
||||
=================
|
||||
**03:53.760** total execution time for **getting-started_tutorials** files:
|
||||
**03:53.315** total execution time for **getting-started_tutorials** files:
|
||||
|
||||
+---------------------------------------------------------------------------------------------------------+-----------+--------+
|
||||
| :ref:`sphx_glr_getting-started_tutorials_03-matrix-multiplication.py` (``03-matrix-multiplication.py``) | 02:30.126 | 0.0 MB |
|
||||
| :ref:`sphx_glr_getting-started_tutorials_03-matrix-multiplication.py` (``03-matrix-multiplication.py``) | 02:29.710 | 0.0 MB |
|
||||
+---------------------------------------------------------------------------------------------------------+-----------+--------+
|
||||
| :ref:`sphx_glr_getting-started_tutorials_02-fused-softmax.py` (``02-fused-softmax.py``) | 01:12.654 | 0.0 MB |
|
||||
| :ref:`sphx_glr_getting-started_tutorials_02-fused-softmax.py` (``02-fused-softmax.py``) | 01:12.618 | 0.0 MB |
|
||||
+---------------------------------------------------------------------------------------------------------+-----------+--------+
|
||||
| :ref:`sphx_glr_getting-started_tutorials_01-vector-add.py` (``01-vector-add.py``) | 00:10.981 | 0.0 MB |
|
||||
| :ref:`sphx_glr_getting-started_tutorials_01-vector-add.py` (``01-vector-add.py``) | 00:10.987 | 0.0 MB |
|
||||
+---------------------------------------------------------------------------------------------------------+-----------+--------+
|
||||
|
Reference in New Issue
Block a user