Skip to content

Run Qwen-Image 2.1 from its DFloat11 checkpoint - #15

Merged
IonDen merged 5 commits into
mainfrom
feature/s4c-qwen-image-21
Oct 8, 2026
Merged

IonDen merged 5 commits into
mainfrom
feature/s4c-qwen-image-21

Conversation

@IonDen

@IonDen IonDen commented Oct 8, 2026

Copy link
Copy Markdown
Owner

This adds Qwen-Image 2.1 to mlx-dfloat generate and the Python API (DFloatModel("qwen-image-2.1")). It runs from the DFloat11 checkpoint mingyi456/Qwen-Image-2.1-DF11-ComfyUI. That checkpoint is a single ComfyUI file with no config.json. The reader added in #13 opens it through a layout pinned to that file's revision.

Qwen-Image 2.1 reuses the per-block hook from Z-Image: each of the 32 blocks gets its decoded weights just before it runs. mflux compiles the denoising step, so this path runs it uncompiled, and the per-block evaluation can't happen inside a compiled function. The defaults are mflux's own: 40 steps, guidance 1.0 and the linear scheduler. Classifier-free guidance needs both a guidance above 1.0 and a negative prompt, as in mflux, and the command warns when one comes without the other. The text encoder, VAE and tokenizer come from Qwen/Qwen-Image-2.1, pinned to the revision the measured runs used. Only the tokenizer files are downloaded, not the whole processor folder.

Evidence, measured on an M1 Max with 32 GB (macOS 27.0.1, mlx 0.32.2, mflux 0.20.0), 1024², seed 42:

Check Result Record
Every compressed matrix (225) and stored tensor (72) vs the BF16 original equal bench/results/parity/qwen-image-2.1/full-vs-bf16.json
GPU decoder vs CPU reference, all 225 matrices equal bench/results/parity/qwen-image-2.1/kernel-vs-reference.json
Final latents vs the same transformer streaming BF16 weights (4 steps, guidance 4.0, negative " ", so classifier-free guidance on) bit-identical, images pixel-identical bench/results/identity/qwen-image-2.1-1024/compare.json
32 GB, 40 steps, guidance 1.0 peak 20.42 GiB, 6.9 min; weights stay loaded through the VAE decode bench/results/tiers/qwen-image-2.1-1024.json
16 GB and 24 GB, simulated under those Macs' caps refused by the fit check (14.6 GiB predicted while encoding the prompt; budgets 8.67 and 14.00 GiB). Forced runs are stopped by the watchdog in that phase bench/results/refusals/ and bench/results/tiers/aborts/

The peak is the process's memory footprint as the OS counts it. The memory estimate is calibrated from the runs in bench/results/calibration/qwen-image-2.1-1024.json. Its VAE term covers the highest of eleven samples, because the VAE phase varies by about 1 GiB between identical runs and a fit check must not under-predict. No 16 or 24 GB Mac was measured.

Changes that reach every model:

  • From Python, each model's generate_image now runs under the same memory caps mlx-dfloat generate installs, and puts MLX's limits back when it returns. Before this, a Python caller ran with no wired limit, while the memory estimates' VAE terms were measured under the caps. A wired limit the process already set is left alone.
  • When a call drops the compressed transformer before the VAE decode, the estimate for that step now counts the BF16 tensors that stay loaded (6 to 137 MB, depending on the model). No 16, 24 or 32 GB verdict changes at 1024².
  • A family's encode phase can now be sized from a measured term, and a group name with a zero-padded block index (layers.01) is refused in every family.
  • scripts/verify_remote_group.py checks config-less checkpoints by range reads, and scripts/verify_image.py covers Qwen-Image 2.1.

The FLUX.1, Z-Image and FLUX.2 Klein model code is otherwise unchanged. The five commits each pass the test suite; the README table check passes from the last one, where the records and the README change together.

@IonDen IonDen self-assigned this Oct 8, 2026
@IonDen IonDen added the enhancement New feature or request label Oct 8, 2026
@IonDen
IonDen merged commit 96198ac into main Oct 8, 2026
6 checks passed
@IonDen
IonDen deleted the feature/s4c-qwen-image-21 branch October 8, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant