MLX-Gen Documentation¶
MLX-Gen is an MLX-native generative image and video runtime forked from mflux. It can be used directly from the command line or embedded in Python applications that need local Apple Silicon generation.
Guides¶
- Getting started: install MLX-Gen, inspect the CLI, prepare or download model files, run image generation/editing, restore or upscale with SeedVR2, and start Wan or Bernini video workflows.
- Architecture: system overview and model-file lifecycle diagrams, package and factored-source shapes, role-aware routing, command boundaries, runtime failure contract, and Python integration boundary.
- API and CLI: public
mlxgencommand surface, generation router behavior, image/video/reference input roles, image editing, the--outpaint-filland--outpaint-passesconditioning-canvas options, negative-prompt support per route, SeedVR2, Wan video controls, Bernini R2V/RV2V/V2V, metadata, and capability schema 17. - Image edit modes: plain-language guide to latent img2img, edit-reference, masked edit/inpaint, base-Qwen control-inpaint, Qwen structured control, multi-reference, generative reframe, and outpaint including its selectable conditioning canvas, covering what each mode is good at and what to expect from the output.
- Masked editing: the canonical masked-edit page — request contract, per-model route matrix with proof grades, per-family behavior (Qwen edit and base routes with the tunable
--mask-strengthwarm start, Z-Image Turbo, FLUX.2 Klein, video masks), and route selection advice. - Qwen route matrix: current MLX-Gen route truth for Qwen Image and Qwen Image Edit, mapping public
mlxgencapability ids to the upstream Diffusers Qwen pipelines and the exact proof surfaces that already exist. - Qwen localized editing: plain-language explanation of Qwen masked edit, Qwen structured control, and shipped base-Qwen control-inpaint, including definitions of ControlNet and “sidecar”, the exact proof rows, and when each route is the right tool.
- Wan video: practical Wan2.2 T2V/I2V sizing, plain and masked prompt-guided A14B video-to-video, the natively ported Wan2.1-VACE-1.3B route (
wan-vace: reference-image object injection and learned mask conditioning with--vace-masked-region), the measured motion-fidelity ladder (strength vs gesture preservation, with a motion-preserving restyle recipe), the fps-resampling and audio copy-through contract with a playable proof, broader A14B target size families, full example commands, and included MP4/frame-strip assets. - Wan prompt encoding: how every Wan route (Wan 2.2 T2V/I2V/V2V, Wan 2.1 VACE, Bernini-R) encodes its prompt with the UMT5 text encoder in float32 on the GPU, weights read one block at a time, with diagrams of the run and of the block loop, measured time, memory and fidelity against 0.40.1, what changes for you (results for a given seed, the prompt-embedding cache,
--keep-text-encoder), how to reproduce a 0.40.1 clip, the cache location and how to clear it, usage examples, and the tests behind it. - MiniMax-H3 video with audio: native MiniMax-H3 text-to-video and first-frame image-to-video (
--image-path) with a synchronized stereo AAC soundtrack in one MP4, the publishedAbstractFramework/minimax-h3-bf16,AbstractFramework/minimax-h3-8bitandAbstractFramework/minimax-h3-4bitpackages with peak memory by mode and machine size, the--low-ramand--stream-blocksmodes, theminimax-h3,minimax-h3-turboandminimax-h3-turbo-544pcatalog entries with lightx2v 8-step Turbo adapters, community LoRA adapters in either key layout stacked on them, the structured prompt format (--soundscape,--music), frame/canvas rules, measured M5 Max runtime,mlxgen prepare, the generated-audio metadata contract, Python usage, motion-prompt guidance, current limits, and the included contact sheets and clips. - MiniMax-H3 memory, speed and quantization: what a MiniMax-H3 run holds in memory and what it reads from disk when needed, the
--low-ramand--stream-blocksmodes with their cost in time, the tested machine sizes from 24 GB to 96 GB, the 8-bit and mixed 4-bit packages compared with the released 16-bit weights, and the tests behind every figure. - Bernini-R 1.3B: experimental reference-to-video and video-edit routes, pinned BF16 runtime setup, measured memory, the committed official public parity bundle (full prompts and contact sheets per upstream example row), and task-specific recipes for many-reference binding and structure-changing edits.
- Spaceship snow workflow: reproducible model-backed T2I, I2I edit, multi-reference I2I, T2V A14B, and I2V A14B commands with included assets.
- Generation previews: step-wise previews rendered with published tiny autoencoders (
taef1,taef2), the--preview-decoder auto|tiny|fullcontract, the per-latent-space availability table, measured agreement against the full VAE, and the guarantee that final outputs are always full-VAE decoded. - Image upscaling: SeedVR2 command usage for image and video restoration, published 3B/7B q8/q4 package handles, shortest-edge and scale-factor sizing, the conservative safe-video profile, the validated June 21 five-second Eiffel
1xand2x3B/7B proof bundles plus timings/memory data, and real 5x image comparisons from a133x113source. - SeedVR2 video memory: what the VAE does in a SeedVR2 video restoration, why it needed about 190 KB per output pixel on MLX 0.32 (per-tap convolution scratch, stacked lazy evaluation, a pinned causal memory), how 0.40.2 sums each causal 3D convolution's taps one frame at a time with bit-identical output, with a diagram, the measured working memory, footprint and time per frame size, what changes for you (larger frames admitted, longer temporal chunks), the largest frame that fits and why, usage examples, and the tests behind it.
- Image edit capabilities: image-edit plus generative reframe and outpaint contact sheets, exact model/package status, the Qwen Image Edit 2511 q8 masked-edit proof, the exact base Qwen q8 structured-control and control-inpaint proofs, the exact Z-Image Turbo q8 native-inpaint proof, the FLUX.2 Klein base source-model starship proof, the published outpaint capability fields including
outpaint_preservationand the per-route validated envelope, and command logs for Qwen Image Edit, Qwen Image Edit 2509/2511, FLUX.2 Klein, Qwen control routes, Z-Image native inpaint, and latent I2I rows. FIBO Edit is unsupported through unifiedmlxgen generate. - Reframe and outpaint:
--reframe-paddingand--outpaint-paddingworkflows, per-side padding and how to extend one side, one axis, or all four in a single call, the--outpaint-fillconditioning-canvas modes and howautoresolves them, padding guidance, supported models, strict FLUX.2 Klein outpaint on distilled and base weights, the cross-route outpaint matrix with per-route timings and source drift on one source, the axis-coverage sheets across three source aspect ratios, and the validation profile ids for canvas expansion workflows. - LoRA: route-specific capability fields, explicit adapter download, strict scale matching, model-card base-model compatibility, source/no-LoRA/with-LoRA validation, exact public proof rows for the current Qwen, Z-Image, FLUX.2, ERNIE, and Wan routes, MiniMax-H3 adapters in the diffusers and original-checkpoint key layouts, and the current guidance that MLX-Gen q8 packages are the validated Lightning target rather than arbitrary external FP8 checkpoints.
- Model management: explicit download and prepare workflows, generation from local files, Bernini's pinned factored download and disk preflight, local package resolution, and Depth Pro downloads.
- Model recommendations: conservative starting picks for
18 GB,24 GB,32 GB,64 GB, and128+ GBMacs, using published MLX-Gen memory measurements rather than package size alone. - Quantization: current low-bit compatibility by model family, including the published package matrix, the measured MiniMax-H3 16-bit, 8-bit and mixed 4-bit packages with memory by mode and machine size, Bernini's BF16-only boundary, Bonsai ternary 2-bit support, SeedVR2 packages, Qwen/ERNIE policies, and Wan storage/runtime behavior.
- Hugging Face publishing: generated model cards, source license/access wording, default
AbstractFramework/<repo-name>usage, upload flow, and optional collection membership. - Python integration: route-resolved runtime planning/loading, Bernini's typed reference inputs, serial multi-output reuse, the model-agnostic outpaint and reframe pipeline (
run_outpaint,prepare_outpaint,prepare_reframe) and thepost_processbefore-save hook, SeedVR2's direct-model boundary, and shared progress callbacks. - Release: GitHub Release and PyPI trusted publishing workflow.
- FAQ: common questions about setup, memory versus disk, quantization, image/edit modes, SeedVR2, Wan (including results compared with 0.40.1 and first-run prompt encoding), and Bernini.
- Troubleshooting: common setup, cache, local-path, routing, quantization, outpaint conditioning-canvas, Bernini reference-fidelity, and Wan video problems with concrete fixes.
The top-level README remains the starting point for installation, model families, and project relationship details.
Project Documents¶
- Agent skill: the package skill that teaches AI agents to use
mlxgenand the Python runtime. - Acknowledgements: upstream mflux credit, post-fork maintainership, and model/community acknowledgements.
- Changelog: release history and migration notes.
- Contributing: local development, checks, and pull-request expectations.
- Architecture Decision Records: durable validation and architecture policies.
- Security: vulnerability reporting and model/token safety guidance.
- Code of Conduct: participation expectations.