How pearblossom-m/flash-swiglu-mlp works
Flash SwiGLU MLP is a GPU-optimized PyTorch/Triton library for the SwiGLU feed-forward block used in LLMs. Callers use either the functional API or a weight-owning module; both enter the same autograd operation. Forward fuses the gate and up projections with SiLU and gating, then uses PyTorch linear for the down projection. Training saves intermediates and computes gradients through fused backward kernels and matrix multiplies; inference skips saving gate/up activations. The README also documents Falcon H1 scaling and shape-bucketed autotuning. Some orchestration source was omitted, so the graph leaves uncertain internal dispatch details out.
Main entry points: ops.py Autograd function · module.py FlashSwiGLUMLP · kernel.py Fused train forward
Components 14
Public API
- FlashSwiGLUMLP
src/flash_swiglu_mlp/module.py - flash_swiglu
src/flash_swiglu_mlp/ops.py
Forward compute
- Input preparation
src/flash_swiglu_mlp/ops.py - Fused train forward
src/flash_swiglu_mlp/kernel.py - Fused inference forward
src/flash_swiglu_mlp/kernel.py - AGU intermediates
src/flash_swiglu_mlp/ops.py - Down projection
src/flash_swiglu_mlp/ops.py
Autograd
- Autograd function
src/flash_swiglu_mlp/ops.py - Activation gradients
src/flash_swiglu_mlp/kernel.py - Weight gradients
src/flash_swiglu_mlp/ops.py - Input gradient
src/flash_swiglu_mlp/kernel.py
Other components
- Model / caller
- PyTorch / cuBLAS
- Output / gradients
Connections 17
- Model / caller → FlashSwiGLUMLP: calls
- Model / caller → flash_swiglu: calls
- FlashSwiGLUMLP → flash_swiglu: calls
- flash_swiglu → Autograd function: applies
- Autograd function → Input preparation: prepares tensors
- Autograd function → Fused train forward: launches
- Autograd function → Fused inference forward: launches
- Fused train forward → AGU intermediates: stores activations
- Autograd function → Down projection: projects activations
- Down projection → PyTorch / cuBLAS: runs linear
- PyTorch / cuBLAS → Output / gradients: returns output
- Autograd function → Activation gradients: launches backward
- Autograd function → Weight gradients: computes weight grads
- Weight gradients → PyTorch / cuBLAS: uses matmul
- Autograd function → Input gradient: launches backward
- Input gradient → Output / gradients: returns input grad
- Weight gradients → Output / gradients: returns weight grads