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

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.3
File Size Uploaded Provenance
aurora_peft-0.1.3.tar.gz 35.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 48.2 kB

Release files / aurora_peft-0.1.3.tar.gz

Download URL aurora_peft-0.1.3.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
da3bc363bb8d68510b5b2d4c213ddc2cb346fb555e4c5269ea115e68c476ddaf
BLAKE2b-256 checksum
How to use checksums
4a1646efe2a87f1321ad743d168165c1b7476ecd0b7879875f06c191101c49fd
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.3-py3-none-any.whl

Download URL aurora_peft-0.1.3-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c68a731f04b2c369307e34d8d47ce2e9a324733661098d9e9c96873fbfb90e3
BLAKE2b-256 checksum
How to use checksums
95f20f6cd9bb58b22003797d9d515e70527bcc1dd653d59d91a90cee8000c789
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.3

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