Skip to main content

experts4bit-qlora

Fine-tune large MoE models on a single GPU.

PyPI CI

Quantize the experts. Train adapters. Move weights to RAM or SSD when GPU memory runs out.

Mixture-of-Experts (MoE) models keep many expert networks but activate only a few per token. Their fused expert weights can escape ordinary load_in_4bit=True loading and stay in full precision. This runtime loads those weights in 4-bit, trains them with QLoRA, and serves the model.

New here? Start with Loggetta. pip install loggetta installs this runtime and its kernels. Use loggetta inspect to check your machine and loggetta plan to plan supported training. Use this package directly when you need control over loading, training, serving, or memory placement.

Install · Results · Model support · Task guides

Latest released package: experts4bit-qlora 0.51.0 · Current development status: docs/STATUS.md on main (this README describes main) · Released documentation for 0.51.0: docs/ · README.md · CHANGELOG.md

Install

pip install "experts4bit-qlora[train,fast]"

GPU execution needs Linux + NVIDIA CUDA. Fast kernels need an sm_80+ GPU, Triton ≥ 3.4; the streaming loader needs transformers ≥ 5.0. The base runtime needs torch ≥ 2.2; the fast extra applies the kernel package’s newer PyTorch floor. CI tests Python 3.11. Start with a CUDA-compatible PyTorch installation for your GPU.

For a smaller install, the base package provides quantization and adapters; [train] adds the trainer; [fast] adds grouped-nf4-gemm. Exact dependency floors live in pyproject.toml.

Load a model and check it

This downloads Qwen3-30B-A3B and keeps its frozen experts in host RAM. Allow enough RAM and disk space for the checkpoint.

import torch
from experts4bit_qlora import load_moe_4bit_streaming, verify_moe_4bit

model, config = load_moe_4bit_streaming(
    "Qwen/Qwen3-30B-A3B", "cuda", torch.bfloat16,
    r=8, alpha=16, quant_type="nf4", offload=True,
)
verify_moe_4bit(model, strict=True)  # raises if an expert stack stayed high precision

To train the built-in Alpaca example:

MODEL=Qwen/Qwen3-30B-A3B OFFLOAD_EXPERTS=1 STEPS=150 R=8 TRAIN_EXPERTS=1 OUT=./out python -m experts4bit_qlora.train

For your own dataset and reusable native adapters, see Loggetta's training guide.

Choose the path you need

Task Start here
Plan before loading weights Loggetta
Train fused MoE experts with QLoRA Training guide
Speed up training enable_fast_train(model, dgrad=True); assert its return count is positive
Fit experts in RAM or NVMe storage Offload guide
Fit the rest of the model enable_dense_offload — freeze base weights before adding adapters
Serve on a consumer GPU Serving guide
Work with native MXFP4 checkpoints MXFP4 guide

What is measured

These are specific workloads, with public results and controls. The table is checked against claims.json in CI. Measured means a public run record; the full register also labels private, superseded, and retired results.

Workload and evidence Result Status
Qwen3-30B-A3B QLoRA · RTX 5090 · TC1's field recipe, both frameworks on one stack, e4b at every default (e4b.train.h2h.unsloth.qwen3.5090.2026-10-08.field-device-ratio) Unsloth spends 1.92× e4b's GPU time per step; wall-clock 2.80× on an AMD EPYC 7713. Comparable held-out loss. Peak 26.16 vs 24.27 GB (Unsloth lower). measured
Packed 4,096-token Qwen3 training · RTX 5090 · e4b at its defaults (e4b.train.h2h.unsloth.qwen3.5090.2026-10-08.packed-4k-device-ratio) Unsloth spends 1.160× e4b's GPU time per step; wall-clock 1.472× on that box's host. measured
Expert-offload training on a 12 GB card (e4b.offload.fits-30b-class) Qwen3-30B-A3B: 7.16 GB peak; Gemma-4-26B-A4B: 8.47 GB. measured

