# Nemotron-Labs-Image 30B-A3B text-to-image on a 12 GB card

NVIDIA's autoregressive text-to-image MoE (AtomicChat Q4_K_M, 25.4 GB) on stock llama.cpp with every routed expert in RAM, a 7000 MiB MoE cache and GPU-side sampling: a 1024x1024 image in 61.5 s (68.7 tok/s) against 108.6 s for stock --fit; NVIDIA's decoder adds 0.23 s on the GPU. Non-commercial licence.

- Recipe id: `nemotron-labs-image`  ·  status: measured  ·  updated 2026-11-29
- Model: [Nemotron-Labs-Image-30B-A3B](https://huggingface.co/nvidia/Nemotron-Labs-Image-30B-A3B) (30B (3B active) hybrid MoE (23 Mamba-2, 23 MoE with 128 routed experts top-6, 6 attention) writing visual codes; L24SQ ViT decoder)
- Weights: GGUF Q4_K_M (mostly Q5_0 and Q8_0), 25.4 GB, from https://huggingface.co/AtomicChat/Nemotron-Labs-Image-30B-A3B-GGUF, file `Nemotron-Labs-Image-30B-A3B-Q4_K_M.gguf`, revision `f0d9baa3ead2fcafce876c4f0204fc005ccc4ee7`
- Engine: [llama.cpp](https://github.com/ggml-org/llama.cpp) b671865c7 (stock; AtomicChat's patch only changes the converter); CUDA sm_86 build
- Hardware: NVIDIA GeForce RTX 3060 12 GB, 62 GB RAM, Intel Core i5-12500, NVMe SSD
- Context: 6,144 tokens
- Placement: Every routed expert in RAM (21.3 GiB, page cache); non-expert weights, the LM head and a 7000 MiB cache of hot experts on the GPU. The decoder runs on the GPU after the server stops.
- Contributor: [David Hatley](https://github.com/davidghatley)

## Run it

From `nemotron-labs-image/` in a clone of https://github.com/davidghatley/3060-recipes:

```sh
./generate.sh "prompt"
```

API: llama-server /completion with raw prompt ids (tools/nli.py), PNG out on port 8107

Key flags: `-ngl 99 --cpu-moe --fit off`, `--moe-cache-mib 7000 --moe-cache-cpu-share 0.95`, `--backend-sampling`, `-c 6144 -np 1 -fa on`, `NL_PROFILE=stock for the baseline`

The script itself (`nemotron-labs-image/generate.sh`, machine paths shown as `$MODELS`, `$SCRATCH`, `~`; set them to where your weights and builds live):

```sh
#!/usr/bin/env bash
# Prompt -> PNG with Nemotron-Labs-Image-30B-A3B on the 3060.
#   ./generate.sh [-s 1024x1024] [-S 42] [-n 1] [-o out.png] "prompt"
#   -s  size (multiples of 16; the card recommends 1024x1024, 1184x880, 1248x832, 880x1184)
#   -S  first seed; -n  images (seeds S, S+1, ...; one server start for all of them)
#   -o  output PNG (with -n > 1: out.png becomes out-s<seed>.png)
# Steps: NVIDIA's tokenizer builds the prompt ids (CPU); then ONE gpu_run hold starts serve.sh (port 8107), writes the
# visual tokens, stops the server, and runs NVIDIA's decoder on the freed GPU (NL_DECODE_DEVICE=cpu decodes on the CPU
# after the lock is released: ~30 s per 1024x1024 image instead of under a second). Every NL_* knob of serve.sh applies.
# Sampling is the card's (temperature 0.9, top-p 1.0, top-k off); see tools/nli.py.
set -euo pipefail
R=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
size=1024x1024; seed=42; n=1; out=$PWD/output.png
while getopts "s:S:n:o:" o; do case $o in s) size=$OPTARG ;; S) seed=$OPTARG ;; n) n=$OPTARG ;; o) out=$OPTARG ;; *) exit 2 ;; esac; done
shift $((OPTIND - 1)); prompt=${1:?usage: generate.sh [-s WxH] [-S seed] [-n count] [-o out.png] "prompt"}
case "$out" in /*) ;; *) out=$PWD/$out ;; esac
dir=$(dirname "$out"); base=$(basename "$out" .png); work="$dir/.$base.nli"; mkdir -p "$work"
seeds=$(seq -s, "$seed" $((seed + n - 1)))
python3 -I -c 'import json,sys; json.dump({"user": sys.argv[1]}, open(sys.argv[2], "w"))' "$prompt" "$work/prompt.json"
"$R/tools/py.sh" "$R/tools/nli.py" tokenize --prompts "$work/prompt.json" --sizes "$size" --out "$work/ids.json" > /dev/null
key="user@${size}"; dev=${NL_DECODE_DEVICE:-cuda}
export PORT=${NL_PORT:-8107} NL_PORT=${NL_PORT:-8107} NLI_LEDGER=$work/ledger.jsonl GPU_RUN_MEM=${GPU_RUN_MEM:-44G}
job() {   # runs inside the gpu_run hold
  NL_NO_GPU_RUN=1 READY_WAIT=600 "$R/../scripts/with_server.sh" gen "$R/serve.sh" "$work" -- \
    python3 -I "$R/tools/nli.py" gen --ids "$work/ids.json" --key "$key" --seed "$seeds" --out "$work" --label generate
  if [ "$dev" != cpu ]; then
    "$R/tools/py.sh" "$R/tools/nli.py" decode --device "$dev" --label generate --tokens "$work"/*.tokens.json
  fi
}
export -f job; export R work key seeds dev
"$HOME/anime-pipeline/tools/gpu_run" --need "${NL_NEED:-10500}" --wait "${NL_WAIT:-7200}" bash -c job
[ "$dev" = cpu ] && "$R/tools/py.sh" "$R/tools/nli.py" decode --device cpu --dtype fp32 --label generate --tokens "$work"/*.tokens.json
for s in $(seq "$seed" $((seed + n - 1))); do
  src="$work/user-${size}-s$s.png"; [ -f "$src" ] || { echo "no image for seed $s (see $work)" >&2; continue; }
  dst=$out; [ "$n" -gt 1 ] && dst="$dir/$base-s$s.png"
  cp "$src" "$dst"; cp "$work/user-${size}-s$s.txt" "${dst%.png}.txt"; echo "saved $dst"
done
```

## Measured results

| Metric | Conditions | Value | Stock | Ceiling | Source |
|---|---|---|---|---|---|
| decode | 1024x1024 image, median of 8 prompts, seed 42 | 68.69 tok/s | 38.7 | 87 | [nemotron-labs-image/RESULTS.md:61](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L61) |
| other | wall time per 1024x1024 image (generation) | 61.5 s | 108.6 |  | [nemotron-labs-image/RESULTS.md:62](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L62) |
| decode | 1248x832 image (fox) | 70.75 tok/s |  |  | [nemotron-labs-image/RESULTS.md:63](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L63) |
| other | decoder, 1024x1024, GPU bf16 | 0.228 s |  |  | [nemotron-labs-image/RESULTS.md:66](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L66) |
| decode | aggregate with -np 4, capped samples | 127.0 tok/s |  |  | [nemotron-labs-image/RESULTS.md:51](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L51) |
| quality | valid images at 1024x1024, all inspected | 8/8 images |  |  | [nemotron-labs-image/RESULTS.md:32](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L32) |
| vram_peak | llama-server while generating | 10250 MiB |  |  | [nemotron-labs-image/RESULTS.md:68](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L68) |
| ram_peak | RSS high-water | 25.1 GB |  |  | [nemotron-labs-image/RESULTS.md:69](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L69) |
| startup | server ready, warm page cache | 2-3 s |  |  | [nemotron-labs-image/RESULTS.md:67](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L67) |
| ttft | 85-token prompt, warm | 0.69-0.73 s |  |  | [nemotron-labs-image/RESULTS.md:65](https://github.com/davidghatley/3060-recipes/blob/main/nemotron-labs-image/RESULTS.md#L65) |

## Caveats

- Non-commercial use only (NVIDIA OneWay Noncommercial License, section 3.3), for the model, the decoder, the GGUF and the images.
- The model card's -ngl 99 line does not load on 12 GB; the baseline is the same line without -ngl (llama.cpp --fit).
- The same seed gives a different image on a different config (the first visual token flips at temperature 0.9); one same-config pair also diverged, cause not found.
- Drift against BF16 is not measured.
- 512x512 gives broken grids; use the card's sizes.
- The -np 4 throughput figure is from capped 1,200-token samples, not full images.

## Credits

- NVIDIA Nemotron Labs: The model behind the Nemotron-Labs-Image recipe; its tokenizer code builds the prompts and its decoder makes the PNGs (NVIDIA OneWay Noncommercial License). (https://huggingface.co/nvidia/Nemotron-Labs-Image-30B-A3B)
- AtomicChat: The Q4_K_M file the Nemotron-Labs-Image recipe serves, and the tested llama.cpp revision it runs on. (https://huggingface.co/AtomicChat/Nemotron-Labs-Image-30B-A3B-GGUF)
- llama.cpp (ggml-org and contributors): The engine for Flint, the 3D coder and Inkling-2-Mini, and the base of the Kintsugi fork. (https://github.com/ggml-org/llama.cpp)
- PedroMarinhoDev: The comparison point for the Nemotron-Labs-Image recipe (its 77.2 s per 1024x1024 image figure on an emulated 12 GB budget). (https://github.com/PedroMarinhoDev/ComfyUI-Nemotron-Image)
- 0xSero / Sybil Solutions: The tuning method behind the Flint and Inkling recipes; its q8_0 KV gotcha is one we confirmed on Flint. (https://github.com/sybil-solutions/inference-optimisation-skill)
- Hugging Face: Every model, quant and drafter in these recipes is fetched from the Hub at a pinned revision and checked against the API's sha256; the base model's MTP tensors were fetched with HTTP range requests. (https://huggingface.co)
- NVIDIA: Every recipe runs on CUDA on this card; cuBLAS SGEMV is our VRAM bandwidth probe (342 GB/s), nvidia-smi dmon is the telemetry, and Inkling's experts ship in NVFP4. (https://www.nvidia.com/en-us/geforce/graphics-cards/30-series/rtx-3060-3060ti/)

## Reproductions

None yet. Ran it on your own 3060? Report your numbers: https://github.com/davidghatley/3060-recipes/issues/new?template=reproduction.yml

## Machine-readable

- https://davidghatley.github.io/3060-recipes/recipes/nemotron-labs-image/recipe.json
- Folder with scripts and raw runs: https://github.com/davidghatley/3060-recipes/tree/main/nemotron-labs-image
- Full results log: https://raw.githubusercontent.com/davidghatley/3060-recipes/main/nemotron-labs-image/RESULTS.md

## Full write-up (README)

Text to image with [nvidia/Nemotron-Labs-Image-30B-A3B](https://huggingface.co/nvidia/Nemotron-Labs-Image-30B-A3B)
on the RTX 3060 12 GB, using stock llama.cpp.

The model is autoregressive. A 30B mixture-of-experts language model (3B active per token, hybrid Mamba-2 / MoE /
attention) writes the picture as a grid of visual codes, one row at a time: 4,176 tokens for 1024×1024. NVIDIA's
L24SQ decoder then turns the codes into pixels. Making an image is one long decode, so image time is decode speed.

The weights are [AtomicChat's Q4_K_M GGUF](https://huggingface.co/AtomicChat/Nemotron-Labs-Image-30B-A3B-GGUF)
(25.4 GB). That is twice the card, so the routed experts stay in RAM. Two flags do most of the work:
- **llama.cpp's MoE cache** keeps the experts that image tokens use most on the GPU (7000 MiB of the card);
- **`--backend-sampling`** draws each token from the 327,680-entry vocabulary on the GPU instead of the CPU.

Numbers and image notes are in [RESULTS.md](RESULTS.md). The experiment log is [PLAN.md](PLAN.md), the ceilings are
in [THEORY.md](THEORY.md), and the raw data is in `runs/`.

> **Licence: NVIDIA OneWay Noncommercial License.** Section 3.3 allows use of the model, the decoder and anything
> derived from them (this GGUF and the images included) only non-commercially, meaning for research or evaluation.
> AtomicChat's GGUF carries the same licence. See `LICENSE` in either Hugging Face repo, or
> [NVIDIA's licence PDF](https://developer.download.nvidia.com/licenses/NVIDIA-OneWay-Noncommercial-License-22Mar2022.pdf).

### Result

| One 1024×1024 image | Stock llama.cpp `--fit` | **This recipe** |
|---|---:|---:|
| Visual-token decode | 38.7 tok/s | **68.7 tok/s (1.77×)** |
| Generation time per image | 108.6 s | **61.5 s** |
| Decoder (codes to pixels, GPU bf16) | 0.23 s | 0.23 s |
| 1248×832 image | not run | 57–59 s (70.8–73.6 tok/s) |
| VRAM / RAM | 9.8 GB / 24.7 GB | 10.25 GB / 25.1 GB |

- 8/8 prompts gave valid images at 1024×1024 and 2/2 at 1248×832 (median of the 8 at seed 42; range 57–64 s).
- **The model card's line (`-ngl 99 -c 6144 -np 1`) does not load on 12 GB**: it tries to allocate 23.7 GB on the
  card. The stock column is the same line without `-ngl`, so llama.cpp's `--fit` picks the split.
- 68.7 tok/s is 79 % of the bandwidth ceiling for a cache with 85 % hits (87 tok/s, THEORY.md). The rest is the
  fixed per-layer cost of 46 MoE and Mamba layers and the cache misses computed on the CPU. The last flag levers gave
  under 2 %, so tuning stopped there.
- For comparison, PedroMarinhoDev's
  [ComfyUI port](https://github.com/PedroMarinhoDev/ComfyUI-Nemotron-Image) reports 77.2 s per 1024² image for a
  12 GB budget with W4A8 weights. That figure was emulated on an RTX 4090 and was not run here.
- **Four images at once:** `-np 4` reaches 127 tok/s in aggregate, 1.65× the images per hour, but each image
  takes about 2.4× as long (32.5 tok/s per stream). It was measured on capped samples only and is not a shipped profile (RESULTS.md).

| fox | sign | stack | kite |
|---|---|---|---|
| ![fox](runs/images/q09-tuned/fox-1024x1024-s42.png) | ![sign](runs/images/q09-tuned/sign-1024x1024-s42.png) | ![stack](runs/images/q09-tuned/stack-1024x1024-s42.png) | ![kite](runs/images/q09-tuned/kite-1024x1024-s42.png) |

Seed 42, the tuned default, no cherry-picking: these are the only seed-42 images of those prompts. The sign reads
"FRESH BREAD AD / DAILY", which is wrong. Every image's defects are listed in RESULTS.md.

### Use it

```
## 1. weights (pinned; sha256 checked)
##    AtomicChat/Nemotron-Labs-Image-30B-A3B-GGUF @ f0d9baa3 -> $MODELS/nemotron-labs-image/atomicchat/
##      Nemotron-Labs-Image-30B-A3B-Q4_K_M.gguf (sha256 3ff36f96…)
##    nvidia/Nemotron-Labs-Image-30B-A3B @ d7c2ba6a -> $MODELS/nemotron-labs-image/nvidia/
##      model.safetensors (the visual tokenizer/decoder, sha256 1d94c3f7…) + the small files under hf/ in repo layout
##      (tokenizer, chat template, Nemotron-Labs-Image-Tokenizer/ remote code)
## 2. engine: stock llama.cpp b671865c7 (AtomicChat's tested revision), CUDA build
##    -> $SCRATCH/llama.cpp/master-b671865c7/bin
## 3. decoder env (CPU tokenizer + GPU decoder): uv venv, python 3.12, torch 2.11.0+cu128, transformers 5.23.0
##    -> $SCRATCH/envs/nemotron-image (runs/env-nemotron-image-freeze.txt)

./generate.sh "A cinematic photograph of a red fox in a snowy pine forest at dawn."      # -> ./output.png
./generate.sh -s 1248x832 -S 7 -n 4 -o shots/fox.png "..."                               # 4 seeds, one server start
NL_DECODE_DEVICE=cpu ./generate.sh "..."                                                 # decode on the CPU (8 s)
```

`generate.sh` does the following:
1. Builds the prompt ids with NVIDIA's tokenizer: the system prompt plus `Generate a {W}x{H} image.` and your
   text, with thinking off.
2. Takes **one** `gpu_run` hold and starts `serve.sh` (port 8107).
3. Writes the visual tokens with the card's sampling (temperature 0.9, top-p 1.0, top-k off).
4. Stops the server and decodes on the freed GPU.
5. Writes `out.png` with an `out.txt` that records the prompt, size, seed and sampling.

Each grid is checked before decoding. Use the card's sizes: 1024×1024, 1184×880, 1248×832 or 880×1184. At
512×512 the model writes broken grids.

`serve.sh` alone gives a llama-server that takes raw prompt ids (`tools/nli.py gen` is the client). Its launch line:

```
llama-server -m Nemotron-Labs-Image-30B-A3B-Q4_K_M.gguf --alias nemotron-labs-image \
  -ngl 99 --cpu-moe --fit off -c 6144 -np 1 --host 127.0.0.1 --port 8107 \
  --moe-cache-mib 7000 --moe-cache-cpu-share 0.95 --backend-sampling -fa on
```

Every knob has an `NL_*` override (see the header of `serve.sh`). `NL_PROFILE=stock` runs the baseline line.

### Limits

- **Same seed, different config, different image.** Changing the placement, cache size or sampler changes the float
  sums slightly. At temperature 0.9 that changes the first visual token and so the whole picture. A seed reproduces
  an image on the same config. One pair of same-config runs did diverge, though, so do not rely on a seed across
  restarts (RESULTS.md, Determinism).
- **Drift against BF16 was not measured.** No BF16 run fits on this box.
- Text in images is hit and miss: one of the two sign prompts misspelled. One of the two 1248×832 posters had a
  broken layout.
- While an image is being made, the server holds 10.25 GB of VRAM and the GPU lock.

### Files

| Path | What |
|---|---|
| `generate.sh` | prompt to PNG, one GPU-lock hold (holds the lock while serving) |
| `serve.sh` | llama-server with the tuned flags; `NL_PROFILE=stock` for the baseline |
| `tools/nli.py` | `tokenize` (NVIDIA tokenizer), `gen` (llama-server client + grid check + ledger), `decode` (NVIDIA decoder) |
| `tools/py.sh` | runs the decoder env's python with `-I`, offline |
| `tools/gate.sh`, `tools/run.sh`, `tools/batch.sh`, `tools/summ.py` | the A/B harness: one server start per run, control/candidate/control per lock hold, medians |
| `tools/decoder_bench.py` | decoder speed, memory and round-trip PSNR |
| `prompts/set.json` | the 8 fixed prompts |
| `configs/` | one JSON per tried config; `best-config.json` is the shipped one |
| `runs/` | `ledger.jsonl` (every measurement), batch scripts and logs, server logs, `images/` (every image with its tokens and prompt) |

### Credits

- [NVIDIA](https://huggingface.co/nvidia/Nemotron-Labs-Image-30B-A3B): the model, the L24SQ visual tokenizer and
  decoder, and the tokenizer code.
- [AtomicChat](https://huggingface.co/AtomicChat/Nemotron-Labs-Image-30B-A3B-GGUF): the GGUF conversion (their
  converter patch exports the visual codebook as vocabulary), the Q4_K_M file, and the tested llama.cpp revision.
- [llama.cpp](https://github.com/ggml-org/llama.cpp) (ggml-org and contributors): the engine, including the MoE cache
  and backend sampling.
- [PedroMarinhoDev](https://github.com/PedroMarinhoDev/ComfyUI-Nemotron-Image): the ComfyUI port and its 12 GB
  figure, used as the comparison point.
- [inference-optimisation-skill](https://github.com/sybil-solutions/inference-optimisation-skill) by 0xSero / Sybil
  Solutions: the method (ceilings first, one change per run between controls, a plateau rule, quality gates).
- PyTorch and Hugging Face transformers run the decoder; the Hugging Face Hub hosts the pinned weights.
