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.

On a 12 GB card: with OFFLOAD_EXPERTS=1, Qwen3-30B-A3B QLoRA-trains at 7.16 GB peak GPU memory while the other ~13–15 GB of packed experts stay in pinned CPU RAM (e4b.offload.fits-30b-class). The command · how to read the number

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.

Limits. GPU execution needs Linux and NVIDIA CUDA; the fast kernels need an sm_80+ GPU. Support varies by model family and execution path. 4-bit saves memory but is not automatically faster than bf16, and vLLM was faster in the measured Qwen decode comparison. Check the fit.

Install · Results · Model support · Task guides · Hugging Face

Latest released package: experts4bit-qlora 0.52.0 · Current development status: docs/STATUS.md on main (this README describes main) · Released documentation for 0.52.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; the wall-clock ratio varies with the host (below). 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

How the two Unsloth rows were measured
  • Hardware: one rented RTX 5090 per reading (a Vast.ai verified host). The field-recipe row ran on an AMD EPYC 7713 host; the packed row on an AMD engineering-sample CPU with a 30.7-CPU quota.
  • Software: torch 2.12.1+cu130 for both frameworks; Unsloth 2026.9.14; e4b and grouped-nf4-gemm at the commits in each run record.
  • Method: matched fp32 adapters and initialization, two draws per arm, three profiled steps before the timed window. Validity and scoring by bench/tc1/tc1_reduce.py, under the pre-registration.
  • Rerun: the TC1 harness on one RTX 5090, token qwen3pos69 (field recipe) or qwen3pos68 (packed rows).
  • Run records (versions, host and every arm): field recipe · packed rows

New in 0.52.0

  • Faster int4 decode by default with grouped-nf4-gemm 0.45.0. On one RTX 5090 the captured 64-row decode step of Qwen3-30B-A3B int4 is 15.5 % faster with the tile table over 4 programs, every token identical (E4B_INT4_TILE_PROGRAMS=1 turns it off). The T == 1 decode skips five kinds of launch, bitwise the same output.
  • Paged serving reads more checkpoints: local expert-int4 directories and Qwen3.5's native composite text checkpoints.
  • The training estimate prices the loss as measured: 12 bytes per logit, and the chunked LM loss where the run chunks it. estimate_env() reports the switches it reads.
  • Opt-in: E4B_TRAIN_FUSE_QKV=1 fuses training attention's q/k/v projection; it failed P129's step-0 quality bar, so it is off by default (CHANGELOG).

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.52.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.52.0
File Size Uploaded
experts4bit_qlora-0.52.0.tar.gz 2.2 MB Details

Built distribution (wheel)

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

Total release size: 2.9 MB

Release files / experts4bit_qlora-0.52.0.tar.gz

Download URL experts4bit_qlora-0.52.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0a29e4cebbdf76e9da2b5ff0bb1a734f3d523384f78246909ae2b4469ec13ad4
BLAKE2b-256 checksum
How to use checksums
9f879158a91aab85a84dd93132f6e1111576c7fd17321fb600d466461751487b
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 10, 2026.

Transparency log

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

Download URL experts4bit_qlora-0.52.0-py3-none-any.whl
Size 670.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd1f544c3440c733f3ab421d8ab14bb746d90704926c1631f8aeb17492694d4a
BLAKE2b-256 checksum
How to use checksums
355b41bd72228a9be820138ec2f9c92e07298acf501bf4ce6e988a56f42771ee
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 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.54.0

2 release files

0.53.0

2 release files

This release

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