CERIN AMROTH · ML systems

experts4bit-qlora

Fine-tune and serve large Mixture-of-Experts models on one GPU, with 4-bit experts in GPU memory, RAM or SSD.

v0.58.0 · current status → · Install · Try the example · Check the limits

What it does

Use this runtime to load, fine-tune, and serve fused MoE models in 4-bit. transformers v5 stores a MoE's experts as one fused three-dimensional parameter per layer rather than ordinary nn.Linear modules, so the standard bitsandbytes module walker can leave most of the expert weights in bf16 and the model still OOMs; this package quantises exactly that fused stack, fine-tunes it with per-expert LoRA, keeps experts in host RAM or on NVMe when they do not fit, and serves the result on one consumer NVIDIA GPU.

Choose a task

Task guideStatusConditions
Why does `load_in_4bit` still OOM on a Mixture-of-Experts model?supportedModels and limits
How do I QLoRA-train the fused experts of a MoE (per-expert LoRA on 4-bit experts)?supportedModels and limits
How can I run a Mixture-of-Experts model larger than my GPU's VRAM?supportedModels and limits
How do I offload MoE experts to host RAM, or serve and train them from an NVMe arena?supportedModels and limits
How do I serve a large MoE on a consumer GPU (RTX 5090 class)?supportedModels and limits
How do I train and serve MoE models released in MXFP4 (gpt-oss, DeepSeek-V4)?experimentalModels and limits

Install

Routes from docs/capabilities.json at the pinned commit; the first entry of the register is the primary route.

pip install "experts4bit-qlora[train]"

Primary route: streaming loader + trainer.

Alternatives:

Environment (from the capability register; one list for all of these routes, so not every item applies to each): OS: Linux · Python: >=3.11 tested in CI (pyproject says >=3.10; 3.10 is not tested) · Accelerator: NVIDIA CUDA GPU (bitsandbytes 4-bit); NVIDIA CUDA GPU, sm_80 or newer (Triton kernels via grouped-nf4-gemm) · Requires: an expert arena baked with grouped-nf4-gemm (nvme_bake_nf4 for NF4, the MXFP4 relocation bake for native MXFP4); bitsandbytes>=0.43; grouped-nf4-gemm>=0.43.0 ([fast] extra; the floor is pyproject.toml's, validated by CI); local NVMe or a fast block device; pinned host RAM for the hot tier; torch>=2.2; transformers>=5.0 for the streaming loader ([train] extra); triton>=3.4 (Linux-only distribution)

Smallest verified example

Needs a CUDA GPU, network access and the checkpoint download; the strict verification is the observable result (it raises if any expert stack is still high precision). Syntax-checked in the repository's CI; executed on rented hardware lanes with receipts.

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",
)
verify_moe_4bit(model, strict=True)   # raises RuntimeError naming the first high-precision expert stack
How each capability addresses the problem

Use this when

Do not use this when

Limitations — what it does not promise

Support depends on the model and execution path. Check the model and hardware conditions before choosing a route; the full repository limits for each capability are below.

quantize-fused-moe-experts · full limits
qlora-fused-moe-experts · full limits
run-moe-larger-than-vram · full limits
offload-moe-experts-to-cpu-or-nvme · full limits
serve-moe-on-consumer-gpu · full limits
mxfp4-moe-training-and-residency · full limits

Current measured position

Representative active claims, selected from docs/claims.json at the source commit; retired and superseded claims never appear here. The whole register at that commit holds 460 measured · 8 measured-private · 3 open · 19 superseded · 9 retired; each card below is an active claim and links its receipt at the pinned commit.

