Text-to-Image
MLX
Safetensors
English
nemotron_h
apple-silicon
mac
autoregressive
mamba
Mixture of Experts
nemotron
nemotron-labs-image
experts6-dense8
custom_code
Instructions to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit --local-dir Nemotron-Labs-Image-30B-A3B-MLX-6bit
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download code/scripts/make_card.py from VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit: direct link, hf CLI and curl.
- Browser
- Download file 7.94 kB
-
https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit/resolve/main/code/scripts/make_card.py
- Command line
-
hf download hf://VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit/code/scripts/make_card.py
-
curl -L -o make_card.py https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit/resolve/main/code/scripts/make_card.py
7.94 kB
| """Write the Hugging Face model card for a published tier. | |
| python make_card.py 8bit|5bit OUT/README.md | |
| """ | |
| import sys | |
| from pathlib import Path | |
| TIERS = { | |
| "8bit": dict( | |
| title="8-bit", recipe="q8", what="routed experts 8-bit (affine, group 64); everything else bf16", | |
| disk="38 GB", mem="Macs with 48 GB or more", | |
| speed="36.4 tok/s, about **115 s per 1024² image** on an M4 Pro (48 GB), peak 39.1 GB; batches of 4 seeds: about 50 s per image", | |
| kl="0.0185", floor="1.05", flips="9.95%", nll="+0.001", | |
| lead="KL to the exact fp32 model is 1.05x that of bf16 itself (the official pipeline's precision): indistinguishable from the reference's own rounding.", | |
| other="[5bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit) for 36 GB Macs (1.6x); [6bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit), the fast 36 GB tier (1.7x)", | |
| tested="M4 Pro 48 GB (real weights; 24 renders plus cold-start and batch runs)", | |
| ), | |
| "5bit": dict( | |
| title="5-bit", recipe="q5", what="routed experts 5-bit (affine, group 64); everything else bf16", | |
| disk="27 GB", mem="Macs with 36 GB", | |
| speed="61-63 tok/s, about **67 s per 1024² image** on an M5 Max (36 GB), peak 27.9 GB", | |
| kl="0.0282", floor="1.60", flips="11.9%", nll="+0.017", | |
| lead="The highest-fidelity tier that fits a 36 GB Mac. 6-bit experts score better (1.19x) but do not fit 36 GB with the dense layers in bf16; 4-bit tiers lose text accuracy (3.1-3.5x).", | |
| other="[8bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-8bit) for 48 GB+ Macs (1.05x); [6bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-6bit), ~22% faster at 1.7x", | |
| tested="M5 Max 36 GB (real weights)", | |
| ), | |
| "6bit": dict( | |
| title="6-bit experts, 8-bit rest", recipe="experts6-dense8", | |
| what="routed experts 6-bit; Mamba and attention projections, shared experts and output head 8-bit (all affine, group 64); norms, router and embedding bf16", | |
| disk="29 GB", mem="Macs with 36 GB (little headroom: 29.5 GB peak) or more", | |
| speed="78-82 tok/s, about **52 s per 1024² image** on an M5 Max (36 GB), peak 29.5 GB; batches of 2: 61 tok/s per image", | |
| kl="0.0290-0.0301", floor="1.65-1.71", flips="12.1%", nll="+0.019", | |
| lead="The fast tier: about 22% quicker than the 5bit tier on an M5 Max at slightly lower fidelity (1.7x vs 1.6x). It reads fewer bytes per token because the dense layers and the 327,680-row output head are 8-bit.", | |
| other="[8bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-8bit) for 48 GB+ Macs (1.05x); [5bit](https://huggingface.co/VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-5bit), the higher-fidelity 36 GB tier (1.6x)", | |
| tested="M5 Max 36 GB (real weights, 24 renders) and M4 Pro 48 GB (same tier built in memory, cross-generation check)", | |
| ), | |
| } | |
| CARD = """--- | |
| license: other | |
| license_name: nvidia-license | |
| license_link: LICENSE | |
| library_name: mlx | |
| pipeline_tag: text-to-image | |
| base_model: nvidia/Nemotron-Labs-Image-30B-A3B | |
| base_model_relation: quantized | |
| language: [en] | |
| tags: [mlx, apple-silicon, mac, text-to-image, autoregressive, mamba, moe, nemotron, nemotron-labs-image, {recipe}] | |
| --- | |
| # Nemotron-Labs-Image-30B-A3B for Apple Silicon, MLX {title} | |
|  | |
| An MLX port of NVIDIA's [Nemotron-Labs-Image-30B-A3B](https://huggingface.co/nvidia/Nemotron-Labs-Image-30B-A3B), an | |
| autoregressive image generator (hybrid Mamba2 / attention / 128-expert MoE, 30B total, 3B active) that writes an | |
| image as a grid of discrete visual tokens, decoded to pixels by its bundled L24SQ ViT. Unofficial; not affiliated with | |
| or endorsed by NVIDIA. **Non-commercial use only** (research and evaluation), per the NVIDIA License included here. | |
| **This tier:** {what}. {disk} on disk; for {mem}. {lead} | |
| Other tiers: {other}. | |
| ## Quick start | |
| ```bash | |
| hf download VisualInference/Nemotron-Labs-Image-30B-A3B-MLX-{tag} --local-dir nemotron-image-{tag} | |
| pip install ./nemotron-image-{tag}/code | |
| nemotron-image "A risograph concert poster in pink and teal with the headline LOW TIDE ORCHESTRA" \\ | |
| --model nemotron-image-{tag} --size 880x1184 --seed 42 --out poster.png | |
| ``` | |
| Sizes: any multiple of 16; recommended 1024x1024, 1184x880, 1248x832, 880x1184. `--seeds 1,2,3,4` renders several | |
| candidates in one batch (more images per minute). Each PNG gets a JSON sidecar with settings and timings. | |
| ## Speed and memory | |
| {speed}. The decode step is one compiled, fixed-shape MLX graph per token (Mamba states, preallocated KV cache, | |
| sampling noise as a Metal kernel) at ~85-88% of the measured memory-bandwidth roofline. The 1.76 GB embedding table is | |
| memory-mapped (or kept on the GPU when there is room); the pixel decoder runs in fp32 after generation (<1 s). | |
| ## Fidelity | |
| Measured on 24 real sequences (99,564 generated image tokens: 8 official gallery prompts at 4 resolutions, 8 visual | |
| test prompts x 2 seeds), teacher-forced, against the model run exactly in fp32 (which matches the upstream PyTorch | |
| module to ~1e-6 per layer): | |
| | | KL vs fp32 (nats/token) | x bf16 floor | sampled tokens that differ from fp32 | NLL vs fp32 | | |
| |---|---|---|---|---| | |
| | bf16 (the official vLLM precision) | 0.0176 | 1.00 | 9.65% | +0.003 | | |
| | **this tier** | **{kl}** | **{floor}** | {flips} | {nll} | | |
| **On seeds.** The sampler reproduces vLLM's seeded sampler, including the CUDA Philox noise stream for a given seed, | |
| and the math follows vLLM's bf16 rounding. But token-for-token identity with the official outputs is not achievable | |
| by any implementation: bf16 rounding alone changes ~10% of sampled image tokens relative to the exact model, the | |
| first one typically within the first row of the grid, and every later token depends on it. The same seed gives a | |
| picture from the same prompt family, not the same pixels, on any other GPU, parallelism setting or port. This | |
| holds for this port too: the same tier and seed on an M4 Pro and an M5 Max first differ at token 18 and token 61 in | |
| two tests, because the two GPUs round bf16 matrix products differently. | |
| ## Valid images by default (and an upstream bug) | |
| At the recommended size 880x1184 the original model, run exactly, writes the wrong size header (`width=884` with | |
| probability 1.0), so the official `infer.py` rejects the image. This port enforces the image grammar after | |
| `<|img_start|>` (fixed header and row markers, visual codes inside rows). Masking only rescales the allowed | |
| probabilities, so every run the official pipeline would accept is reproduced token for token (verified: 4,175 of | |
| 4,175 tokens identical on real weights), and the rejected ones become valid images. `--unconstrained` samples | |
| exactly like the reference, failures included. | |
| ## Details | |
| - Numerics: residual stream bf16; RMSNorm rounded once; MoE router bf16 x bf16 -> fp32 logits (as vLLM on H100; the | |
| generic mlx-lm `nemotron_h` rounds router logits to bf16); Mamba conv, softplus, decay and SSM state in fp32. | |
| - On M5 GPUs MLX runs float32 GEMMs in TF32 by default; the package disables that before the first GEMM. | |
| - Tested: {tested}. Expected to work on any Apple | |
| Silicon Mac with enough memory (M1 is slower: no native bf16). Python 3.10+, MLX 0.32.5. | |
| - Full write-up, methods and raw numbers: `code/docs/FINDINGS.md`, `code/docs/RESULTS.md`. | |
| ## License | |
| The weights are a modified distribution of NVIDIA's Nemotron-Labs-Image-30B-A3B under the NVIDIA License (`LICENSE`, | |
| non-commercial: research or evaluation only); upstream notices are retained in `NOTICE`. The runner in `code/` is | |
| distributed under the same license (it contains a port of NVIDIA's L24SQ decoder); parts derived from Apache-2.0 | |
| files keep those notices. | |
| """ | |
| tag = sys.argv[1] | |
| t = TIERS[tag] | |
| Path(sys.argv[2]).write_text(CARD.format(tag=tag, **t)) | |
| print("wrote", sys.argv[2]) | |