Quickstart#

Allocate ranks on CPU#

Choose directions using spectral energy without importing a tensor library:

from loraforge.compression import allocate_spectral_budget

ranks = allocate_spectral_budget(
    {"query": [5.0, 2.0], "value": [3.0, 1.0]},
    budget=2,
)
assert ranks == {"query": 1, "value": 1}

For heterogeneous resource costs and measured calibration losses, use quality-budget allocation.

Compress a local PEFT adapter#

On a supported GPU, compress physical factors into a new directory:

from loraforge.adapters import compress_peft_adapter

result = compress_peft_adapter(
    "adapter-original",
    "adapter-r4",
    keep=4,
    device="cuda:0",
)

The default accelerated backend is FlashTSQR. Adapter scaling, including rsLoRA when present, is preserved independently of retained rank. Input files remain unchanged; compact output stores the retained tensor dimensions. See the PEFT contract for supported modules, manifests and reload checks.

Enable an alpha serving path#

In each SGLang worker, before model construction:

from loraforge.integrations.sglang_experimental import install_qwen35_nf4

install_qwen35_nf4(mode="byte-pairs")

This path requires the prepared Qwen3.5-0.8B NF4 fixture, TP1, gfx90a, SGLang 0.5.22 and bitsandbytes 0.50.2. For spawned processes, use the documented plugin environment options in experimental APIs. The marker describes interface stability; it does not establish model quality.

Read the contracts#