|
|
Fit an Elephant into a Fridge |
Sparse And Low-Rank Adaptation via ADMM for Large Language Model Inference
Official implementation of SALAAD, a plug-and-play framework for inducing sparse plus low-rank structure during language-model pretraining.
- Pretraining-time compression: induce sparse-and-low-rank structure during pretraining.
- Plug-and-play framework: compatible with existing training pipelines.
- Architecture-agnostic: compatible with existing foundation models.
- Scalable: adaptive structure control and distributed block-wise updates.
- Elastic deployment: support different memory budgets with one trained checkpoint.
SALAAD operates in weight space and does not require architectural changes to the underlying Transformer model. During training, selected weight matrices are coupled to structured surrogate variables through an ADMM-style objective:
Here
The code currently focuses on LLaMA-style causal language models and includes training, evaluation, Hugging Face export, and LM Evaluation Harness workflows.
Let a language model contain selected weight blocks {X_i}_{i=1}^N, where each
block is a linear map in the Transformer, such as attention projections, MLP
projections, or embeddings. SALAAD introduces a sparse plus low-rank surrogate
for each selected block:
where L_i captures the dominant low-rank structure and S_i captures sparse
residual variation. For one block, the problem is formulated as:
Here X is updated by standard backpropagation on the coupled loss:
Then the structured variables are recovered with closed-form proximal updates:
This produces both the trained dense weights
SALAAD also uses an I-controller to adapt the block-wise thresholding levels
alpha and beta from the observed effective rank of L and density of S.
This lets different Transformer blocks acquire different ranks and sparsity
patterns without manually assigning per-layer schedules.
At deployment time, the learned surrogate can be further compressed with Homomorphic Parameter Allocation (HPA): singular values and sparse entries are truncated according to a target parameter budget. As a result, one SALAAD checkpoint can produce a continuous family of architecture-preserving surrogate models without retraining.
| Path | Purpose |
|---|---|
salaad/ |
Core trainer, ADMM solver, operators, and utilities |
models/ |
Local LLaMA model implementation |
dataloaders/ |
Iterable C4/tokenization utilities |
configs/ |
Small example training and model configs |
scripts/ |
Training, evaluation, resave, and lm-eval entry points |
tests/ |
Lightweight smoke tests |
The main training path is:
scripts/train_salad.py
-> salaad/register.py
-> salaad/trainer_salad.py
-> salaad/salad_solver.py
Use Python 3.9+ and install a PyTorch build that matches your CUDA environment before installing this package. See the PyTorch installation instructions for the correct command for your system.
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
# Install PyTorch separately for your CUDA/CPU environment first.
pip install -e ".[dev]"Training streams C4 from Hugging Face. If you need gated resources or hit rate limits, authenticate before running:
huggingface-cli loginWeights & Biases logging is optional. If enabled in a config, set:
export WANDB_API_KEY=...
export WANDB_ENTITY=...Run the lightweight solver smoke test first:
python -m pytest tests/test_smoke.py -qFor real training, start with the debug configuration. This command streams C4 from Hugging Face and expects a working PyTorch distributed/CUDA setup:
torchrun \
--nproc_per_node=1 \
--nnodes=1 \
--rdzv_backend=c10d \
--rdzv_endpoint=127.0.0.1:29500 \
scripts/train_salad.py \
--cfg_version llama_debug \
--folder debugOutputs are written to:
data/<folder>/<cfg_version>/<timestamp>/
Typical outputs include model.pth, copied config files, layer_info.pkl, and
rank-local matrix_rank<N>.pkl files containing the low-rank, sparse, and dual
variables.
Training configs live in configs/*.yaml; matching architecture configs live in
configs/*_model.json.
Important fields:
training_mode:saladfor low-rank/sparse training orvanillafor normal training.num_total_iters: total optimizer updates.num_freq: how often to run ADMM updates.layers: model layers to decompose.rate_rank: target low-rank ratio for a layer.rate_sparsity: target sparse density for a layer.rho_dict,alpha_dict,beta_dict: ADMM penalty and adaptive threshold settings.
Evaluate a trained SALAAD run directly from its output directory:
python scripts/evaluation.py \
--run_dir data/debug/llama_debug/<timestamp> \
--target_params 6.5Resave the checkpoint in Hugging Face format:
python scripts/resave_model.py \
--run_dir data/debug/llama_debug/<timestamp> \
--target_params 6.5 \
--gamma 0.5This writes:
data/debug/llama_debug/<timestamp>/model_resave/vanilla/
data/debug/llama_debug/<timestamp>/model_resave/surrogate/
Run LM Evaluation Harness on a resaved model:
python scripts/run_lm_eval.py \
--model_dir data/debug/llama_debug/<timestamp>/model_resave \
--variant both \
--tasks piqa boolq \
--batch_size 8Use --variant direct if --model_dir points directly to a Hugging Face model
folder rather than a directory containing vanilla/ and surrogate/.
This is research code. Start with llama_debug, verify dataset streaming in
your environment, and avoid committing generated checkpoints or experiment
outputs.
This repository is released under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0). The code is available for non-commercial research use. Commercial use is not permitted without prior written permission from the copyright holders.
Some files include code adapted from third-party projects under their original
licenses. See NOTICE for attribution details.
If you use this codebase, please cite:
@inproceedings{ma2026salaad,
title = {{SALAAD}: {Sparse And Low-Rank Adaptation via {ADMM} for Large Language Model Inference}},
author = {Ma, Hao and Bal, Melis Ilayda and Zhang, Liang and Li, Bingcong and He, Niao and Zeilinger, Melanie and Muehlebach, Michael},
booktitle = {Proceedings of the International Conference on Machine Learning},
volume = {306},
year = {2026},
address = {Seoul, South Korea},
publisher = {PMLR}
}
