Skip to content

mlx tensor-parallel: replicate vector-quantized codebooks - #2268

Open
noahzelezny wants to merge 1 commit into
exo-explore:mainfrom
noahzelezny:vq-codebook-replicate
Open

mlx tensor-parallel: replicate vector-quantized codebooks#2268
noahzelezny wants to merge 1 commit into
exo-explore:mainfrom
noahzelezny:vq-codebook-replicate

Conversation

@noahzelezny

@noahzelezny noahzelezny commented Aug 17, 2026

Copy link
Copy Markdown

What

Vector-quantized (VQ) models store each expert weight as codes + scales + a [K, d] codebook. Under tensor-parallel sharding, codes and vq_scales shard correctly on the default axes, but the codebook is a shared lookup table indexed by the codes — slicing it across ranks leaves every rank decoding against a fraction of the table, producing garbage output. This adds a guard to both sharding closures in auto_parallel.py so any parameter path ending in codebook is replicated instead of sliced.

The guard can't misfire on existing models: no parameter anywhere in current mlx-lm is named codebook.

Also adds model cards for the three VQ builds this was found on — Qwen3.5-397B-A17B-VQ-2.2bpw / 2.4bpw / 3.1bpw — which load on stock mlx-lm via the bundled model.py (config.json model_file), so no engine changes are needed beyond this one.

Why

I built these quants to make this model more accessible to the community. The 2.2bpw and 2.4bpw builds each run on a single 128 GB Mac (~101 / ~112 GiB on disk); the 3.1bpw quality build is what tensor-parallel across two Macs is for — which is where this guard matters. Verified serving across a 2-node ring: output identical to the single-box run.

The artifacts also ship the model's full vision tower at source precision as a top-level indexed shard, and the cards declare the vision capability — mlx-lm is text-only for this architecture, but exo's vision path loads the tower from the folder directly. Verified: an image query through /v1/chat/completions against the 2.4bpw build on a live 2-node tensor instance returns a correct description.

Testing

  • Card TOMLs validate against ModelCard.load_from_path (existing card tests pass).
  • Live 2-node tensor-parallel serving of the VQ builds: coherent generation, output matching the unsharded run.
  • Without the guard: garbage output (the failure this fixes).
  • Vision: image round-trip through the API on a live tensor instance, correct description returned.

VQ-quantized MoE experts store each expert tensor as codes + scales +
a [K, d] codebook. The codes and scales shard correctly on the default
axes, but the codebook is a shared lookup table indexed by the codes --
slicing it across ranks makes every rank decode against a fraction of
the table and produce garbage. Guard both sharding closures so the
codebook is replicated instead.

Also adds model cards for three VQ builds of Qwen3.5-397B-A17B, which
are what this was found on. They load on stock mlx-lm via the bundled
model.py (config.json model_file); no engine changes beyond the above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant