MLorc - Momentum Low-Rank Compression for Memory-Efficient LLM Fine-tuning
Unofficial implementation of "MLorc: Momentum Low-rank Compression for Large Language Model Adaptation"
This repository introduces MLorc (Momentum Low-rank Compression), a novel and highly memory-efficient paradigm designed to significantly reduce the memory footprint of full-parameter fine-tuning for large language models. Based on the paper "MLorc: Momentum Low-rank Compression for Large Language Model Adaptation" this method offers a compelling alternative to existing memory-efficient techniques.
Install
pip install MLorc-optim
How MLorc Works
MLorc's core innovation lies in its approach to momentum compression and reconstruction:
- Direct Momentum Compression: It directly compresses and reconstructs both first and second-order momentum using Randomized SVD (RSVD) at each optimization step.
- Adaptive Second-Order Momentum Handling: To ensure stability, especially for non-negative second-order momentum, MLorc adaptively adds a small constant to zero values introduced by ReLU during reconstruction.
Key Advantages of MLorc
MLorc is broadly applicable to any momentum-based optimizer (e.g., Adam, Lion) and delivers superior performance:
- State-of-the-Art Performance: Empirically, MLorc consistently outperforms other memory-efficient methods like LoRA and GaLore in terms of validation accuracy. It can even match or exceed the performance of full fine-tuning with a small rank (e.g.,
rank=4). - Memory and Time Efficiency: It maintains comparable memory efficiency to LoRA while demonstrating improved time efficiency compared to GaLore.
- Theoretical Guarantees: MLorc offers a theoretical guarantee for convergence, matching the convergence rate of the original Lion optimizer under reasonable assumptions.
Included MLorc-Integrated Optimizers
This repository integrates MLorc into six momentum-based optimizers, each with additional enhancements for improved performance and stability:
-
MLorc_AdamW: AdamW with MLorc compression, featuring:- Fused Backward Pass
- Gradient Descent with Adaptive Momentum Scaling (Grams): For better performance and faster convergence.
atan2smoothing & scaling: A robust replacement foreps(no tuning required), which also incorporates gradient clipping. (If enabled,epsis ignored.)- OrthoGrad: Prevents "naïve loss minimization" (NLM) that can lead to overfitting by removing the gradient component parallel to the weight, thus improving generalization
-
MLorc_Prodigy:- Same Features as
MLorc_AdamW - Incorporates MLorc with the Prodigy adaptive method and its associated features.
- Same Features as
-
MLorc_Lion: Lion with MLorc compression, featuring:- Fused Backward Pass
- OrthoGrad
use_cautious: use the cautious varaint of Lion.clip_threshold: whether to clip the gradients norm per-parameter as proposed in the paper Lions and Muons: Optimization via Stochastic Frank-Wolfe to make Lion more stable (default: 5.0, from the paper).
-
MLorc_DAdapt_Lion:- Same Features as
MLorc_Lion - Integrates MLorc with the DAdaptation adaptive method for LION, and includes the slice_p feature (from Prodigy).
- Same Features as
-
MLorc_Adopt:- Same Features as
MLorc_AdamW - Implements the method of ADOPT: Modified Adam Can Converge with Any β_2 with the Optimal Rate.
- Same Features as
-
MLorc_CAME:- Same Features as
MLorc_AdamW - The first moment (momentum) is compressed using the low-rank factorization from MLorc, while the adaptive pre-conditioning and confidence-guided updates are from CAME: Confidence-guided Adaptive Memory Efficient Optimization.
- Same Features as
Metadata
Release files for MLorc-optim 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mlorc_optim-0.1.8.tar.gz | 20.1 kB | Without provenance | Details for mlorc_optim-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlorc_optim-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for mlorc_optim-0.1.8-py3-none-any.whl |
Total release size: 50.9 kB
Release files / mlorc_optim-0.1.8.tar.gz
| Download URL | mlorc_optim-0.1.8.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65a2430adb496404e3e148097664cfc3dc001dc14f5caf00f3bb4faa86abceb1
|
|
BLAKE2b-256 checksum How to use checksums |
a2db652c3f407c0a80e933609ef8e72dc0e142c3bddbeaa2626be40c48dfb5dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Release files / mlorc_optim-0.1.8-py3-none-any.whl
| Download URL | mlorc_optim-0.1.8-py3-none-any.whl |
|---|---|
| Size | 30.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c78a517fb244bbbdcb2ff7224ae459f0aa62fdc3020c265f5b788ebfc644394d
|
|
BLAKE2b-256 checksum How to use checksums |
3a26312cebda944e4f3c42a220a6d06a1988fed44604b5f3e46c45d983a08363
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Security for MLorc-optim 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.