:orphan:
Helion Examples
==============
This directory contains examples demonstrating how to use Helion for high-performance tensor operations.
The examples are organized into the following categories:
Basic Operations
~~~~~~~~~~~~~~~
- ``add.py``: Element-wise addition with broadcasting support
- ``exp.py``: Element-wise exponential function
- ``sum.py``: Sum reduction along the last dimension
- ``long_sum.py``: Efficient sum reduction along a long dimension
- ``softmax.py``: Different implementations of the softmax function
Matrix Multiplication Operations
~~~~~~~~~~~~~~~~
- ``matmul.py``: Basic matrix multiplication
- ``bmm.py``: Batch matrix multiplication
- ``matmul_split_k.py``: Matrix multiplication using split-K algorithm for better parallelism
- ``matmul_layernorm.py``: Fused matrix multiplication and layer normalization
- ``fp8_gemm.py``: Matrix multiplication using FP8 precision
Attention Operations
~~~~~~~~~~~~~~~~~~~
- ``attention.py``: Scaled dot-product attention mechanism
- ``fp8_attention.py``: Attention mechanism using FP8 precision
Normalization
~~~~~~~~~~~~
- ``rms_norm.py``: Root Mean Square (RMS) normalization
Sparse and Jagged Tensors
~~~~~~~~~~~~~~~~~~~~~~~~~
- ``jagged_dense_add.py``: Addition between a jagged tensor and a dense tensor
- ``jagged_mean.py``: Computing the mean of each row in a jagged tensor
- ``segment_reduction.py``: Segmented reduction operation
- ``moe_matmul_ogs.py``: Mixture-of-Experts matrix multiplication using Outer-Gather-Scatter
Other Operations
~~~~~~~~~~~~~~~
- ``concatenate.py``: Tensor concatenation along a dimension
- ``cross_entropy.py``: Cross entropy loss function
- ``embedding.py``: Embedding lookup operation
- ``all_gather_matmul.py``: All-gather operation followed by matrix multiplication
.. toctree::
:maxdepth: 2
:caption: Contents
:hidden:
add
all_gather_matmul
attention
bmm
concatenate
cross_entropy
embedding
exp
fp8_attention
fp8_gemm
jagged_dense_add
jagged_mean
long_sum
matmul
matmul_layernorm
matmul_split_k
moe_matmul_ogs
rms_norm
segment_reduction
softmax
sum
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_exp_thumb.png
:alt:
:ref:`sphx_glr_examples_exp.py`
.. raw:: html
Exponential Function Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_add_thumb.png
:alt:
:ref:`sphx_glr_examples_add.py`
.. raw:: html
Element-wise Addition Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_concatenate_thumb.png
:alt:
:ref:`sphx_glr_examples_concatenate.py`
.. raw:: html
Tensor Concatenation Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_sum_thumb.png
:alt:
:ref:`sphx_glr_examples_sum.py`
.. raw:: html
Sum Reduction Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_embedding_thumb.png
:alt:
:ref:`sphx_glr_examples_embedding.py`
.. raw:: html
Embedding Lookup Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_bmm_thumb.png
:alt:
:ref:`sphx_glr_examples_bmm.py`
.. raw:: html
Batch Matrix Multiplication Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_layer_norm_thumb.png
:alt:
:ref:`sphx_glr_examples_layer_norm.py`
.. raw:: html
Helion Layer Normalization Forward Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_cross_entropy_thumb.png
:alt:
:ref:`sphx_glr_examples_cross_entropy.py`
.. raw:: html
Cross Entropy Loss Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_rms_norm_thumb.png
:alt:
:ref:`sphx_glr_examples_rms_norm.py`
.. raw:: html
Root Mean Square Normalization Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_softmax_thumb.png
:alt:
:ref:`sphx_glr_examples_softmax.py`
.. raw:: html
Helion Softmax Kernel Examples
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_fp8_gemm_thumb.png
:alt:
:ref:`sphx_glr_examples_fp8_gemm.py`
.. raw:: html
FP8 General Matrix Multiplication (GEMM) with Helion
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_matmul_layernorm_thumb.png
:alt:
:ref:`sphx_glr_examples_matmul_layernorm.py`
.. raw:: html
Matrix Multiplication with Layer Normalization Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_long_sum_thumb.png
:alt:
:ref:`sphx_glr_examples_long_sum.py`
.. raw:: html
Long Dimension Sum Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_matmul_split_k_thumb.png
:alt:
:ref:`sphx_glr_examples_matmul_split_k.py`
.. raw:: html
Matrix Multiplication with Split-K using Helion
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_attention_thumb.png
:alt:
:ref:`sphx_glr_examples_attention.py`
.. raw:: html
Attention Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_matmul_thumb.png
:alt:
:ref:`sphx_glr_examples_matmul.py`
.. raw:: html
Helion Matmul Kernel Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_jagged_dense_add_thumb.png
:alt:
:ref:`sphx_glr_examples_jagged_dense_add.py`
.. raw:: html
Jagged Dense Addition Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_jagged_mean_thumb.png
:alt:
:ref:`sphx_glr_examples_jagged_mean.py`
.. raw:: html
Jagged Mean Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_moe_matmul_ogs_thumb.png
:alt:
:ref:`sphx_glr_examples_moe_matmul_ogs.py`
.. raw:: html
Mixture-of-Experts (MoE) Matmul with Outer-Gather-Scatter (OGS)
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_segment_reduction_thumb.png
:alt:
:ref:`sphx_glr_examples_segment_reduction.py`
.. raw:: html
Segmented Reduction Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_all_gather_matmul_thumb.png
:alt:
:ref:`sphx_glr_examples_all_gather_matmul.py`
.. raw:: html
All-Gather Matrix Multiplication Example
.. raw:: html
.. only:: html
.. image:: /examples/images/thumb/sphx_glr_fp8_attention_thumb.png
:alt:
:ref:`sphx_glr_examples_fp8_attention.py`
.. raw:: html
FP8 Attention Example
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/examples/exp
/examples/add
/examples/concatenate
/examples/sum
/examples/embedding
/examples/bmm
/examples/layer_norm
/examples/cross_entropy
/examples/rms_norm
/examples/softmax
/examples/fp8_gemm
/examples/matmul_layernorm
/examples/long_sum
/examples/matmul_split_k
/examples/attention
/examples/matmul
/examples/jagged_dense_add
/examples/jagged_mean
/examples/moe_matmul_ogs
/examples/segment_reduction
/examples/all_gather_matmul
/examples/fp8_attention
.. only:: html
.. container:: sphx-glr-footer sphx-glr-footer-gallery
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download all examples in Python source code: examples_python.zip `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download all examples in Jupyter notebooks: examples_jupyter.zip `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery