Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
MoE kernels AGPLv3
Daniel Han538558df53c5
diff --git a/unsloth/kernels/moe/README.md b/unsloth/kernels/moe/README.mdindex 326ee159c94..0375c8d5079 100644--- a/unsloth/kernels/moe/README.md+++ b/unsloth/kernels/moe/README.md@@ -1,6 +1,7 @@## MoE Grouped GEMMOptimized implementation of `MoE MLP Block`.+Licensed under AGPLv3.### Backgrounddiff --git a/unsloth/kernels/moe/grouped_gemm/interface.py b/unsloth/kernels/moe/grouped_gemm/interface.pyindex 99c58b36ec6..5d1a8865e53 100644--- a/unsloth/kernels/moe/grouped_gemm/interface.py+++ b/unsloth/kernels/moe/grouped_gemm/interface.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import loggingimport warningsfrom dataclasses import asdictdiff --git a/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py b/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.pyindex fb924ed368f..d57105ceef9 100644--- a/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py+++ b/unsloth/kernels/moe/grouped_gemm/kernels/autotuning.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+"""Autotuning utils"""diff --git a/unsloth/kernels/moe/grouped_gemm/kernels/backward.py b/unsloth/kernels/moe/grouped_gemm/kernels/backward.pyindex ba35ee6993b..a05fb4d5d08 100644--- a/unsloth/kernels/moe/grouped_gemm/kernels/backward.py+++ b/unsloth/kernels/moe/grouped_gemm/kernels/backward.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import torchimport tritonimport triton.language as tldiff --git a/unsloth/kernels/moe/grouped_gemm/kernels/forward.py b/unsloth/kernels/moe/grouped_gemm/kernels/forward.pyindex fbc231304a6..98f66502978 100644--- a/unsloth/kernels/moe/grouped_gemm/kernels/forward.py+++ b/unsloth/kernels/moe/grouped_gemm/kernels/forward.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import torchimport tritonimport triton.language as tldiff --git a/unsloth/kernels/moe/grouped_gemm/kernels/tuning.py b/unsloth/kernels/moe/grouped_gemm/kernels/tuning.pyindex 8c0a8c717ef..3632e811efb 100644--- a/unsloth/kernels/moe/grouped_gemm/kernels/tuning.py+++ b/unsloth/kernels/moe/grouped_gemm/kernels/tuning.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+"""Manual tuning utils"""diff --git a/unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.py b/unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.pyindex 63e64af8584..3d1afac9e37 100644--- a/unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.py+++ b/unsloth/kernels/moe/grouped_gemm/reference/layers/llama4_moe.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+from dataclasses import dataclassfrom typing import Tuplediff --git a/unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.py b/unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.pyindex 37f001aefce..0ca4391b296 100644--- a/unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.py+++ b/unsloth/kernels/moe/grouped_gemm/reference/layers/qwen3_moe.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+from dataclasses import dataclassfrom typing import Tuplediff --git a/unsloth/kernels/moe/grouped_gemm/reference/moe_block.py b/unsloth/kernels/moe/grouped_gemm/reference/moe_block.pyindex ac7c7a59a5f..cbccf19cbe9 100644--- a/unsloth/kernels/moe/grouped_gemm/reference/moe_block.py+++ b/unsloth/kernels/moe/grouped_gemm/reference/moe_block.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import torchfrom transformers.models.qwen3_moe.configuration_qwen3_moe import Qwen3MoeConfigfrom transformers.models.qwen3_moe.modeling_qwen3_moe import Qwen3MoeSparseMoeBlockdiff --git a/unsloth/kernels/moe/grouped_gemm/reference/moe_ops.py b/unsloth/kernels/moe/grouped_gemm/reference/moe_ops.pyindex 08c04778a01..85ebf147f3b 100644--- a/unsloth/kernels/moe/grouped_gemm/reference/moe_ops.py+++ b/unsloth/kernels/moe/grouped_gemm/reference/moe_ops.py@@ -1,3 +1,5 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.import torchimport torch.nn.functional as Fdiff --git a/unsloth/kernels/moe/tests/common.py b/unsloth/kernels/moe/tests/common.pyindex 8ab1482b5c5..67461b39f1e 100644--- a/unsloth/kernels/moe/tests/common.py+++ b/unsloth/kernels/moe/tests/common.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import itertoolsfrom contextlib import contextmanagerfrom dataclasses import dataclass, fielddiff --git a/unsloth/kernels/moe/tests/moe_utils.py b/unsloth/kernels/moe/tests/moe_utils.pyindex 18a30dd3498..b32e4476c9a 100644--- a/unsloth/kernels/moe/tests/moe_utils.py+++ b/unsloth/kernels/moe/tests/moe_utils.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+from dataclasses import dataclass, fieldsimport torchdiff --git a/unsloth/kernels/moe/tests/test_grouped_gemm.py b/unsloth/kernels/moe/tests/test_grouped_gemm.pyindex cad5d2df95b..38b7e00ca3b 100644--- a/unsloth/kernels/moe/tests/test_grouped_gemm.py+++ b/unsloth/kernels/moe/tests/test_grouped_gemm.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+from dataclasses import asdictimport pytestdiff --git a/unsloth/kernels/moe/tests/test_llama4_moe.py b/unsloth/kernels/moe/tests/test_llama4_moe.pyindex 16d1611dd7a..27d5d99a244 100644--- a/unsloth/kernels/moe/tests/test_llama4_moe.py+++ b/unsloth/kernels/moe/tests/test_llama4_moe.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import argparseimport sysfrom contextlib import contextmanagerdiff --git a/unsloth/kernels/moe/tests/test_qwen3_moe.py b/unsloth/kernels/moe/tests/test_qwen3_moe.pyindex ee4277ce23a..0e1eee9902b 100644--- a/unsloth/kernels/moe/tests/test_qwen3_moe.py+++ b/unsloth/kernels/moe/tests/test_qwen3_moe.py@@ -1,3 +1,6 @@+# SPDX-License-Identifier: GNU Affero General Public License v3.0+# Copyright 2023-present the Unsloth team. All rights reserved.+import argparsefrom contextlib import contextmanager