The speed rows profile both frameworks on one stack (torch 2.12.1). The GPU-time ratio is the host-independent figure; the wall-clock ratio grows on a slower host, because Unsloth runs 14× e4b's CPU ops per step at the field recipe. On packed rows the wall ratio read 1.287, 1.472 and 1.773 on three hosts. The earlier field-recipe readings, 2.352 and 2.468, were wall ratios from before the reentrant checkpoint. The offload row uses a different training setup.

Qwen comparison · Packed 4K result · All current results

New in 0.51.0

  • Faster MoE decode by default in serve_paged. On one RTX 5090: the B=1 fused stack decodes one Qwen3-30B-A3B NF4 request 1.59× as fast, and the fused router epilogue cuts Qwen3.6-MoE's one-request step to 0.973. With grouped-nf4-gemm 0.44.0, int4 Qwen3-30B-A3B's 32–64-row decode steps get the wide tile table and int4 attention projections. Each default names its way back in the CHANGELOG.
  • Fixes: every card licenses the same routers, and an int4 lm_head no longer crashes the prefill-graph warm-up.
  • Opt-in: E4B_INT4_TILE_PROGRAMS=P splits the cumsum tile table over P programs (needs the grouped-nf4-gemm release after 0.44.0).

Check the fit

  • Models: use the architecture support matrix. Support and test coverage vary by family and execution path.
  • Memory: CPU/NVMe offload trades transfer time and host storage for GPU memory. Measure your workload.
  • Speed: 4-bit saves weight memory; it is not automatically faster or more energy-efficient than bf16 when both fit.
  • Serving: vLLM was faster in the measured Qwen decode comparison. This runtime focuses on fitting and controlling low-bit MoEs; see the serving results.
  • Platforms: CUDA execution is the tested path. ROCm, macOS, Windows and other non-CUDA GPU execution are outside this package's scope.

Documentation and machine-readable data

Task guides · API and capability map · Claims and evidence · Package compatibility · Documentation index · llms.txt · Contributing

License

MIT. The vendored bitsandbytes code is also MIT; see third-party notices. For integration or research work: jordananderson.work.

Metadata

Release files for experts4bit-qlora 0.51.0

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

Source distribution (sdist)

Source distribution for experts4bit-qlora 0.51.0
File Size Uploaded
experts4bit_qlora-0.51.0.tar.gz 2.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for experts4bit-qlora 0.51.0
File Interpreter ABI Platform
experts4bit_qlora-0.51.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.8 MB

Release files / experts4bit_qlora-0.51.0.tar.gz

Download URL experts4bit_qlora-0.51.0.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
8c04b3242dbc6cd22417a0f6a968ca54038033613be1e30d8a63cd86ed7ba5cc
BLAKE2b-256 checksum
How to use checksums
0d87639a7b599e6a24fcffd8eed0b9d1eebe8d17451e2bcf987dce476c3b9a00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / experts4bit_qlora-0.51.0-py3-none-any.whl

Download URL experts4bit_qlora-0.51.0-py3-none-any.whl
Size 659.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96d5df5f8ef7c89784512ffe86ba435e0cb1d167e7884305bdd257caafd28c6c
BLAKE2b-256 checksum
How to use checksums
bde59e12c2583ce9945c4be7f5ec4e6fccd4aec70ad23a725810401888fe8ed6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.54.0

2 release files

0.53.0

2 release files

0.52.0

2 release files

This release

0.51.0 This release

2 release files

0.37.8

2 release files

0.37.7

2 release files

0.37.6

2 release files

0.37.5

2 release files

0.37.4

2 release files

0.37.3

2 release files

0.37.2

2 release files

0.37.1

2 release files

0.37.0

2 release files

0.36.4

2 release files

0.36.3

2 release files

0.36.2

2 release files

0.36.1

2 release files

0.36.0

2 release files

0.24.1

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.0

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.1

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.5

2 release files

0.17.4

2 release files

0.17.3

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.3

2 release files

0.16.2

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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