TC1 amendment 69 (#835), one rented RTX 5090 (tc1-5090-137, AMD EPYC 7713, Vast machine 55913): TC1's field recipe (alpaca, seq 2048, micro-batch 2 x accum 4) over 60 load-gated steps with both frameworks on one stack (venv-unsloth, torch 2.12.1), e4b's matched arm at every current default against Unsloth 2026.9.14's matched arm (grouped_mm), two draws each in ABBA order, every arm profiled. Unsloth's device time per profiled step is 1.924x e4b's (3259.1 / 1693.9 ms; P205 HELD, [1.7, 2.7]); s/step 9.780 against 3.489, a wall ratio of 2.803 on this host (P206 HELD, [2.3, 3.3]). Unsloth runs 14.09x e4b's CPU ops per step (P207 HELD, >= 8) and its GPU is busy for 0.333 of its timed step against e4b's 0.486, so the wall ratio is 1.457x the device ratio (P208 HELD, >= 1.05). Held-out at N 0.75643 against 0.75761 (P209 HELD, within 0.01). e4b peaks 26.16 GB against Unsloth's 24.27.measured
e4b.train.h2h.unsloth.qwen3.5090.2026-10-08.field-device-ratio · RTX 5090 (sm_120), one rented Vast.ai verified/secure host (tc1-5090-137: instance 54809007, AMD EPYC 7713, Vast machine 55913); e4b @ 737f02f + grouped-nf4-gemm @ 8371c38, torch 2.12.1+cu130; Unsloth 2026.9.14 · measured 2026-10-08 · receipt (pinned)
QLoRA on frozen NF4 experts improves a held-out Alpaca eval from 1.4813 to 1.0290 on OLMoE-1B-7B.measured
e4b.train.olmoe-converges · allenai/OLMoE-1B-7B · measured 2026-07-04 · receipt (pinned)
With OFFLOAD_EXPERTS=1 the frozen experts stream from pinned CPU RAM one layer at a time, so a fused MoE whose 4-bit experts exceed the card still QLoRA-trains on 12 GB: Qwen3-30B-A3B peaks at 7.16 GB and Gemma-4-26B-A4B at 8.47 GB, both of which OOM without offload. Cost is about +11% s/step at OLMoE scale.measured
e4b.offload.fits-30b-class · · measured 2026-07-02 · receipt (pinned)
Throughput census (bo7, the shipped 0.35.0 / 0.30.0 code): single-stream (B=1) paged decode of Qwen/Qwen3-30B-A3B's LICENSED serving stack -- streamed GPTQ-calibrated int4 experts at 64k C4-validation tokens + C4-calibrated int4 attention + round-1/2 folds + router epilogue + decode glue, the configuration bo6c licensed on both texts (e4b.serve.buildout.bo6c.qwen3.all-calibexp-streamed-64k.k8.2026-09-05; pack artifact 11512 gptq / 776 rtn) -- on one rented RTX 5090: 238.1 tok/s (4.20 ms/step), x2.067 vs e4b's own NF4 control on the same box (8.68 ms = 115.2 tok/s); anchor-class projection 159.2 x 2.067 = about 329 tok/s, a PROJECTION from a class that was never certified.measured
e4b.serve.census.bo7.qwen3.b1.5090.2026-09-05 · RTX 5090 (sm_120, driver 595.84, 32607 MiB) on an AMD EPYC 7Q83 64-core host (128 CPUs, 251 GB, container cgroup memory.max 183,318,347,776 B = 170.7 GiB), Vast.ai instance 49916675; the 5090 class carries ~8.5% inter-box dispersion and B=1 is host-bound, so cross-host ratios are indicative only · measured 2026-09-05 · receipt (pinned)
Two arithmetically equivalent forwards of an MoE model disagree because rounding flips router top-k choices: 4.52% of (layer, token) choices on gpt-oss-20b and 6.77% on Qwen3-30B, with the disagreement carried by the flipped tokens (KL 0.0504 vs 0.0013). Every parity delta must be read against a per-model measured floor, never against zero.measured
e4b.parity.moe-routing-flip-floor · RTX 5090, rented · measured 2026-09-03 · receipt (pinned)
On a card that already fits the model, 4-bit expert projections cost more GPU energy per op than native bf16 on the measured comparator: one OLMoE-dims gate_up projection on one rented RTX 5090 (500 W power limit, driver 570.133.07), bitsandbytes 0.50.2, the unchanged harness, medians of three passes. bnb.matmul_4bit costs 1.748x native's total J/op at decode M=1, 1.601x at prefill M=512 and 1.965x at train fwd+bwd M=32; dequantize-then-linear costs 3.293x, 1.539x and 1.405x. The registered prediction that matmul_4bit would read near 1x at decode is refuted: 1.748x, at half native's power and 0.28 of its op rate. Batch is where the energy goes: the fused 4-bit MoE forward's J/token at batch 4096 is 0.063 of batch 64's (about 16x lower).measured
e4b.train.energy-honest.5090.2026-10-05 · one rented RTX 5090 (32 GB; power limit 500 W of 600 W max; driver 570.133.07; PCIe gen 4 x16) on an AMD EPYC 7B12 host (503 GB), Vast.ai verified-secure · measured 2026-10-05 · receipt (pinned)

Current status and compatibility

v0.58.0 · current status → — the position page is docs/STATUS.md at the pinned commit (latest on main, unpinned; not the source of any fact rendered here); the site's status and compatibility pages are generated from the same commit, and the evidence words are defined once in the system manifest's vocabulary.

Problems this solves

Package identity, supported platforms and source links
Canonical PyPI package
experts4bit-qlora
Canonical repository
github.com/pjordanandrsn/experts4bit-qlora
Import
experts4bit_qlora
License
MIT
Repository version
0.58.0 (at the pinned commit)
Latest PyPI version
0.58.0 — published
Source commit
f15cb7d695cf (2026-10-24) · files at this commit
Claim register
claims tiered in the public register: 460 measured · 8 measured-private · 3 open · 19 superseded · 9 retired — docs/claims.json (pinned)
Current status
v0.58.0 · current status → · capability table · docs/STATUS.md (pinned)
System manifest
runtime package of one system with grouped-nf4-gemm — system-manifest.json (verbatim, identical in both repositories; provenance)

Also discoverable as e4b, e4b-qlora, experts4bit, expertsnbit, experts-mxfp4. These are lookup-only aliases from the system manifest; experts4bit-qlora is the canonical project.

What it supports

Modes
inference, offload, quantization, serving, streaming, training
Formats
bf16, fp16, fp4, fp8, int4, int8, mxfp4, nf4
Model families
deepseek_v2; deepseek_v4 (Flash, Pro); ernie4_5_moe; gemma4_text; gpt_oss; granitemoe; granitemoehybrid; lfm2_moe; mixtral; nemotron_h; olmoe; qwen3_5_moe; qwen3_moe; qwen3_next
Operating system
Linux
Python
>=3.11 tested in CI (pyproject says >=3.10; 3.10 is not tested)
Accelerator
NVIDIA CUDA GPU (bitsandbytes 4-bit); NVIDIA CUDA GPU, sm_80 or newer (Triton kernels via grouped-nf4-gemm)
Public entry points
cli:python -m experts4bit_qlora.serve, cli:python -m experts4bit_qlora.train, experts4bit_qlora.arch.topology:describe_moe, experts4bit_qlora.engines.batched:enable_batched_train, experts4bit_qlora.engines.capture:capture_decode, experts4bit_qlora.engines.dense_offload:enable_dense_offload, experts4bit_qlora.engines.expert_profile:hot_sets_from_profile, experts4bit_qlora.engines.fast:enable_fast, experts4bit_qlora.engines.fast:enable_fast_train, experts4bit_qlora.engines.int4_attn_calib:enable_serve_attn_int4_calib, experts4bit_qlora.engines.int4_experts:enable_serve_experts_int4, experts4bit_qlora.engines.layer_major:layer_major_step, experts4bit_qlora.engines.nvme_experts:enable_mxfp4_nvme_residency, experts4bit_qlora.engines.nvme_experts:enable_nvme_residency, experts4bit_qlora.engines.nvme_train:enable_nvme_train_residency, experts4bit_qlora.engines.offload:enable_expert_offload, experts4bit_qlora.engines.paged_runner:PagedModelRunner, experts4bit_qlora.engines.pipelined:enable_pipelined_residency, experts4bit_qlora.loader:load_moe_4bit_streaming, experts4bit_qlora.lora:ExpertsLoRA, experts4bit_qlora.recipe:estimate_qlora_footprint, experts4bit_qlora.recipe:prepare_qlora_training, experts4bit_qlora.serve_recipe:estimate_serve_footprint, experts4bit_qlora.verify:verify_moe_4bit, experts4bit_qlora:Experts4bit, experts4bit_qlora:ExpertsNbit, flag:E4B_EXPERT_PROFILE
Owns (system manifest)
  • model loading (streaming loader, fused expert stacks, Experts4bit/ExpertsNbit bases)
  • quantization orchestration (NF4/MXFP4 routes, int4 expert store, calibration drivers)
  • adapters (ExpertsLoRA)
  • training (trainer, fast/batched/hybrid paths, checkpointing)
  • residency integration (host-RAM and NVMe engines bound to a loaded model)
  • serving (paged runner, decode stack, HTTP shim)
  • model-level measurement, quality gates and the claims register for model-level numbers
Related package
grouped-nf4-gemm — one system, two independently released packages: the runtime package depends on the kernel package through its optional `fast` extra; the kernel package never depends on the runtime package. Dependency direction: experts4bit-qlora -> grouped-nf4-gemm.

rendered from experts4bit-qlora 0.58.0 · source: pjordanandrsn/experts4bit-qlora@f15cb7d695cf · checked 2026-10-24