Activation function Triton kernels, LoRA custom autograd functions #2324
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Title. These optimizations can be enabled for certain models and LoRA configurations via YAML config options detailed in the
kernels.qmd
file.Motivation and Context
These optimizations were inspired by similar optims in Unsloth, which improve speed and memory usage of models during training / post-training. We wanted to add them to Axolotl in part to remove this Unsloth dependency, and study / improve Triton kernels / custom autograd functions / the patching logic.
How has this been tested?
Various
pytest
tests undertests/e2e/kernels
.Benchmarks
Using variations on this Gist, on 1x H100 SXM.
SmolLM2-135M
Patching MLP only:
Patching all modules (MLP + QKV projections + output projection):
SmolLM2-1.7B
Patching MLP only:
Patching all modules (MLP + QKV projections + output projection):
meta-llama/Llama-3.2-3B
Patching MLP only:
Patching all modules (MLP + QKV projections + output projection):
In summary, we're seeing ~10-20% savings in peak VRAM usage, around +25 to +50% forward pass throughput, and around -15% to +5% change in forward pass throughput.