From 9fddd7381d2cbaf70201b5b1e6cf83f8d74150a3 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Wed, 23 Oct 2024 19:49:51 +0000 Subject: [PATCH 01/19] Initial Dependency Setup. --- docs/Makefile | 20 ++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ docs/source/conf.py | 28 ++++++++++++++++++++++++++++ docs/source/index.rst | 17 +++++++++++++++++ src/liger_kernel/README.rst | 3 +++ 5 files changed, 103 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 src/liger_kernel/README.rst diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..d0c3cbf10 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..747ffb7b3 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 000000000..d8c0a8123 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,28 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Liger-Kernel' +copyright = '2024, Parag Ekbote' +author = 'Parag Ekbote' +release = '0.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_static_path = ['_static'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 000000000..d7635deea --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,17 @@ +.. Liger-Kernel documentation master file, created by + sphinx-quickstart on Wed Oct 23 19:47:42 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Liger-Kernel documentation +========================== + +Add your content using ``reStructuredText`` syntax. See the +`reStructuredText `_ +documentation for details. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + diff --git a/src/liger_kernel/README.rst b/src/liger_kernel/README.rst new file mode 100644 index 000000000..ed5fedc03 --- /dev/null +++ b/src/liger_kernel/README.rst @@ -0,0 +1,3 @@ +Liger + +Liger is a Python Library used for finetuning. \ No newline at end of file From ae529cc280f7b46b16314ac68097d2245e5b59af Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Thu, 24 Oct 2024 06:45:00 +0000 Subject: [PATCH 02/19] Added Extensions. --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index d8c0a8123..6b62b6e72 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = [] +extensions = ['sphinx.ext.duration',] templates_path = ['_templates'] exclude_patterns = [] From 9c2d88b6736c4c522286d34d9153d225aa83b3b2 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Sun, 27 Oct 2024 19:12:53 +0000 Subject: [PATCH 03/19] Updated configurations and created initial files for documentation. --- .github/workflows/sphinx.yml | 24 +++++ .../.doctrees/source/_templates/api.doctree | Bin 0 -> 6495 bytes .../source/_templates/modules.doctree | Bin 0 -> 6800 bytes .../.doctrees/source/_templates/todo.doctree | Bin 0 -> 2163 bytes docs/_build/.doctrees/source/conf.py | 89 ++++++++++++++++ docs/_build/.doctrees/source/index.doctree | Bin 0 -> 4447 bytes docs/requirements.txt | 1 + docs/source/api.rst | 80 +++++++++++++++ docs/source/conf.py | 28 ----- docs/source/index.rst | 24 ++--- docs/source/modules.rst | 97 ++++++++++++++++++ docs/source/todo.rst | 0 12 files changed, 303 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/sphinx.yml create mode 100644 docs/_build/.doctrees/source/_templates/api.doctree create mode 100644 docs/_build/.doctrees/source/_templates/modules.doctree create mode 100644 docs/_build/.doctrees/source/_templates/todo.doctree create mode 100644 docs/_build/.doctrees/source/conf.py create mode 100644 docs/_build/.doctrees/source/index.doctree create mode 100644 docs/requirements.txt create mode 100644 docs/source/api.rst delete mode 100644 docs/source/conf.py create mode 100644 docs/source/modules.rst create mode 100644 docs/source/todo.rst diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml new file mode 100644 index 000000000..1e63e921b --- /dev/null +++ b/.github/workflows/sphinx.yml @@ -0,0 +1,24 @@ +name: "Sphinx: Render docs" + +on: push + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Build HTML + uses: ammaraskar/sphinx-action@master + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: html-docs + path: docs/build/html/ + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: github.ref == 'refs/heads/main' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/build/html \ No newline at end of file diff --git a/docs/_build/.doctrees/source/_templates/api.doctree b/docs/_build/.doctrees/source/_templates/api.doctree new file mode 100644 index 0000000000000000000000000000000000000000..a3e3f76c7ef4f11eef07a2569faeb5388816b277 GIT binary patch literal 6495 zcmc&&ZEGCY6_zEhq?J}H$+6wWw$cr45}SA>la{{tL#c7%;7V3YV%kq(xI1%q@9fUb zOz+&Wr9w*$3C+U&mMMWipg*Ay2=pfu0)hU7LLksT&?MCDbMCya?XlG_73^r{+_&?b zw|ma{L+ej>pImThh$MFM)M~Pl_0y~~^UnL(TR~{t4OD^lSWcQ;WmNrlH z0%q94^&H9l0gtFK65y>eHU<^W-odFulf< zlI|c@KuM^UTqhy~E4Ig?2t>TMd^SzrR-HI3KL*U6NIs-Fv0hPZL_>+#6c%8~s$spKP8V0f z!YWv3L$$#)3}WA@s3_H*SOD(8R+3lMmyJE?AaPNjdn|BB9g34~D(jBx+g|MOp-Tv% zhSe!Ma(JjjvcCxZu+SJ3v^nyEK{C_J!gUwsvw4Z>%?xk+*_Kal*0Jq$%OH4MHuI6 z!nnY|kx@`84`{|V9C=gNQ09!fc~*mE;IIa9^o%HO#SwQ75c`wSZ(w=zP408aJomTU=~dW&gkD1V=gFXaS%LCe4az3epP${Y z!>SJT(xC>3*tP*;x8jZ!g!AMA;P~{Zg@qGg9G@y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)d)idZasM$TEY-5vP2j$;MAvs*_=dD3L+Fj&2?@F_fP!U7q+zk6BXdW)x!SIk zniM9AG1{>BSfni#*-w-&QK5OiIsQ9*eEc^$8HM2Dsd!twFa9b%5+90B#V6u(@o({! z_;UOWYITtwFVmw-kNfnvM~?wLEPDK&9*6Wu>G5Yg64j#lQ39W@o}m|GQ}Qo>G)V#4HB`~C~f4H;SD%R z?ZES3P~d>0a_MeX{vKB4S^5x8kK8)84`jn**f~vz?DTqk6eEG1mlg+lo@k|1e+wPi z2+3Mesa99tr2hcuAhFFO^1zM^f=(=OTK4k$T~m|truY5Xa|F8MKDE9!zJ-5q>1^T9 zalxK>)&QHtK^5TbQv;Wk?kRsc@c*Z)Ap~f504;91!L@J}y=rzuY|7X>c=VX3xS5TA zR+6I>diA22Crk6}uv#eYB=h8aSn=Q7dANUn{|(wwu^#DeyK+~g(Z8!lKasjt+r_Dw jn}N2*)uLE$SgYB831EX9(O$LU(7~RafpmLK2EG3Rhd0Rn literal 0 HcmV?d00001 diff --git a/docs/_build/.doctrees/source/_templates/todo.doctree b/docs/_build/.doctrees/source/_templates/todo.doctree new file mode 100644 index 0000000000000000000000000000000000000000..106721eeae89586f4e8aa553dd22019b4da3851f GIT binary patch literal 2163 zcmZ8jO>Y}F5RK!=wrorONE{SseC*f3QV%@@MQ=U2^`VE}0)irEcL{UJEk9!U5THF2 zhymWh{@*_CO0q2j29}S*nc>WvNBuqeuQ_ zKlxMsK8+o}^ENs`IlX{|Xq1+YO#YD5ArHZ+MGQDwYYB%dk+xbBg5O_>p;ft zak1dy)=|~l?5zX5pWj(`>pL#U&wo=jxvOh(hV&eX`T1ZrXMx&Ib3~m7EA7nrkkgys zxbZ-hHLP>CcI1bwM!^QI^Yx2#xV9mQWsGS*@Vcawo1HWj(cxZ!t&+J($7@6@L-{5h zcnU$88ihJ5g$hdhS>>z=WMocze{vmh)lKR4Yz$otI5`R`=;C5rlOe~0b!8#T9RhDV zERLMD0f|$kmO1Urb2=IlVTg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}kAEH965pdp|U z2afgK4=YwON1)+}RHO3JuX8~uMuf^u%vBlGq(j{H9^nqIF;p?1u}+!EUT${wPL)KN0DW>xRbsx^lK~ zwmjj(6W^V%9JFkeF0r5(-QyQpMQr1czXVDMfgVUmT()T9@} z^0XOPa9;gEJ;5L>niWdhRI+o1aNh7ePGr06_&%EnM9~uKOrzBC9m+;-g5!2Ch|Up3 zXkeb5LefRbG8V2B{1Z81mZBjj3M~|fv*W{G9U6h(Z!K@8Olzf6PI4*%Sik^x%P`OE zRgqt?(ur0|e}83X#RUJ4->r;ZInaFi*7C;6mwrE70KhXG@sV+K+mR%nI7|WvH^nG- z12yem!<4KvO~C~W6Ih-F!Z`8km`=vHBf=qQg9g6tcZstqy%PBw0$AIjZd#-*9ud_j z5EyWDPGm5+7bUS8Lh7$Xg<+1W6eA|I_SvjZhNX*NMu=oKJr_n)c->2>Fk~ddMQSfM znmR$vZR0Wql@W^$Mt5qpv?ag0;TI0UARA~8i3!#y^1TI`YL~~?eLoZ%V3SXPLMf)g zmcQSB;CBmFq;2~Mm)Q=I5rOZaF8oiLE(@_46m!c}9*45h-wB%00cfU{;mw2c3zIb~ z4&Q$F3F5h{$JvVcAh|OCPGcUGO9Ea&bOXWcIGzDE7>211wcE91gc72G=QsU*0CJkP zmDye(t%mzczh6z9DHjtC2IX-WR{{6iW{P)R`rM(U4FdIATvy9fs*Kcq<$lI7_GUwf*109NI=BD71t#`5zL?Zaw!zm!kf@^^qbkjiP{??MTdO|@AYvXni#;@@Df_x(gtKSFwTmB9IoX?%_ z2C1DFa5KC#zP;q1zi|AG@cSD)F6P`gzq6RRXlo}E$bWDK_A5y!&_=IvdQnp8;oXN! zPe)3&V2G->SA?y0cgbS6IW>NCYsr3m{$rf-cUEoHJD3wd9~lN8U`_ -documentation for details. - +Welcome to Liger-Kernel Documentation +=================================== .. toctree:: :maxdepth: 2 :caption: Contents: + source/api + source/modules + source/todo + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` \ No newline at end of file diff --git a/docs/source/modules.rst b/docs/source/modules.rst new file mode 100644 index 000000000..646a245d2 --- /dev/null +++ b/docs/source/modules.rst @@ -0,0 +1,97 @@ +Liger Kernel Modules +===================== + +.. toctree:: + :maxdepth: 2 + + liger_kernel.transformers + liger_kernel.nn + liger_kernel.transformers.experimental + +liger_kernel.transformers +------------------------- + +.. automodule:: liger_kernel.transformers + :members: + +AutoLigerKernelForCausalLM +--------------------------- + +.. autoclass:: liger_kernel.transformers.AutoLigerKernelForCausalLM + :members: + :undoc-members: + +LigerFusedLinearCrossEntropyLoss +--------------------------------- + +.. autoclass:: liger_kernel.transformers.LigerFusedLinearCrossEntropyLoss + :members: + :undoc-members: + +KLDivergence +------------- + +.. autoclass:: liger_kernel.transformers.KLDivergence + :members: + :undoc-members: + +JSD +---- + +.. autoclass:: liger_kernel.transformers.JSD + :members: + :undoc-members: + +Generalized JSD +---------------- + +.. autoclass:: liger_kernel.transformers.GeneralizedJSD + :members: + :undoc-members: + +FusedLinearJSD +---------------- + +.. autoclass:: liger_kernel.transformers.FusedLinearJSD + :members: + :undoc-members: + +apply_liger_kernel_to_llama +----------------------------- + +.. autofunction:: liger_kernel.transformers.apply_liger_kernel_to_llama + :members: + :undoc-members: + +liger_kernel.nn +---------------- + +.. automodule:: liger_kernel.nn + :members: + +nn.Module +--------- + +.. autoclass:: liger_kernel.nn.Module + :members: + :undoc-members: + +liger_kernel.transformers.experimental +-------------------------------------- + +.. automodule:: liger_kernel.transformers.experimental + :members: + +LigerEmbeddingMatmul +--------------------- + +.. autoclass:: liger_kernel.transformers.experimental.LigerEmbeddingMatmul + :members: + :undoc-members: + +Matmul int2xint8 +----------------- + +.. autoclass:: liger_kernel.transformers.experimental.Matmul + :members: + :undoc-members: \ No newline at end of file diff --git a/docs/source/todo.rst b/docs/source/todo.rst new file mode 100644 index 000000000..e69de29bb From ac2ce4929c9389df26085289a8071d9f346f9bfa Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Sun, 27 Oct 2024 19:25:38 +0000 Subject: [PATCH 04/19] Updated GitHub worflow and configurations. --- .github/workflows/sphinx.yml | 34 +++++++++++++--------- docs/{_build/.doctrees => }/source/conf.py | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) rename docs/{_build/.doctrees => }/source/conf.py (98%) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 1e63e921b..a8784fce4 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -8,17 +8,23 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v4 - - name: Build HTML - uses: ammaraskar/sphinx-action@master - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: html-docs - path: docs/build/html/ - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/main' - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/build/html \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Upgrade pip + run: python -m pip install --upgrade pip + + - name: Install dependencies + run: pip install -r docs/requirements.txt + + - name: Build documentation + env: + INPUT_DOCS-FOLDER: "docs/source" # Adjust if conf.py is in a different folder + INPUT_BUILD-COMMAND: "make html" + run: | + make -C docs/ clean html || exit 1 diff --git a/docs/_build/.doctrees/source/conf.py b/docs/source/conf.py similarity index 98% rename from docs/_build/.doctrees/source/conf.py rename to docs/source/conf.py index d30e091c2..2b1eeb9b2 100644 --- a/docs/_build/.doctrees/source/conf.py +++ b/docs/source/conf.py @@ -67,7 +67,7 @@ def __init__(self, *args, **kwargs): exclude_patterns = [] # HTML output options -html_theme = 'sphinx_rtd_theme' +html_theme = 'alabaster' html_static_path = [os.path.join(source_dir, '_static')] html_theme_options = { 'navigation_depth': 4, From 2e43830707f0067635d8c9552d68c4700f91b44a Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 06:41:27 +0000 Subject: [PATCH 05/19] Changed conf.py to fix circular import issue, and added new files. --- docs/source/api.rst | 54 ++++++++++---- docs/source/conf.py | 89 ++++++++++++++++------- docs/source/liger_kernel.nn.rst | 0 docs/source/liger_kernel.transformers.rst | 0 docs/source/recursion_trace.py | 19 +++++ 5 files changed, 122 insertions(+), 40 deletions(-) create mode 100644 docs/source/liger_kernel.nn.rst create mode 100644 docs/source/liger_kernel.transformers.rst create mode 100644 docs/source/recursion_trace.py diff --git a/docs/source/api.rst b/docs/source/api.rst index c2fedc943..0888c233a 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -12,49 +12,69 @@ Submodules liger_kernel.transformers liger_kernel.nn -liger_kernel.transformers --------------------------- +Transformers Module +------------------- + +The `liger_kernel.transformers` module includes essential tools and model classes designed for tasks such as language modeling and loss calculations, optimizing deep learning workflows. .. automodule:: liger_kernel.transformers :members: +Classes +------- + AutoLigerKernelForCausalLM ---------------------------- +-------------------------- + +The `AutoLigerKernelForCausalLM` class is an extension for causal language modeling, providing enhanced support for auto-regressive tasks. .. autoclass:: liger_kernel.transformers.AutoLigerKernelForCausalLM :members: :undoc-members: LigerFusedLinearCrossEntropyLoss ---------------------------------- +-------------------------------- + +Implements a fused linear layer with Cross-Entropy Loss, offering computational efficiency improvements. .. autoclass:: liger_kernel.transformers.LigerFusedLinearCrossEntropyLoss :members: :undoc-members: +Loss Functions +-------------- + KLDivergence -------------- +------------ + +The `KLDivergence` class offers a divergence metric based on Kullback-Leibler Divergence, commonly used in various ML training contexts. .. autoclass:: liger_kernel.transformers.KLDivergence :members: :undoc-members: JSD ----- +--- + +This class defines the Jensen-Shannon Divergence (JSD), used for calculating symmetrical divergence between distributions. .. autoclass:: liger_kernel.transformers.JSD :members: :undoc-members: -Generalized JSD ----------------- +GeneralizedJSD +-------------- + +Generalized form of Jensen-Shannon Divergence, adapted for more complex applications. .. autoclass:: liger_kernel.transformers.GeneralizedJSD :members: :undoc-members: FusedLinearJSD ----------------- +-------------- + +Provides a fused linear implementation of Jensen-Shannon Divergence for faster computation. .. autoclass:: liger_kernel.transformers.FusedLinearJSD :members: @@ -63,18 +83,24 @@ FusedLinearJSD Experimental Kernels --------------------- +A collection of experimental kernels for advanced and experimental features in `liger_kernel`. + .. automodule:: liger_kernel.transformers.experimental :members: -liger_kernel.nn ----------------- +Neural Network Module +--------------------- + +The `liger_kernel.nn` module offers fundamental neural network building blocks. .. automodule:: liger_kernel.nn :members: -nn.Module ---------- +Module Class +------------ + +The base `nn.Module` class provides essential methods and attributes for building neural network models. .. autoclass:: liger_kernel.nn.Module :members: - :undoc-members: \ No newline at end of file + :undoc-members: diff --git a/docs/source/conf.py b/docs/source/conf.py index 2b1eeb9b2..49f516a84 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,28 +1,21 @@ import os import sys -from unittest.mock import MagicMock - -class MockModule(MagicMock): - @classmethod - def __getattr__(cls, name): - if name == '__all__': - return [] - return MagicMock() - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.__all__ = [] +import importlib +import inspect + +# Increase the recursion limit (optional) +sys.setrecursionlimit(10000) # Configure paths docs_dir = os.path.abspath(os.path.dirname(__file__)) root_dir = os.path.abspath(os.path.join(docs_dir, '..')) sys.path.insert(0, root_dir) -# Source and Build directories +# Source and build directories source_dir = os.path.join(docs_dir, 'source') output_dir = os.path.join(docs_dir, '_build') -# List all modules to mock +# List modules to mock (as simple strings) MOCK_MODULES = [ 'liger_kernel', 'liger_kernel.transformers', @@ -36,14 +29,17 @@ def __init__(self, *args, **kwargs): 'liger_kernel.transformers.FusedLinearJSD', 'liger_kernel.nn.Module', ] -sys.modules.update((mod_name, MockModule()) for mod_name in MOCK_MODULES) + +# Mock modules by replacing them in sys.modules +for mod_name in MOCK_MODULES: + sys.modules[mod_name] = None # Simple mock; replace with 'None' or a basic object as needed # Project information project = 'Liger-Kernel' copyright = '2024' author = 'LinkedIn' -# General configuration +# General Sphinx configuration extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', @@ -51,22 +47,26 @@ def __init__(self, *args, **kwargs): 'sphinx.ext.todo', 'sphinx.ext.autosummary', 'sphinx.ext.linkcode', - 'sphinx.ext.intersphinx' + 'sphinx.ext.intersphinx', ] -# Intersphinx configuration +# Mocked imports for autodoc +autodoc_mock_imports = ['numpy', 'tensorflow', 'torch', 'triton'] + +# Intersphinx mapping for cross-referencing external documentation intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), 'numpy': ('https://numpy.org/doc/stable', None), 'torch': ('https://pytorch.org/docs/stable', None), + 'triton': ('https://triton-lang.org/main/', None), } -# Source and build configuration +# Source file configuration source_suffix = '.rst' master_doc = 'index' exclude_patterns = [] -# HTML output options +# HTML output configuration html_theme = 'alabaster' html_static_path = [os.path.join(source_dir, '_static')] html_theme_options = { @@ -74,16 +74,53 @@ def __init__(self, *args, **kwargs): 'collapse_navigation': False, } -# Output directory configuration -html_baseurl = '' +# Output directory for HTML files html_output_dir = output_dir -# autodoc configuration +# Autodoc configuration autodoc_member_order = 'bysource' autoclass_content = 'both' -# Enable todo +# Enable todo extension todo_include_todos = True -# Generate autosummary -autosummary_generate = True \ No newline at end of file +# Autosummary settings +autosummary_generate = True + +def linkcode_resolve(domain, info): + """ + Determine the URL corresponding to Python object + """ + if domain != 'py': + return None + + try: + mod = importlib.import_module(info['module']) + if 'class' in info: + obj = getattr(mod, info['class']) + if 'fullname' in info: + obj = getattr(obj, info['fullname']) + else: + obj = getattr(mod, info['fullname']) + except Exception: + return None + + try: + filepath = inspect.getsourcefile(obj) + if filepath: + filepath = os.path.relpath(filepath, start=root_dir) + else: + return None + except Exception: + return None + + try: + source, lineno = inspect.getsourcelines(obj) + except Exception: + return None + + # Modify these values based on your repository + github_url = "https://github.com/LinkedIn/liger-kernel" + branch = "main" # or whatever your default branch is + + return f"{github_url}/blob/{branch}/{filepath}#L{lineno}-L{lineno + len(source) - 1}" \ No newline at end of file diff --git a/docs/source/liger_kernel.nn.rst b/docs/source/liger_kernel.nn.rst new file mode 100644 index 000000000..e69de29bb diff --git a/docs/source/liger_kernel.transformers.rst b/docs/source/liger_kernel.transformers.rst new file mode 100644 index 000000000..e69de29bb diff --git a/docs/source/recursion_trace.py b/docs/source/recursion_trace.py new file mode 100644 index 000000000..f967b0f00 --- /dev/null +++ b/docs/source/recursion_trace.py @@ -0,0 +1,19 @@ +import sys +import inspect + +def trace(frame, event, arg): + if event == "call": + print(f"Recursion depth: {len(inspect.stack())}") + return trace + +sys.settrace(trace) + +# Add a sample recursive function to test the trace function +def recursive_function(n): + if n > 0: + recursive_function(n - 1) + else: + print("Reached base case") + +# Run the recursive function to test recursion depth tracking +recursive_function(10) From 7107fcce39c815cb6eb8b9cb3271a37da4766e13 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 06:45:38 +0000 Subject: [PATCH 06/19] Edited github action with improvements. --- .github/workflows/sphinx.yml | 41 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index a8784fce4..1f0725186 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -3,28 +3,23 @@ name: "Sphinx: Render docs" on: push jobs: - build: + build-docs: runs-on: ubuntu-latest - permissions: - contents: write steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Upgrade pip - run: python -m pip install --upgrade pip - - - name: Install dependencies - run: pip install -r docs/requirements.txt - - - name: Build documentation - env: - INPUT_DOCS-FOLDER: "docs/source" # Adjust if conf.py is in a different folder - INPUT_BUILD-COMMAND: "make html" - run: | - make -C docs/ clean html || exit 1 + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install sphinx>=5.0.0 + # Install other dependencies if needed + pip install -r requirements.txt + + - name: Build documentation + run: | + cd docs + make html \ No newline at end of file From 0a2a8f45cd8197b05fbd6c539d937ec72639f9e8 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 06:51:32 +0000 Subject: [PATCH 07/19] Updated requirements.txt --- docs/requirements.txt | 1 - requirements.txt | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) delete mode 100644 docs/requirements.txt create mode 100644 requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 324649132..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -furo==2021.11.16 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..fc3aad1a4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +furo==2021.11.16 +sphinx>=5.0.0 +sphinx-rtd-theme>=1.0.0 +sphinxcontrib-applehelp>=1.0.4 +sphinxcontrib-devhelp>=1.0.2 +sphinxcontrib-htmlhelp>=2.0.1 +sphinxcontrib-serializinghtml>=1.1.5 +sphinxcontrib-qthelp>=1.0.3 \ No newline at end of file From a21f925d32b31022694ed36dfa3eedc396804536 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 06:53:35 +0000 Subject: [PATCH 08/19] Updated requirements file. --- requirements.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index fc3aad1a4..13d941d23 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ furo==2021.11.16 -sphinx>=5.0.0 -sphinx-rtd-theme>=1.0.0 -sphinxcontrib-applehelp>=1.0.4 -sphinxcontrib-devhelp>=1.0.2 +sphinx==4.0.0 +sphinx-rtd-theme==1.0.0 +sphinxcontrib-applehelp==1.0.4 +sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp>=2.0.1 -sphinxcontrib-serializinghtml>=1.1.5 -sphinxcontrib-qthelp>=1.0.3 \ No newline at end of file +sphinxcontrib-serializinghtml==1.1.5 +sphinxcontrib-qthelp==1.0.3 \ No newline at end of file From 0589d036967cbec0823d3916f8cab17668501568 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 06:57:59 +0000 Subject: [PATCH 09/19] Updated github action file. --- .github/workflows/sphinx.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 1f0725186..9c159ee19 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -6,11 +6,11 @@ jobs: build-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.11' - name: Install dependencies run: | @@ -22,4 +22,16 @@ jobs: - name: Build documentation run: | cd docs - make html \ No newline at end of file + make html + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: documentation + path: docs/_build/html/ + + - name: Deploy to GitHub Pages + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html \ No newline at end of file From 8e576f27ddba78ede62dceaacf5227bb330ce7ec Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 07:04:43 +0000 Subject: [PATCH 10/19] Update actions file. --- .github/workflows/sphinx.yml | 6 +++++- requirements.txt | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 9c159ee19..a2d8d116b 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,6 +1,10 @@ name: "Sphinx: Render docs" -on: push +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: build-docs: diff --git a/requirements.txt b/requirements.txt index 13d941d23..03ed8eeb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -furo==2021.11.16 -sphinx==4.0.0 -sphinx-rtd-theme==1.0.0 -sphinxcontrib-applehelp==1.0.4 -sphinxcontrib-devhelp==1.0.2 +sphinx>=7.0.0 +furo>=2023.09.10 +sphinxcontrib-applehelp>=1.0.4 +sphinxcontrib-devhelp>=1.0.2 sphinxcontrib-htmlhelp>=2.0.1 -sphinxcontrib-serializinghtml==1.1.5 -sphinxcontrib-qthelp==1.0.3 \ No newline at end of file +sphinxcontrib-serializinghtml>=1.1.5 +sphinxcontrib-qthelp>=1.0.3 +typing-extensions>=4.8.0 \ No newline at end of file From c09ca1b04a3b7c29f73f8eb5e85f40bb3cbb86f8 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 07:50:03 +0000 Subject: [PATCH 11/19] Delete test file. --- docs/source/recursion_trace.py | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 docs/source/recursion_trace.py diff --git a/docs/source/recursion_trace.py b/docs/source/recursion_trace.py deleted file mode 100644 index f967b0f00..000000000 --- a/docs/source/recursion_trace.py +++ /dev/null @@ -1,19 +0,0 @@ -import sys -import inspect - -def trace(frame, event, arg): - if event == "call": - print(f"Recursion depth: {len(inspect.stack())}") - return trace - -sys.settrace(trace) - -# Add a sample recursive function to test the trace function -def recursive_function(n): - if n > 0: - recursive_function(n - 1) - else: - print("Reached base case") - -# Run the recursive function to test recursion depth tracking -recursive_function(10) From e0350dfbfb72217b3de1390d6352e9d9e15176b6 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:08:39 +0000 Subject: [PATCH 12/19] Update Compability with ruff. --- .github/workflows/ci.yml | 27 +++++++++++++++------------ pyproject.toml | 10 +++++++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f41afdb6d..c8d1fcb2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,5 @@ +# CI Pipeline + name: CI Pipeline on: @@ -13,18 +15,19 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 isort black + - name: Install Ruff + run: | + python -m pip install --upgrade pip + pip install ruff - - name: Run checkstyle - run: make checkstyle \ No newline at end of file + - name: Run Ruff + run: | + ruff . \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 74e19c801..53d8225a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,9 +22,7 @@ transformers = [ dev = [ "transformers>=4.44.2", "matplotlib>=3.7.2", - "flake8>=4.0.1.1", - "black>=24.4.2", - "isort>=5.13.2", + "ruff>=0.0.210", # Replaced flake8, black, and isort with Ruff "pytest>=7.1.2", "datasets>=2.19.2", "torchvision>=0.16.2", @@ -43,3 +41,9 @@ pythonpath = [ asyncio_mode = "auto" log_cli = true log_cli_level = "INFO" + +[tool.ruff] +select = ["E", "W", "I"] # Select all errors, warnings, and information messages +ignore = ["E226", "E24"] # Ignore specific error codes +extend-select = ["DT100", "SIM100"] # Extend select with specific rules +show-source = true # Show source code snippets \ No newline at end of file From e5f78de878bbbc02ddda4fd2a10646ec58194406 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:11:05 +0000 Subject: [PATCH 13/19] Updated CI Pipeline. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8d1fcb2d..fc41a517c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,4 +30,4 @@ jobs: - name: Run Ruff run: | - ruff . \ No newline at end of file + ruff check. \ No newline at end of file From 740106c07f183a3b0d3a434086bfc51cb2158692 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:12:07 +0000 Subject: [PATCH 14/19] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc41a517c..3f233f781 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,4 +30,4 @@ jobs: - name: Run Ruff run: | - ruff check. \ No newline at end of file + ruff check \ No newline at end of file From 5ef47b05bc369a5aaee3f5eaaab10bc168908586 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:17:49 +0000 Subject: [PATCH 15/19] Update .toml --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 53d8225a2..c07bcd761 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,6 @@ dependencies = [ transformers = [ "transformers~=4.0" ] - dev = [ "transformers>=4.44.2", "matplotlib>=3.7.2", @@ -35,8 +34,8 @@ include = ["liger_kernel", "liger_kernel.*"] [tool.pytest.ini_options] pythonpath = [ - "src", - "." + "src", + "." ] asyncio_mode = "auto" log_cli = true From 8456f58ea6cce4eda05571df8362284337b08228 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:22:36 +0000 Subject: [PATCH 16/19] Update Ci Pipeline. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c07bcd761..c7e7ff34b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,5 +44,5 @@ log_cli_level = "INFO" [tool.ruff] select = ["E", "W", "I"] # Select all errors, warnings, and information messages ignore = ["E226", "E24"] # Ignore specific error codes -extend-select = ["DT100", "SIM100"] # Extend select with specific rules +extend-select = ["SIM100"] # Extend select with specific rules show-source = true # Show source code snippets \ No newline at end of file From cb8442e0aa30a8c5c2e2e6a5e287680e12aed8d3 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 08:28:03 +0000 Subject: [PATCH 17/19] Update pyproject.toml file. --- pyproject.toml | 81 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c7e7ff34b..dc8926028 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,80 @@ log_cli = true log_cli_level = "INFO" [tool.ruff] -select = ["E", "W", "I"] # Select all errors, warnings, and information messages -ignore = ["E226", "E24"] # Ignore specific error codes -extend-select = ["SIM100"] # Extend select with specific rules -show-source = true # Show source code snippets \ No newline at end of file +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py38" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" \ No newline at end of file From 95ff480068c0e94697b5f119f0ad18c2597f5e46 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 09:37:31 +0000 Subject: [PATCH 18/19] Update CI pipeline. --- .github/workflows/ci.yml | 27 ++++++------ pyproject.toml | 90 ++++------------------------------------ 2 files changed, 19 insertions(+), 98 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f233f781..f41afdb6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,3 @@ -# CI Pipeline - name: CI Pipeline on: @@ -15,19 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' - - name: Install Ruff - run: | - python -m pip install --upgrade pip - pip install ruff + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 isort black - - name: Run Ruff - run: | - ruff check \ No newline at end of file + - name: Run checkstyle + run: make checkstyle \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index dc8926028..7849f58cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,10 +18,13 @@ dependencies = [ transformers = [ "transformers~=4.0" ] + dev = [ "transformers>=4.44.2", "matplotlib>=3.7.2", - "ruff>=0.0.210", # Replaced flake8, black, and isort with Ruff + "flake8>=4.0.1.1", + "black>=24.4.2", + "isort>=5.13.2", "pytest>=7.1.2", "datasets>=2.19.2", "torchvision>=0.16.2", @@ -34,88 +37,9 @@ include = ["liger_kernel", "liger_kernel.*"] [tool.pytest.ini_options] pythonpath = [ - "src", - "." + "src", + "." ] asyncio_mode = "auto" log_cli = true -log_cli_level = "INFO" - -[tool.ruff] -# Exclude a variety of commonly ignored directories. -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".git-rewrite", - ".hg", - ".ipynb_checkpoints", - ".mypy_cache", - ".nox", - ".pants.d", - ".pyenv", - ".pytest_cache", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "site-packages", - "venv", -] - -# Same as Black. -line-length = 88 -indent-width = 4 - -# Assume Python 3.8 -target-version = "py38" - -[tool.ruff.lint] -# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. -# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or -# McCabe complexity (`C901`) by default. -select = ["E4", "E7", "E9", "F"] -ignore = [] - -# Allow fix for all enabled rules (when `--fix`) is provided. -fixable = ["ALL"] -unfixable = [] - -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -[tool.ruff.format] -# Like Black, use double quotes for strings. -quote-style = "double" - -# Like Black, indent with spaces, rather than tabs. -indent-style = "space" - -# Like Black, respect magic trailing commas. -skip-magic-trailing-comma = false - -# Like Black, automatically detect the appropriate line ending. -line-ending = "auto" - -# Enable auto-formatting of code examples in docstrings. Markdown, -# reStructuredText code/literal blocks and doctests are all supported. -# -# This is currently disabled by default, but it is planned for this -# to be opt-out in the future. -docstring-code-format = false - -# Set the line length limit used when formatting code snippets in -# docstrings. -# -# This only has an effect when the `docstring-code-format` setting is -# enabled. -docstring-code-line-length = "dynamic" \ No newline at end of file +log_cli_level = "INFO" \ No newline at end of file From b41a3435c5f9315424dbcc57a164e19165b19614 Mon Sep 17 00:00:00 2001 From: Parag Ekbote Date: Mon, 28 Oct 2024 09:54:48 +0000 Subject: [PATCH 19/19] Update liger_kernel.transformers file --- docs/source/liger_kernel.transformers.rst | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/source/liger_kernel.transformers.rst b/docs/source/liger_kernel.transformers.rst index e69de29bb..6ced7eb3a 100644 --- a/docs/source/liger_kernel.transformers.rst +++ b/docs/source/liger_kernel.transformers.rst @@ -0,0 +1,36 @@ +.. automodule:: liger_kernel.transformers + :members: + +Liger Cross Entropy Function +============================= + +.. autoclass:: LigerCrossEntropyFunction + :members: + + The Liger Cross Entropy Function is a custom autograd function that implements the Liger Cross Entropy loss. + It overrides the forward and backward methods of the torch.autograd.Function class. + + .. automethod:: forward + + .. automethod:: backward + +Liger Cross Entropy Forward +============================ + +.. autofunction:: cross_entropy_forward + +Liger Cross Entropy Backward +============================ + +.. autofunction:: cross_entropy_backward + +Liger Cross Entropy Kernel +========================== + +.. autofunction:: liger_cross_entropy_kernel + +Element Mul Kernel +=================== + +.. autofunction:: element_mul_kernel +