experts4bit-qlora
Fine-tune large MoE models on a single GPU.
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.50.0 · Current development status: docs/STATUS.md on main (this README describes main) · Released documentation for 0.50.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.50.0
- Serving takes more requests by default.
serve_pagedsizes its slot count to the GPU's free memory and decodes each step as one graph: on Qwen3-30B-A3B int4 on one RTX 5090 at 2,048 tokens a slot, 12 req/s within the latency bound instead of 4.E4B_PAGED_MAX_SEQS=16andE4B_PAGED_BUCKETS=1,2,4,8,16restore the old behaviour (CHANGELOG). - Opt-in: final-position prefill logits (
E4B_PAGED_LAST_LOGITS=1) and the decode lookahead (E4B_PAGED_DECODE_LOOKAHEAD=1). - The training comparison is quoted as GPU time, with the wall-clock ratio on its host beside it (above).
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.50.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| experts4bit_qlora-0.50.0.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| experts4bit_qlora-0.50.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.6 MB
Release files / experts4bit_qlora-0.50.0.tar.gz
| Download URL | experts4bit_qlora-0.50.0.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a88824e929ef6b8247316557e36f7ce437a7fc75652a1ae51ce4bf3f8121442d
|
|
BLAKE2b-256 checksum How to use checksums |
d791e7b71eef6c1758abbb2dd5ee92be22c640a0bc192802a7f1f6350b8680c2
|
| 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 8, 2026.
Transparency logRelease files / experts4bit_qlora-0.50.0-py3-none-any.whl
| Download URL | experts4bit_qlora-0.50.0-py3-none-any.whl |
|---|---|
| Size | 650.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26fac95411f4d3d172fe4c7b41d171259a8d54e08828eae9bca2a3b7b04fa583
|
|
BLAKE2b-256 checksum How to use checksums |
1c7e6d5d1ca4cb3089b887e82b2fd42b5b55b33bcf70af718e7bee392e8cf896
|
| 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 8, 2026.
Transparency log