aurora-peft
Re-implementation của AuroRA: Breaking Low-Rank Bottleneck of LoRA with Nonlinear Mapping (NeurIPS 2025) dưới dạng một tuner cho 🤗 PEFT (>=0.13).
Cài đặt
pip install aurora-peft
Hoặc cài bản dev:
pip install -e .
Sử dụng nhanh
import torch
from transformers import AutoModel
from aurora_peft import AuroraConfig, get_aurora_model
base = AutoModel.from_pretrained("bert-base-uncased")
config = AuroraConfig(
r=8, # LoRA rank (= ANL in/out dim)
alpha=16, # LoRA alpha
target_modules=["query", "value"],
grid_size=5, # B-spline intervals (paper: 5)
spline_order=3, # B-spline degree (paper: 3)
scale_noise=0.1,
)
model = get_aurora_model(base, config)
# Optimizer chỉ update params của Aurora (ANL + A + B)
model.print_trainable_parameters()
Hoặc dùng qua API chuẩn của peft:
from peft import get_peft_model
from aurora_peft import AuroraConfig
model = get_peft_model(base, AuroraConfig(r=8, target_modules=["q_proj", "v_proj"]))
Công thức
AuroRA mở rộng LoRA bằng cách chèn một Adaptive Nonlinear Layer (ANL)
giữa hai low-rank matrix A và B:
Δh = B · ANL(A · x)
trong đó ANL là một mini KAN:
ANL(z) = tanh(W_base @ tanh(z)) + W_spline @ Σ_i B_i(z)
B_i là basis B-spline bậc spline_order trên grid_size khoảng.
Re-implementation note
Đây là re-implementation không chính thức, dựa trên paper và 4 bản fork trong repo gốc https://github.com/ins1stenc3/AuroRA. Mục tiêu:
- Rút logic lõi (ANL + cách gắn vào
nn.Linear) ra khỏi 4 fork trùng lặp. - Tương thích với
pefthiện hành (>=0.13). - Có unit test so khớp số học với bản gốc.
Bản gốc (paper) dùng hai công thức:
- Training (dynamic):
h = W₀x + B · ANL(Ax)— input-dependent. - Inference (static merge):
ΔW = B · ANL(A)— weight-only, merge được vàoW₀.
Repo gốc chỉ hiện thực 1 trong 2. Thư viện này:
- Forward (training) dùng công thức dynamic (khớp paper Algorithm 1, line "Training Phase").
merge()dùng công thức static (line "Inference Preparation"), nên sau khi merge, forward chỉ làWx(không còn gọi ANL nữa).
Tests
pip install -e ".[test]"
pytest
Giấy phép
Apache-2.0 (theo license của peft và paper).
Metadata
Release files for aurora-peft 0.1.5
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 | |
|---|---|---|---|---|
| aurora_peft-0.1.5.tar.gz | 37.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aurora_peft-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.4 kB
Release files / aurora_peft-0.1.5.tar.gz
| Download URL | aurora_peft-0.1.5.tar.gz |
|---|---|
| Size | 37.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc4a893c2ef24a4c500fd23ca47df4e1ad3e393f5c4445421a5a94f3002f1c74
|
|
BLAKE2b-256 checksum How to use checksums |
ea90edabdd80aca5aa464a40d8fd30cfe9eda214e8f4acd32b58d3220b064c98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / aurora_peft-0.1.5-py3-none-any.whl
| Download URL | aurora_peft-0.1.5-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69c4fdada18f65f3d9132e3b0d5b8787742619f048825fe68e736768b178ffc9
|
|
BLAKE2b-256 checksum How to use checksums |
07dbc76b12b750d8106f34484ffcb985a00947820ee11ebcbd1ed4f2ae92bfe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for aurora-peft 0.1.5
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.