Skip to main content

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:

  1. Rút logic lõi (ANL + cách gắn vào nn.Linear) ra khỏi 4 fork trùng lặp.
  2. Tương thích với peft hiện hành (>=0.13).
  3. 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ào W₀.

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aurora-peft 0.1.1
File Size Uploaded Provenance
aurora_peft-0.1.1.tar.gz 27.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aurora-peft 0.1.1
File Interpreter ABI Platform
aurora_peft-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.7 kB

Release files / aurora_peft-0.1.1.tar.gz

Download URL aurora_peft-0.1.1.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
86be50c636d8769c7cbc6f54848b782ad5cf3af1cce82802b05d7d1fe5501757
BLAKE2b-256 checksum
How to use checksums
992087c62618ecc3983b742e6d25f52eebf920aa3d7aa274656812e7573b0537
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.1-py3-none-any.whl

Download URL aurora_peft-0.1.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c557bb552328081f782cd2c3b5afb7b48c15b82b3cd78a506e696f0546f782a7
BLAKE2b-256 checksum
How to use checksums
14d99736fb61eca89f45ef3ba63acf4879c2fbcc936bf8bc53125d963ff471c0
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.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page